fix: do not construct expireTimer string by hand

pull/3206/head
Audric Ackermann 7 months ago
parent dfe41e4beb
commit 9119fef90a
No known key found for this signature in database

@ -57,7 +57,7 @@ function useFollowSettingsButtonClick(
},
};
const okText = props.disabled ? window.i18n('yes') : window.i18n('set');
const okText = window.i18n('confirm');
dispatch(
updateConfirmModal({

@ -206,7 +206,6 @@ export const OverlayRightPanelSettings = () => {
const weAreAdmin = useSelectedWeAreAdmin();
const disappearingMessagesSubtitle = useDisappearingMessageSettingText({
convoId: selectedConvoKey,
separator: ': ',
});
const lastMessage = useSelectedLastMessage();

@ -398,32 +398,16 @@ export function useSortedGroupMembers(convoId: string | undefined): Array<string
export function useDisappearingMessageSettingText({
convoId,
abbreviate,
separator = ' - ',
}: {
convoId?: string;
abbreviate?: boolean;
separator?: string;
}): string {
const convoProps = useConversationPropsById(convoId);
if (!convoProps) {
return '';
}
const { expirationMode, expireTimer, isMe, isPublic } = convoProps;
const isGroup = !convoProps.isPrivate && !convoProps.isPublic;
// TODO legacy messages support will be removed in a future release
const expirationModeText =
expirationMode === 'deleteAfterRead'
? window.i18n('disappearingMessagesDisappearAfterRead')
: expirationMode === 'deleteAfterSend'
? window.i18n('disappearingMessagesDisappearAfterSend')
: expirationMode === 'legacy'
? isMe || (isGroup && !isPublic)
? window.i18n('disappearingMessagesDisappearAfterSend')
: window.i18n('disappearingMessagesDisappearAfterRead')
: null;
const { expirationMode, expireTimer } = convoProps;
const expireTimerText = isNumber(expireTimer)
? abbreviate
@ -431,9 +415,19 @@ export function useDisappearingMessageSettingText({
: TimerOptions.getName(expireTimer)
: null;
return expireTimer && expirationModeText
? `${expirationModeText}${expireTimerText ? `${separator}${expireTimerText}` : ''}`
: '';
if (!expireTimerText) {
return '';
}
if (expirationMode === 'legacy') {
throw new Error('legacy support is removed');
}
return expirationMode === 'deleteAfterRead'
? window.i18n('disappearingMessagesDisappearAfterReadState', { time: expireTimerText })
: expirationMode === 'deleteAfterSend'
? window.i18n('disappearingMessagesDisappearAfterSendState', { time: expireTimerText })
: '';
}
export function useLastMessage(convoId?: string) {

Loading…
Cancel
Save