feat: outdated banner now shows specific messaging for synced messages

pull/2971/head
William Grant 2 years ago
parent 710da30594
commit ad21d198cf

@ -71,6 +71,7 @@ function createSessionInboxStore() {
conversationLookup: makeLookup(conversations, 'id'), conversationLookup: makeLookup(conversations, 'id'),
}, },
user: { user: {
ourDisplayNameInProfile: UserUtils.getOurProfile()?.displayName || '',
ourNumber: UserUtils.getOurPubKeyStrFromCache(), ourNumber: UserUtils.getOurPubKeyStrFromCache(),
}, },
section: initialSectionState, section: initialSectionState,

@ -69,6 +69,7 @@ export interface LightBoxOptions {
} }
interface Props { interface Props {
ourDisplayNameInProfile: string;
ourNumber: string; ourNumber: string;
selectedConversationKey: string; selectedConversationKey: string;
selectedConversation?: ReduxConversationType; selectedConversation?: ReduxConversationType;
@ -235,6 +236,7 @@ export class SessionConversation extends React.Component<Props, State> {
const { isDraggingFile } = this.state; const { isDraggingFile } = this.state;
const { const {
ourDisplayNameInProfile,
selectedConversation, selectedConversation,
messagesProps, messagesProps,
showMessageDetails, showMessageDetails,
@ -251,6 +253,12 @@ export class SessionConversation extends React.Component<Props, State> {
// TODOLATER break showMessageDetails & selectionMode into it's own container component so we can use hooks to fetch relevant state from the store // 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 selectionMode = selectedMessages.length > 0;
const bannerText =
selectedConversation.hasOutdatedClient &&
selectedConversation.hasOutdatedClient !== ourDisplayNameInProfile
? window.i18n('disappearingMessagesModeOutdated', [selectedConversation.hasOutdatedClient])
: window.i18n('someOfYourDeviceUseOutdatedVersion');
return ( return (
<SessionTheme> <SessionTheme>
<div className="conversation-header"> <div className="conversation-header">
@ -258,9 +266,7 @@ export class SessionConversation extends React.Component<Props, State> {
{selectedConversation?.hasOutdatedClient && {selectedConversation?.hasOutdatedClient &&
selectedConversation.hasOutdatedClient.length > 0 && ( selectedConversation.hasOutdatedClient.length > 0 && (
<NoticeBanner <NoticeBanner
text={window.i18n('disappearingMessagesModeOutdated', [ text={bannerText}
selectedConversation.hasOutdatedClient,
])}
dismissCallback={() => { dismissCallback={() => {
const conversation = getConversationController().get(selectedConversation.id); const conversation = getConversationController().get(selectedConversation.id);
conversation.set({ hasOutdatedClient: undefined }); conversation.set({ hasOutdatedClient: undefined });

@ -1,6 +1,7 @@
// State // State
export type UserStateType = { export type UserStateType = {
ourDisplayNameInProfile: string;
ourNumber: string; ourNumber: string;
}; };
@ -9,6 +10,7 @@ export type UserStateType = {
type UserChangedActionType = { type UserChangedActionType = {
type: 'USER_CHANGED'; type: 'USER_CHANGED';
payload: { payload: {
ourDisplayNameInProfile: string;
ourNumber: string; ourNumber: string;
ourPrimary: string; ourPrimary: string;
}; };
@ -22,7 +24,11 @@ export const actions = {
userChanged, userChanged,
}; };
function userChanged(attributes: { ourNumber: string; ourPrimary: string }): UserChangedActionType { function userChanged(attributes: {
ourDisplayNameInProfile: string;
ourNumber: string;
ourPrimary: string;
}): UserChangedActionType {
return { return {
type: 'USER_CHANGED', type: 'USER_CHANGED',
payload: attributes, payload: attributes,
@ -33,6 +39,7 @@ function userChanged(attributes: { ourNumber: string; ourPrimary: string }): Use
function getEmptyState(): UserStateType { function getEmptyState(): UserStateType {
return { return {
ourDisplayNameInProfile: '',
ourNumber: 'missing', ourNumber: 'missing',
}; };
} }

@ -12,4 +12,9 @@ export const getOurNumber = createSelector(
(state: UserStateType): string => state.ourNumber (state: UserStateType): string => state.ourNumber
); );
export const getOurDisplayNameInProfile = createSelector(
getUser,
(state: UserStateType): string => state.ourDisplayNameInProfile
);
export const getIntl = createSelector(getUser, (): LocalizerType => window.i18n); export const getIntl = createSelector(getUser, (): LocalizerType => window.i18n);

@ -15,7 +15,7 @@ import {
import { getSelectedConversationKey } from '../selectors/selectedConversation'; import { getSelectedConversationKey } from '../selectors/selectedConversation';
import { getStagedAttachmentsForCurrentConversation } from '../selectors/stagedAttachments'; import { getStagedAttachmentsForCurrentConversation } from '../selectors/stagedAttachments';
import { getTheme } from '../selectors/theme'; import { getTheme } from '../selectors/theme';
import { getOurNumber } from '../selectors/user'; import { getOurDisplayNameInProfile, getOurNumber } from '../selectors/user';
import { HTMLDirection } from '../../util/i18n'; import { HTMLDirection } from '../../util/i18n';
type SmartSessionConversationOwnProps = { type SmartSessionConversationOwnProps = {
@ -28,6 +28,7 @@ const mapStateToProps = (state: StateType, ownProps: SmartSessionConversationOwn
selectedConversationKey: getSelectedConversationKey(state), selectedConversationKey: getSelectedConversationKey(state),
theme: getTheme(state), theme: getTheme(state),
messagesProps: getSortedMessagesOfSelectedConversation(state), messagesProps: getSortedMessagesOfSelectedConversation(state),
ourDisplayNameInProfile: getOurDisplayNameInProfile(state),
ourNumber: getOurNumber(state), ourNumber: getOurNumber(state),
showMessageDetails: isMessageDetailView(state), showMessageDetails: isMessageDetailView(state),
isRightPanelShowing: isRightPanelShowing(state), isRightPanelShowing: isRightPanelShowing(state),

@ -207,6 +207,7 @@ async function registrationDone(ourPubkey: string, displayName: string) {
await conversation.commit(); await conversation.commit();
const user = { const user = {
ourDisplayNameInProfile: displayName,
ourNumber: getOurPubKeyStrFromCache(), ourNumber: getOurPubKeyStrFromCache(),
ourPrimary: ourPubkey, ourPrimary: ourPubkey,
}; };

Loading…
Cancel
Save