Patch 37a1fd88: Sync selectedChannel only if the channel doesn't exist

## Issue
The previous commit was over-doing the manual syncing, causing other usages like the Repost Modal to always reset to a different channel.

## Fix
Only do the manual syncing when the channel does not exist.
At this point, we could also just take `channel[0]` as the new value.
This commit is contained in:
infiinte-persistence 2020-08-06 10:17:21 +08:00 committed by Sean Yesmunt
parent e64d925086
commit e5b1177644

View file

@ -47,13 +47,15 @@ class ChannelSelection extends React.PureComponent<Props, State> {
fetchChannelListMine();
}
const elem = document.getElementById(ID_FF_SELECT_CHANNEL);
// $FlowFixMe
if (elem && elem.value && elem.value !== channel) {
setTimeout(() => {
// $FlowFixMe
onChannelChange(elem.value);
}, 250);
if (channels && channels.length && !channels.find(chan => chan.name === channel)) {
const elem = document.getElementById(ID_FF_SELECT_CHANNEL);
// $FlowFixMe
if (elem && elem.value && elem.value !== channel) {
setTimeout(() => {
// $FlowFixMe
onChannelChange(elem.value);
}, 250);
}
}
}