From ce4592c6c0198ca11a43a599d3966fcdf4e028cb Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Tue, 19 Apr 2022 02:19:24 +0300 Subject: [PATCH] frontend: fix array index checks in channels store --- frontend/src/stores.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/frontend/src/stores.js b/frontend/src/stores.js index a9c9590..2f97edb 100644 --- a/frontend/src/stores.js +++ b/frontend/src/stores.js @@ -30,33 +30,28 @@ class ChannelsStore extends Store { gateway.subscribe(GatewayEventType.Ready, ({ channels }) => { this.value = channels; - this.updated(); }); gateway.subscribe(GatewayEventType.ChannelCreate, (channel) => { this.value.push(channel); - this.updated(); }); gateway.subscribe(GatewayEventType.ChannelDelete, ({ id }) => { const index = this.value.findIndex(e => e.id === id); - if (!index) + if (index === -1) return; this.value.splice(index, 1); - this.updated(); }); gateway.subscribe(GatewayEventType.ChannelUpdate, (data) => { const index = this.value.findIndex(e => e.id === data.id); - if (!index) + if (index === -1) return; - if (!this.value[index]) return; this.value[index] = data; - this.updated(); }); }