Skip to content

Commit

Permalink
fix: wait to run storage oper until prev one finished
Browse files Browse the repository at this point in the history
  • Loading branch information
betterRunner committed Nov 16, 2021
1 parent b88539f commit 64e3806
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/content-scripts/renderer/popup/note-book/note-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ export default defineComponent({
const { noteId = "", tag = "", isAddOrDelete = false } = data as any;
const fn = isAddOrDelete ? addItemToArrProperty : delItemFromArrProperty;
storage.notes = await fn(StorageKeys.notes, "id", noteId, "tags", tag);
mitt.emit("update-note-tag-cb");
});
/// update note of note
Expand Down
6 changes: 3 additions & 3 deletions src/content-scripts/renderer/popup/tag-book/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import randomColor from "randomcolor";
import { Coor } from "@/types/common";
import { Tag } from "@/types/tag";
import { Storage } from "@/types/storage";
import mitt from "@/utils/mitt";
import mitt, { sendEmitAndWait } from "@/utils/mitt";
import {
addItemToArr,
addItemToArrProperty,
Expand Down Expand Up @@ -149,7 +149,7 @@ export default {
} else {
tag.isSelect = !tag.isSelect;
if (tag.isSelect) {
mitt.emit("update-note-tag", {
await sendEmitAndWait("update-note-tag", {
noteId: props.noteId,
tag: tag.name,
isAddOrDelete: true,
Expand All @@ -162,7 +162,7 @@ export default {
props.noteId
);
} else {
mitt.emit("update-note-tag", {
await sendEmitAndWait("update-note-tag", {
noteId: props.noteId,
tag: tag.name,
isAddOrDelete: false,
Expand Down

0 comments on commit 64e3806

Please sign in to comment.