frontend: fix array index checks in channels store
This commit is contained in:
parent
abdaa80d1a
commit
ce4592c6c0
1 changed files with 2 additions and 7 deletions
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue