mirror of
https://github.com/standardnotes/mobile.git
synced 2026-05-19 12:04:31 -04:00
fix: insert template note when creating with default editor
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
|
||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
|
||||
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
|
||||
1C2EEB3B45F4EB07AC795C77 /* (null) in Frameworks */ = {isa = PBXBuildFile; };
|
||||
1C2EEB3B45F4EB07AC795C77 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; };
|
||||
33BB1B14071EBE5978EBF3A8 /* libPods-StandardNotes-StandardNotesTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 04FCB5A3A3387CA3CFC82AA3 /* libPods-StandardNotes-StandardNotesTests.a */; };
|
||||
BC8DEA834BF198E8511F04FF /* libPods-StandardNotesDev.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 51F2D747BE02C2A1BCFEEFD1 /* libPods-StandardNotesDev.a */; };
|
||||
CD7D5ECA27800609005FE1BF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD7D5EC927800608005FE1BF /* LaunchScreen.storyboard */; };
|
||||
@@ -83,7 +83,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1C2EEB3B45F4EB07AC795C77 /* (null) in Frameworks */,
|
||||
1C2EEB3B45F4EB07AC795C77 /* BuildFile in Frameworks */,
|
||||
DD3D1CE428EC1C8BA0C49211 /* libPods-StandardNotes.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@@ -5,11 +5,14 @@ import { ApplicationContext } from '@Root/ApplicationContext';
|
||||
import { SCREEN_COMPOSE } from '@Screens/screens';
|
||||
import {
|
||||
ApplicationEvent,
|
||||
ComponentMutator,
|
||||
ComponentViewer,
|
||||
ContentType,
|
||||
isPayloadSourceInternalChange,
|
||||
isPayloadSourceRetrieved,
|
||||
ItemMutator,
|
||||
NoteMutator,
|
||||
PayloadSource,
|
||||
SNComponent,
|
||||
} from '@standardnotes/snjs';
|
||||
import { ICON_ALERT, ICON_LOCK } from '@Style/icons';
|
||||
@@ -85,24 +88,30 @@ export class Compose extends React.Component<{}, State> {
|
||||
|
||||
componentDidMount() {
|
||||
this.removeNoteInnerValueObserver = this.editor?.addNoteInnerValueChangeObserver(
|
||||
(newNote, source) => {
|
||||
(note, source) => {
|
||||
if (isPayloadSourceRetrieved(source!)) {
|
||||
this.setState({
|
||||
title: newNote.title,
|
||||
text: newNote.text,
|
||||
title: note.title,
|
||||
text: note.text,
|
||||
});
|
||||
}
|
||||
|
||||
if (newNote.lastSyncBegan || newNote.dirty) {
|
||||
if (newNote.lastSyncEnd) {
|
||||
const isTemplateNoteInsertedToBeInteractableWithEditor =
|
||||
source === PayloadSource.Constructor && note.dirty;
|
||||
if (isTemplateNoteInsertedToBeInteractableWithEditor) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (note.lastSyncBegan || note.dirty) {
|
||||
if (note.lastSyncEnd) {
|
||||
if (
|
||||
newNote.dirty ||
|
||||
newNote.lastSyncBegan!.getTime() > newNote.lastSyncEnd.getTime()
|
||||
note.dirty ||
|
||||
note.lastSyncBegan!.getTime() > note.lastSyncEnd.getTime()
|
||||
) {
|
||||
this.showSavingStatus();
|
||||
} else if (
|
||||
this.context?.getStatusManager().hasMessage(SCREEN_COMPOSE) &&
|
||||
newNote.lastSyncEnd.getTime() > newNote.lastSyncBegan!.getTime()
|
||||
note.lastSyncEnd.getTime() > note.lastSyncBegan!.getTime()
|
||||
) {
|
||||
this.showAllChangesSavedStatus();
|
||||
}
|
||||
@@ -262,6 +271,18 @@ export class Compose extends React.Component<{}, State> {
|
||||
return this.context?.mobileComponentManager!;
|
||||
}
|
||||
|
||||
async associateComponentWithCurrentNote(component: SNComponent) {
|
||||
const note = this.note;
|
||||
if (!note) {
|
||||
return;
|
||||
}
|
||||
return this.context?.changeItem(component.uuid, (m: ItemMutator) => {
|
||||
const mutator = m as ComponentMutator;
|
||||
mutator.removeDisassociatedItemId(note.uuid);
|
||||
mutator.associateWithItem(note.uuid);
|
||||
});
|
||||
}
|
||||
|
||||
reloadComponentEditorState = async () => {
|
||||
this.setState({
|
||||
downloadingEditor: false,
|
||||
@@ -271,6 +292,12 @@ export class Compose extends React.Component<{}, State> {
|
||||
|
||||
const associatedEditor = this.componentManager.editorForNote(this.note!);
|
||||
|
||||
/** Editors cannot interact with template notes so the note must be inserted */
|
||||
if (associatedEditor && this.editor?.isTemplateNote) {
|
||||
await this.editor?.insertTemplatedNote();
|
||||
this.associateComponentWithCurrentNote(associatedEditor);
|
||||
}
|
||||
|
||||
if (!associatedEditor) {
|
||||
if (this.state.componentViewer) {
|
||||
this.componentManager.destroyComponentViewer(
|
||||
|
||||
Reference in New Issue
Block a user