Skip to content

Commit

Permalink
Remove unnecessary throw when processing snapshot (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
texuf authored Aug 6, 2024
1 parent 369c352 commit 2be489a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/sdk/src/streamStateView_Space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,17 @@ export class StreamStateView_Space extends StreamStateView_AbstractContent {
}
break
case ChannelOp.CO_UPDATED: {
// first take settings from payload, then from local channel, then defaults
const channel = this.spaceChannelsMetadata.get(channelId)
if (!channel) {
throwWithCode(`Channel not found: ${channelId}`, Err.STREAM_BAD_EVENT)
}
const isDefault = isDefaultChannelId(channelId)
const isAutojoin = payload.settings?.autojoin ?? channel?.isAutojoin ?? isDefault
const hideUserJoinLeaveEvents =
payload.settings?.hideUserJoinLeaveEvents ?? channel?.isAutojoin ?? false
this.spaceChannelsMetadata.set(channelId, {
isDefault: isDefaultChannelId(channelId),
isDefault,
updatedAtEventNum,
isAutojoin: channel.isAutojoin,
hideUserJoinLeaveEvents: channel.hideUserJoinLeaveEvents,
isAutojoin,
hideUserJoinLeaveEvents,
})
stateEmitter?.emit(
'spaceChannelUpdated',
Expand Down

0 comments on commit 2be489a

Please sign in to comment.