fix community channel selection

This commit is contained in:
hippoz 2023-06-26 13:44:55 +03:00
parent f79f51527b
commit 54030dcba9
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED

View file

@ -698,10 +698,10 @@ class SelectedChannelStore extends Store {
this.communityIdToSelectedChannel = new Map();
selectedCommunity.subscribe((community) => {
let channel = this.communityIdToSelectedChannel.get(community.id);
if (!channel && filteredChannelsStore.value.length) {
channel = filteredChannelsStore.value[0];
filteredChannelsStore.subscribe((channels) => {
let channel = this.communityIdToSelectedChannel.get(selectedCommunity.value.id);
if (!channel && channels.length) {
channel = channels[0];
}
this.value = channel || noneChannel;
this.updated();
@ -716,9 +716,7 @@ class SelectedChannelStore extends Store {
this.communityIdToSelectedChannel.set(parseInt(communityId), channel);
}
}
this.value = this.communityIdToSelectedChannel.get(selectedCommunity.value.id) || noneChannel;
this.updateSavedMap();
this.updated();
});
gateway.subscribe(GatewayEventType.CommunityDelete, ({ id }) => {
if (this.communityIdToSelectedChannel.delete(id) && this.value && this.value.id === id) {