Skip to content

Commit

Permalink
fix: skip incorrect channels
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashshah committed Oct 18, 2023
1 parent f41bcb5 commit a0cbffe
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/components/channel/UserSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,29 @@ function UserSettings() {
const dispatch = useDispatch();

const fetchChannelDetails = async (channel: string) => {
const details = await getChannel({ channel });
if (details) {
const updatedChannelItem: ChannelListItem = {
channel,
id: details.id,
icon: details.icon,
name: details.name,
channel_settings: details.channel_settings,
};
return updatedChannelItem;
} else return undefined;
try {
const details = await getChannel({ channel });
if (details) {
const updatedChannelItem: ChannelListItem = {
channel,
id: details.id,
icon: details.icon,
name: details.name,
channel_settings: details.channel_settings,
};
return updatedChannelItem;
} else return undefined;
} catch {
return undefined;
}
};

const fillData = async (details: any) => {
const data = await Promise.all(
const data = [];
await Promise.all(
Object.keys(details).map(async (channel) => {
const channelData = await fetchChannelDetails(channel);
if (channelData) return channelData;
if (channelData) data.push(channelData);
})
);
setChannelList(data);
Expand Down

0 comments on commit a0cbffe

Please sign in to comment.