frontend: prevent accessing stores of channels that have not been loaded yet
This commit is contained in:
parent
66bdd7e06f
commit
d3dff302c5
1 changed files with 14 additions and 3 deletions
|
@ -205,16 +205,27 @@ class MessagesStoreProvider {
|
||||||
// we currently don't care about our own messages
|
// we currently don't care about our own messages
|
||||||
if (gateway.user && message.author_id === gateway.user.id)
|
if (gateway.user && message.author_id === gateway.user.id)
|
||||||
return;
|
return;
|
||||||
this.getStore(message.channel_id).addMessage(message);
|
|
||||||
|
const store = this.getStoreOrNull(message.channel_id);
|
||||||
|
if (store)
|
||||||
|
store.addMessage(message);
|
||||||
});
|
});
|
||||||
gateway.subscribe(GatewayEventType.MessageUpdate, (message) => {
|
gateway.subscribe(GatewayEventType.MessageUpdate, (message) => {
|
||||||
this.getStore(message.channel_id).updateMessage(message);
|
const store = this.getStoreOrNull(message.channel_id);
|
||||||
|
if (store)
|
||||||
|
store.updateMessage(message);
|
||||||
});
|
});
|
||||||
gateway.subscribe(GatewayEventType.MessageDelete, (message) => {
|
gateway.subscribe(GatewayEventType.MessageDelete, (message) => {
|
||||||
this.getStore(message.channel_id).deleteMessage(message);
|
const store = this.getStoreOrNull(message.channel_id);
|
||||||
|
if (store)
|
||||||
|
store.deleteMessage(message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getStoreOrNull(channelId) {
|
||||||
|
return this.storeByChannel.get(channelId);
|
||||||
|
}
|
||||||
|
|
||||||
getStore(channelId) {
|
getStore(channelId) {
|
||||||
if (!this.storeByChannel.get(channelId)) {
|
if (!this.storeByChannel.get(channelId)) {
|
||||||
const store = new MessageStore(channelId);
|
const store = new MessageStore(channelId);
|
||||||
|
|
Loading…
Reference in a new issue