From ad21d198cf1a0e60094df0343cc1ae820d067097 Mon Sep 17 00:00:00 2001 From: William Grant Date: Fri, 15 Sep 2023 15:04:55 +1000 Subject: [PATCH] feat: outdated banner now shows specific messaging for synced messages --- ts/components/SessionInboxView.tsx | 1 + ts/components/conversation/SessionConversation.tsx | 12 +++++++++--- ts/state/ducks/user.ts | 9 ++++++++- ts/state/selectors/user.ts | 5 +++++ ts/state/smart/SessionConversation.ts | 3 ++- ts/util/accountManager.ts | 1 + 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ts/components/SessionInboxView.tsx b/ts/components/SessionInboxView.tsx index fe3ced550..6d26b5df4 100644 --- a/ts/components/SessionInboxView.tsx +++ b/ts/components/SessionInboxView.tsx @@ -71,6 +71,7 @@ function createSessionInboxStore() { conversationLookup: makeLookup(conversations, 'id'), }, user: { + ourDisplayNameInProfile: UserUtils.getOurProfile()?.displayName || '', ourNumber: UserUtils.getOurPubKeyStrFromCache(), }, section: initialSectionState, diff --git a/ts/components/conversation/SessionConversation.tsx b/ts/components/conversation/SessionConversation.tsx index 05c9b6a09..4aeb0d262 100644 --- a/ts/components/conversation/SessionConversation.tsx +++ b/ts/components/conversation/SessionConversation.tsx @@ -69,6 +69,7 @@ export interface LightBoxOptions { } interface Props { + ourDisplayNameInProfile: string; ourNumber: string; selectedConversationKey: string; selectedConversation?: ReduxConversationType; @@ -235,6 +236,7 @@ export class SessionConversation extends React.Component { const { isDraggingFile } = this.state; const { + ourDisplayNameInProfile, selectedConversation, messagesProps, showMessageDetails, @@ -251,6 +253,12 @@ export class SessionConversation extends React.Component { // TODOLATER break showMessageDetails & selectionMode into it's own container component so we can use hooks to fetch relevant state from the store const selectionMode = selectedMessages.length > 0; + const bannerText = + selectedConversation.hasOutdatedClient && + selectedConversation.hasOutdatedClient !== ourDisplayNameInProfile + ? window.i18n('disappearingMessagesModeOutdated', [selectedConversation.hasOutdatedClient]) + : window.i18n('someOfYourDeviceUseOutdatedVersion'); + return (
@@ -258,9 +266,7 @@ export class SessionConversation extends React.Component { {selectedConversation?.hasOutdatedClient && selectedConversation.hasOutdatedClient.length > 0 && ( { const conversation = getConversationController().get(selectedConversation.id); conversation.set({ hasOutdatedClient: undefined }); diff --git a/ts/state/ducks/user.ts b/ts/state/ducks/user.ts index 7b6289e9d..86ebf3745 100644 --- a/ts/state/ducks/user.ts +++ b/ts/state/ducks/user.ts @@ -1,6 +1,7 @@ // State export type UserStateType = { + ourDisplayNameInProfile: string; ourNumber: string; }; @@ -9,6 +10,7 @@ export type UserStateType = { type UserChangedActionType = { type: 'USER_CHANGED'; payload: { + ourDisplayNameInProfile: string; ourNumber: string; ourPrimary: string; }; @@ -22,7 +24,11 @@ export const actions = { userChanged, }; -function userChanged(attributes: { ourNumber: string; ourPrimary: string }): UserChangedActionType { +function userChanged(attributes: { + ourDisplayNameInProfile: string; + ourNumber: string; + ourPrimary: string; +}): UserChangedActionType { return { type: 'USER_CHANGED', payload: attributes, @@ -33,6 +39,7 @@ function userChanged(attributes: { ourNumber: string; ourPrimary: string }): Use function getEmptyState(): UserStateType { return { + ourDisplayNameInProfile: '', ourNumber: 'missing', }; } diff --git a/ts/state/selectors/user.ts b/ts/state/selectors/user.ts index 69535cfda..adbc4b958 100644 --- a/ts/state/selectors/user.ts +++ b/ts/state/selectors/user.ts @@ -12,4 +12,9 @@ export const getOurNumber = createSelector( (state: UserStateType): string => state.ourNumber ); +export const getOurDisplayNameInProfile = createSelector( + getUser, + (state: UserStateType): string => state.ourDisplayNameInProfile +); + export const getIntl = createSelector(getUser, (): LocalizerType => window.i18n); diff --git a/ts/state/smart/SessionConversation.ts b/ts/state/smart/SessionConversation.ts index a2fcac167..608ed6341 100644 --- a/ts/state/smart/SessionConversation.ts +++ b/ts/state/smart/SessionConversation.ts @@ -15,7 +15,7 @@ import { import { getSelectedConversationKey } from '../selectors/selectedConversation'; import { getStagedAttachmentsForCurrentConversation } from '../selectors/stagedAttachments'; import { getTheme } from '../selectors/theme'; -import { getOurNumber } from '../selectors/user'; +import { getOurDisplayNameInProfile, getOurNumber } from '../selectors/user'; import { HTMLDirection } from '../../util/i18n'; type SmartSessionConversationOwnProps = { @@ -28,6 +28,7 @@ const mapStateToProps = (state: StateType, ownProps: SmartSessionConversationOwn selectedConversationKey: getSelectedConversationKey(state), theme: getTheme(state), messagesProps: getSortedMessagesOfSelectedConversation(state), + ourDisplayNameInProfile: getOurDisplayNameInProfile(state), ourNumber: getOurNumber(state), showMessageDetails: isMessageDetailView(state), isRightPanelShowing: isRightPanelShowing(state), diff --git a/ts/util/accountManager.ts b/ts/util/accountManager.ts index b95a6bb92..dcdb12e1a 100644 --- a/ts/util/accountManager.ts +++ b/ts/util/accountManager.ts @@ -207,6 +207,7 @@ async function registrationDone(ourPubkey: string, displayName: string) { await conversation.commit(); const user = { + ourDisplayNameInProfile: displayName, ourNumber: getOurPubKeyStrFromCache(), ourPrimary: ourPubkey, };