From 94e94deb912a88b220e6093adc2adc99257e0d0c Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Sat, 22 Jul 2023 18:01:22 +0300 Subject: [PATCH] improve store --- frontend/src/components/MessageInput.svelte | 2 +- frontend/src/stores.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/MessageInput.svelte b/frontend/src/components/MessageInput.svelte index fc97b05..00f2fc3 100644 --- a/frontend/src/components/MessageInput.svelte +++ b/frontend/src/components/MessageInput.svelte @@ -111,7 +111,7 @@ .message-input { width: 100%; - background-color : var(--background-color-3); + background-color: var(--background-color-3); border: none; color: currentColor; border-radius: var(--radius-md); diff --git a/frontend/src/stores.js b/frontend/src/stores.js index 9c609e6..389949d 100644 --- a/frontend/src/stores.js +++ b/frontend/src/stores.js @@ -73,13 +73,15 @@ class Store { storeLog(`[Flush] Flushing ${queueCount} callbacks from queue`, storeCallbackQueue); const start = performance.now(); + let count = 0; for (let i = 0; i < storeCallbackQueue.length; i++) { storeCallbackQueue[i][0](storeCallbackQueue[i][1]); + count++; } storeCallbackQueue.length = 0; const delta = performance.now() - start; - storeLog(`[Flush] Flushed ${queueCount} callbacks from queue, took ${delta}ms`); + storeLog(`[Flush] Flushed ${count} callbacks from queue, took ${delta}ms`); } startBatch() { @@ -100,6 +102,8 @@ class Store { this.value = this._applyPipes(this.value); + if (!this._handlers.size) return; + storeLog(`[Update] (${this.name}) Will queue ${this._handlers.size} handlers`, "value:", this.value, "handlers:", this._handlers); const isRootNode = storeCallbackQueue.length === 0; @@ -192,7 +196,6 @@ class UserInfoStore extends Store { }); gateway.subscribe(GatewayEventType.UserUpdate, (user) => { - console.log(user); if (this.value && this.value.id === user.id) { this.value = user; this.updated();