diff --git a/special-pages/pages/new-tab/app/activity/ActivityProvider.js b/special-pages/pages/new-tab/app/activity/ActivityProvider.js index 81925a932..85acf0aa0 100644 --- a/special-pages/pages/new-tab/app/activity/ActivityProvider.js +++ b/special-pages/pages/new-tab/app/activity/ActivityProvider.js @@ -237,8 +237,8 @@ export function SignalStateProvider({ children }) { useSignalEffect(() => { if (!service) return console.warn('could not access service'); const unsub = service.onData((evt) => { - const next = normalize(keys.value, evt.data); batch(() => { + const next = normalize(keys.value, evt.data); keys.value = next; activity.value = normalizeItems(activity.value, evt.data); }); diff --git a/special-pages/pages/new-tab/app/activity/activity.service.js b/special-pages/pages/new-tab/app/activity/activity.service.js index 4413ae1ba..746f5c16f 100644 --- a/special-pages/pages/new-tab/app/activity/activity.service.js +++ b/special-pages/pages/new-tab/app/activity/activity.service.js @@ -116,12 +116,14 @@ export class ActivityService { * @return {Promise} */ confirmBurn(url) { + this.dataService.disableBroadcast(); return this.ntp.messaging.request('activity_confirmBurn', { url }); } /** * @param {string} url */ burnAnimationComplete(url) { + this.dataService.enableBroadcast(); this.dataService.update((old) => { return { ...old, diff --git a/special-pages/pages/new-tab/app/service.js b/special-pages/pages/new-tab/app/service.js index 68ac43a1e..6e0b9eb45 100644 --- a/special-pages/pages/new-tab/app/service.js +++ b/special-pages/pages/new-tab/app/service.js @@ -13,6 +13,7 @@ export class Service { eventTarget = new EventTarget(); DEBOUNCE_TIME_MS = 200; + _broadcast = true; /** * @param {object} props * @param {() => Promise} [props.initial] @@ -110,9 +111,20 @@ export class Service { } } + disableBroadcast() { + this._broadcast = false; + } + + /** + * + */ + enableBroadcast() { + this._broadcast = true; + } + /** * @param {Data} data - * @param {'initial' | 'subscription' | 'manual' | 'trigger-fetch'} source + * @param {'initial' | 'subscription' | 'manual' | 'trigger-fetch' | 'flush'} source * @private */ _accept(data, source) { @@ -124,6 +136,8 @@ export class Service { // always cancel any existing debounced timers this.clearDebounceTimer(); + if (!this._broadcast) return; + // always broadcast the change on the event target const dataEvent = new CustomEvent('data', { detail: { @@ -131,6 +145,7 @@ export class Service { source, }, }); + this.eventTarget.dispatchEvent(dataEvent); // try to persist if the last try was 'manual' update