Skip to content

Commit 1f82d31

Browse files
committed
fix: stabilize update/reset functions in NoteCreatorStore
1 parent bc4f16e commit 1f82d31

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

packages/app/src/State/NoteCreator.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,8 @@ class NoteCreatorStore extends ExternalStore<NoteCreatorDataSnapshot> {
4343
sendStarted: false,
4444
filePicker: "hidden",
4545
hashTags: [],
46-
reset: () => {
47-
this.#reset(this.#data)
48-
this.notifyChange(this.#data)
49-
},
50-
update: (fn: (v: NoteCreatorDataSnapshot) => void) => {
51-
fn(this.#data)
52-
this.notifyChange(this.#data)
53-
},
46+
reset: this.#resetFn,
47+
update: this.#updateFn,
5448
}
5549
}
5650

@@ -76,16 +70,21 @@ class NoteCreatorStore extends ExternalStore<NoteCreatorDataSnapshot> {
7670
d.attachments = undefined
7771
}
7872

73+
#resetFn = () => {
74+
this.#reset(this.#data)
75+
this.notifyChange(this.#data)
76+
}
77+
78+
#updateFn = (fn: (v: NoteCreatorDataSnapshot) => void) => {
79+
fn(this.#data)
80+
this.notifyChange(this.#data)
81+
}
82+
7983
takeSnapshot(): NoteCreatorDataSnapshot {
8084
const sn = {
8185
...this.#data,
82-
reset: () => {
83-
this.#reset(this.#data)
84-
},
85-
update: (fn: (v: NoteCreatorDataSnapshot) => void) => {
86-
fn(this.#data)
87-
this.notifyChange(this.#data)
88-
},
86+
reset: this.#resetFn,
87+
update: this.#updateFn,
8988
} as NoteCreatorDataSnapshot
9089
return sn
9190
}

0 commit comments

Comments
 (0)