improve store

This commit is contained in:
hippoz 2023-07-22 18:01:22 +03:00
parent 1e5efdf7e8
commit 94e94deb91
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED
2 changed files with 6 additions and 3 deletions

View file

@ -111,7 +111,7 @@
.message-input { .message-input {
width: 100%; width: 100%;
background-color : var(--background-color-3); background-color: var(--background-color-3);
border: none; border: none;
color: currentColor; color: currentColor;
border-radius: var(--radius-md); border-radius: var(--radius-md);

View file

@ -73,13 +73,15 @@ class Store {
storeLog(`[Flush] Flushing ${queueCount} callbacks from queue`, storeCallbackQueue); storeLog(`[Flush] Flushing ${queueCount} callbacks from queue`, storeCallbackQueue);
const start = performance.now(); const start = performance.now();
let count = 0;
for (let i = 0; i < storeCallbackQueue.length; i++) { for (let i = 0; i < storeCallbackQueue.length; i++) {
storeCallbackQueue[i][0](storeCallbackQueue[i][1]); storeCallbackQueue[i][0](storeCallbackQueue[i][1]);
count++;
} }
storeCallbackQueue.length = 0; storeCallbackQueue.length = 0;
const delta = performance.now() - start; 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() { startBatch() {
@ -100,6 +102,8 @@ class Store {
this.value = this._applyPipes(this.value); 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); storeLog(`[Update] (${this.name}) Will queue ${this._handlers.size} handlers`, "value:", this.value, "handlers:", this._handlers);
const isRootNode = storeCallbackQueue.length === 0; const isRootNode = storeCallbackQueue.length === 0;
@ -192,7 +196,6 @@ class UserInfoStore extends Store {
}); });
gateway.subscribe(GatewayEventType.UserUpdate, (user) => { gateway.subscribe(GatewayEventType.UserUpdate, (user) => {
console.log(user);
if (this.value && this.value.id === user.id) { if (this.value && this.value.id === user.id) {
this.value = user; this.value = user;
this.updated(); this.updated();