From c4d8ea515a20b3af106984c31e2e4f74c470a5aa Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 12 Jul 2025 15:45:35 +0800 Subject: [PATCH 1/2] docs(store): reload merges the value --- plugins/store/guest-js/index.ts | 7 ++++++- plugins/store/src/store.rs | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/store/guest-js/index.ts b/plugins/store/guest-js/index.ts index 1df89fd529..4cf1c9b2b0 100644 --- a/plugins/store/guest-js/index.ts +++ b/plugins/store/guest-js/index.ts @@ -396,7 +396,12 @@ interface IStore { * * This method is useful if the on-disk state was edited by the user and you want to synchronize the changes. * - * Note: This method does not emit change events. + * Note: + * - This method loads the data and merges it with the current store, + * this behavior will be changed to overriding from on-disk state in v3, + * for now, call {@linkcode clear} first for the store to fully match the on-disk state + * - This method does not emit change events. + * * @returns */ reload(): Promise diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index 1dc5e1d21d..421dd00ee3 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -284,6 +284,8 @@ impl StoreInner { } /// Update the store from the on-disk state + /// + /// Note: This method loads the data and merges it with the current store pub fn load(&mut self) -> crate::Result<()> { let bytes = fs::read(&self.path)?; @@ -499,6 +501,12 @@ impl Store { } /// Update the store from the on-disk state + /// + /// Note: + /// - This method loads the data and merges it with the current store, + /// this behavior will be changed to overriding from on-disk state in v3, + /// for now, call [`clear`](Self::clear) first for the store to fully match the on-disk state + /// - This method does not emit change events pub fn reload(&self) -> crate::Result<()> { self.store.lock().unwrap().load() } From aec3b71d95f4c4b4fd07cc3b90c374cf37fa98ef Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 18 Jul 2025 17:22:56 +0800 Subject: [PATCH 2/2] Tweak docs --- plugins/store/guest-js/index.ts | 4 ++-- plugins/store/src/store.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/store/guest-js/index.ts b/plugins/store/guest-js/index.ts index 4cf1c9b2b0..2ea062c5cd 100644 --- a/plugins/store/guest-js/index.ts +++ b/plugins/store/guest-js/index.ts @@ -398,8 +398,8 @@ interface IStore { * * Note: * - This method loads the data and merges it with the current store, - * this behavior will be changed to overriding from on-disk state in v3, - * for now, call {@linkcode clear} first for the store to fully match the on-disk state + * call {@linkcode clear} or {@linkcode reset} first for the store to fully match the on-disk state + * (be careful with the auto save settings as they both trigger that) * - This method does not emit change events. * * @returns diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index 421dd00ee3..201d30ccfe 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -504,8 +504,8 @@ impl Store { /// /// Note: /// - This method loads the data and merges it with the current store, - /// this behavior will be changed to overriding from on-disk state in v3, - /// for now, call [`clear`](Self::clear) first for the store to fully match the on-disk state + /// call [`clear`](Self::clear) or [`reset`](Self::reset) first for the store to fully match the on-disk state + /// (be careful with the auto save settings as they both trigger that) /// - This method does not emit change events pub fn reload(&self) -> crate::Result<()> { self.store.lock().unwrap().load()