From 1bc3d2523cf848356d845aa3d34cfe75c8f2ad8d Mon Sep 17 00:00:00 2001 From: Jay Meistrich Date: Tue, 21 Nov 2023 12:45:44 +0000 Subject: [PATCH] fix activation observe re-running itself --- src/persist/persistActivateNode.ts | 5 ++++- src/persist/persistObservable.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/persist/persistActivateNode.ts b/src/persist/persistActivateNode.ts index 43e58101a..4b0a6bb92 100644 --- a/src/persist/persistActivateNode.ts +++ b/src/persist/persistActivateNode.ts @@ -164,7 +164,10 @@ export function persistActivateNode() { }, }) as unknown as Observable; - if (newValue === undefined) { + const nodeVal = getNodeValue(node); + if (nodeVal !== undefined) { + newValue = nodeVal; + } else if (newValue === undefined) { newValue = initial; } diff --git a/src/persist/persistObservable.ts b/src/persist/persistObservable.ts index 9dcc0a2e6..3541a2c8b 100644 --- a/src/persist/persistObservable.ts +++ b/src/persist/persistObservable.ts @@ -554,7 +554,7 @@ async function loadLocal( localState.persistenceLocal = persistenceLocal; - if (!initialized.get()) { + if (!initialized.peek()) { await when(initialized); }