Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go back to inbox on bad chat team loads #19251

Merged
merged 1 commit into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions shared/actions/chat2-gen.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 33 additions & 11 deletions shared/actions/chat2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1238,13 +1238,28 @@ function* loadMoreMessages(
)
} catch (e) {
logger.warn(e.message)
// no longer in team
if (e.code === RPCTypes.StatusCode.scchatnotinteam) {
yield* maybeKickedFromTeam(conversationIDKey)
return
}
if (e.code !== RPCTypes.StatusCode.scteamreaderror) {
// scteamreaderror = user is not in team. they'll see the rekey screen so don't throw for that
throw e
}
}
}

function* maybeKickedFromTeam(conversationIDKey: Types.ConversationIDKey) {
yield Saga.put(Chat2Gen.createInboxRefresh({reason: 'maybeKickedFromTeam'}))
yield Saga.put(
Chat2Gen.createNavigateToInbox({
avoidConversationID: conversationIDKey,
findNewConversation: true,
})
)
}

function* getUnreadline(
state: TypedState,
action: Chat2Gen.SelectConversationPayload,
Expand Down Expand Up @@ -1274,18 +1289,25 @@ function* getUnreadline(
}

const {readMsgID} = state.chat2.metaMap.get(conversationIDKey, Constants.makeConversationMeta())
const unreadlineRes = yield RPCChatTypes.localGetUnreadlineRpcPromise({
convID,
identifyBehavior: RPCTypes.TLFIdentifyBehavior.chatGui,
readMsgID: readMsgID < 0 ? 0 : readMsgID,
})
const unreadlineID = unreadlineRes.unreadlineID ? unreadlineRes.unreadlineID : 0
yield Saga.put(
Chat2Gen.createUpdateUnreadline({
conversationIDKey,
messageID: Types.numberToMessageID(unreadlineID),
try {
const unreadlineRes = yield RPCChatTypes.localGetUnreadlineRpcPromise({
convID,
identifyBehavior: RPCTypes.TLFIdentifyBehavior.chatGui,
readMsgID: readMsgID < 0 ? 0 : readMsgID,
})
)
const unreadlineID = unreadlineRes.unreadlineID ? unreadlineRes.unreadlineID : 0
yield Saga.put(
Chat2Gen.createUpdateUnreadline({
conversationIDKey,
messageID: Types.numberToMessageID(unreadlineID),
})
)
} catch (e) {
if (e.code === RPCTypes.StatusCode.scchatnotinteam) {
yield* maybeKickedFromTeam(conversationIDKey)
}
// ignore this error in general
}
}

// Show a desktop notification
Expand Down
3 changes: 2 additions & 1 deletion shared/actions/json/chat2.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
"'inboxSyncedUnknown'",
"'joinedAConversation'",
"'leftAConversation'",
"'teamTypeChanged'"
"'teamTypeChanged'",
"'maybeKickedFromTeam'"
]
},
// We want to unbox an inbox row
Expand Down