fix: refactor disappearing messages control messages

pull/3206/head
Ryan Miller 8 months ago committed by Audric Ackermann
parent 796eb43583
commit cea2656c72

@ -147,9 +147,8 @@ function useTextToRenderI18nProps(props: PropsForExpirationTimer) {
const { pubkey, profileName, expirationMode, timespanText: time, type, disabled } = props; const { pubkey, profileName, expirationMode, timespanText: time, type, disabled } = props;
const isPrivate = useSelectedIsPrivate(); const isPrivate = useSelectedIsPrivate();
const isMe = useSelectedIsNoteToSelf(); const isNoteToSelf = useSelectedIsNoteToSelf();
// when in a 1o1 not NTS, we have a setting per side of the conversation const isPrivateAndNotNoteToSelf = isPrivate && !isNoteToSelf;
const ownSideOnly = isPrivate && !isMe;
const name = profileName ?? pubkey; const name = profileName ?? pubkey;
@ -169,27 +168,13 @@ function useTextToRenderI18nProps(props: PropsForExpirationTimer) {
? window.i18n('disappearingMessagesTypeRead') ? window.i18n('disappearingMessagesTypeRead')
: window.i18n('disappearingMessagesTypeSent'); : window.i18n('disappearingMessagesTypeSent');
switch (type) {
case 'fromOther':
if (disabled) { if (disabled) {
return { token: 'disappearingMessagesTurnedOff', args: { name } }; if (type === 'fromMe' || isPrivateAndNotNoteToSelf) {
}
return { return {
token: 'disappearingMessagesSet', token: 'disappearingMessagesTurnedOffYou',
args: {
name,
time,
disappearing_messages_type,
},
}; };
}
case 'fromMe': return {
case 'fromSync':
if (disabled) {
return ownSideOnly
? { token: 'disappearingMessagesTurnedOffYou' }
: {
token: 'disappearingMessagesTurnedOff', token: 'disappearingMessagesTurnedOff',
args: { args: {
name, name,
@ -204,11 +189,6 @@ function useTextToRenderI18nProps(props: PropsForExpirationTimer) {
disappearing_messages_type, disappearing_messages_type,
}, },
}; };
default:
assertUnreachable(type, `TimerNotification: Missing case error "${type}"`);
}
throw new Error('unhandled case');
} }
export const TimerNotification = (props: PropsForExpirationTimer) => { export const TimerNotification = (props: PropsForExpirationTimer) => {

Loading…
Cancel
Save