Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
select new conv if we delete a channel (#20202)
  • Loading branch information
mmaxim committed Oct 8, 2019
1 parent 455fb04 commit fcd65b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 9 additions & 0 deletions go/chat/storage/inbox.go
Expand Up @@ -1850,6 +1850,12 @@ func (i *Inbox) ConversationsUpdate(ctx context.Context, uid gregor1.UID, vers c
locks.Inbox.Lock()
defer locks.Inbox.Unlock()
defer i.maybeNukeFn(func() Error { return err }, i.dbKey(uid))
layoutChanged := false
defer func() {
if layoutChanged {
i.layoutNotifier.UpdateLayout(ctx, "existence")
}
}()

i.Debug(ctx, "ConversationsUpdate: updating %d convs", len(convUpdates))
ibox, err := i.readDiskInbox(ctx, uid, true)
Expand All @@ -1874,6 +1880,9 @@ func (i *Inbox) ConversationsUpdate(ctx context.Context, uid gregor1.UID, vers c
for idx, conv := range ibox.Conversations {
if update, ok := updateMap[conv.GetConvID().String()]; ok {
i.Debug(ctx, "ConversationsUpdate: changed conv: %v", update)
if ibox.Conversations[idx].Conv.Metadata.Existence != update.Existence {
layoutChanged = true
}
ibox.Conversations[idx].Conv.Metadata.Existence = update.Existence
}
}
Expand Down
10 changes: 7 additions & 3 deletions shared/actions/chat2/index.tsx
Expand Up @@ -1886,7 +1886,8 @@ const changeSelectedConversation = (
| Chat2Gen.AttachmentsUploadPayload
| Chat2Gen.BlockConversationPayload
| Chat2Gen.HideConversationPayload
| TeamsGen.LeaveTeamPayload,
| TeamsGen.LeaveTeamPayload
| TeamsGen.DeleteChannelConfirmedPayload,
logger: Saga.SagaLogger
) => {
if (!isMobile) {
Expand All @@ -1905,7 +1906,8 @@ const _maybeAutoselectNewestConversation = (
| Chat2Gen.AttachmentsUploadPayload
| Chat2Gen.BlockConversationPayload
| Chat2Gen.HideConversationPayload
| TeamsGen.LeaveTeamPayload,
| TeamsGen.LeaveTeamPayload
| TeamsGen.DeleteChannelConfirmedPayload,
logger: Saga.SagaLogger
) => {
// If there is a team we should avoid when selecting a new conversation (e.g.
Expand Down Expand Up @@ -1944,7 +1946,8 @@ const _maybeAutoselectNewestConversation = (
} else if (
(action.type === Chat2Gen.leaveConversation ||
action.type === Chat2Gen.blockConversation ||
action.type === Chat2Gen.hideConversation) &&
action.type === Chat2Gen.hideConversation ||
action.type === TeamsGen.deleteChannelConfirmed) &&
action.payload.conversationIDKey === selected
) {
// Intentional fall-through -- force select a new one
Expand Down Expand Up @@ -3346,6 +3349,7 @@ function* chat2Saga() {
Chat2Gen.blockConversation,
Chat2Gen.hideConversation,
TeamsGen.leaveTeam,
TeamsGen.deleteChannelConfirmed,
],
changeSelectedConversation,
'changeSelectedConversation'
Expand Down

0 comments on commit fcd65b3

Please sign in to comment.