Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : Note content overrides when switching between notes #307

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions src/application/services/useNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt

const route = useRoute();

/**
* Is there any note currently saving
* Used to prevent re-load note after draft is saved
*/
const isNoteSaving = ref<boolean>(false);

/**
* Note Title identifier
*/
Expand Down Expand Up @@ -219,8 +213,6 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
*/
const specifiedNoteTools = resolveToolsByContent(content);

isNoteSaving.value = true;

if (currentId.value === null) {
/**
* @todo try-catch domain errors
Expand Down Expand Up @@ -251,8 +243,6 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
* Store just saved content in memory
*/
lastUpdateContent.value = content;

isNoteSaving.value = false;
}

/**
Expand Down Expand Up @@ -297,7 +287,7 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
lastUpdateContent.value = null;
}

watch(currentId, (newId, prevId) => {
watch(currentId, (newId, _prevId) => {
/**
* One note is open, user clicks on "+" to create another new note
* Clear existing note
Expand All @@ -308,16 +298,6 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
return;
}

const isDraftSaving = prevId === null && isNoteSaving.value;

/**
* Case for newly created note,
* we don't need to re-load it
*/
if (isDraftSaving) {
return;
}

void load(newId);
});

Expand Down
1 change: 1 addition & 0 deletions src/presentation/pages/Note.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<Editor
v-if="isEditorReady"
ref="editor"
:key="id || 'new'"
v-bind="editorConfig"
@change="noteChanged"
/>
Expand Down
Loading