feat: use correct timer options and set the defaults

pull/2660/head
William Grant 2 years ago
parent 6de7c5c405
commit 80f18e9f1c

@ -18,7 +18,7 @@ import {
getSelectedConversationKey,
} from '../../../../state/selectors/conversations';
import {
DisappearingMessageConversationSetting,
DEFAULT_TIMER_OPTION,
DisappearingMessageConversationType,
} from '../../../../util/expiringMessages';
import { TimerOptionsArray } from '../../../../state/ducks/timerOptions';
@ -204,22 +204,22 @@ export const OverlayDisappearingMessages = (props: OverlayDisappearingMessagesPr
const { isGroup } = convoProps;
const [modeSelected, setModeSelected] = useState(convoProps.expirationType);
const [timeSelected, setTimeSelected] = useState(convoProps.expireTimer);
// Legacy mode uses the default timer options depending on the conversation type
// TODO verify that this if fine compared to updating in the useEffect
const timerOptions = useTimerOptionsByMode(
modeSelected === 'legacy'
? isGroup
? DisappearingMessageConversationSetting[2]
: DisappearingMessageConversationSetting[1]
: modeSelected
const [timeSelected, setTimeSelected] = useState(
convoProps.expireTimer && convoProps.expireTimer > -1
? convoProps.expireTimer
: isGroup
? DEFAULT_TIMER_OPTION.GROUP
: DEFAULT_TIMER_OPTION.PRIVATE_CONVERSATION
);
// TODO verify that this if fine compared to updating in the useEffect
const timerOptions = useTimerOptionsByMode(modeSelected);
useEffect(() => {
if (modeSelected !== convoProps.expirationType) {
setModeSelected(convoProps.expirationType);
}
if (timeSelected !== convoProps.expireTimer) {
if (convoProps.expireTimer && timeSelected !== convoProps.expireTimer) {
setTimeSelected(convoProps.expireTimer);
}
}, [convoProps.expirationType, convoProps.expireTimer]);

@ -190,11 +190,29 @@ export function useTimerOptionsByMode(disappearingMessageMode?: string) {
const options = state.timerOptions.timerOptions;
switch (disappearingMessageMode) {
// TODO legacy messages support will be removed in a future release
case 'legacy':
return options.filter(option => {
return (
option.value === 5 || // 5 seconds
option.value === 10 || // 10 seconds
option.value === 30 || // 30 seconds
option.value === 60 || // 1 minute
option.value === 300 || // 5 minutes
option.value === 1800 || // 30 minutes
option.value === 3600 || // 1 hour
option.value === 21600 || // 6 hours
option.value === 43200 || // 12 hours
option.value === 86400 || // 1 day
option.value === 604800 // 1 week
);
});
case 'deleteAfterSend':
return options.filter(option => {
return (
option.value === 10 || // 10 seconds (for testing)
option.value === 30 || // 30 seconds (for testing)
option.value === 10 || // 10 seconds (for development)
option.value === 30 || // 30 seconds (for development)
option.value === 60 || // 1 minute (for testing)
option.value === 43200 || // 12 hours
option.value === 86400 || // 1 day
option.value === 604800 || // 1 week
@ -204,8 +222,9 @@ export function useTimerOptionsByMode(disappearingMessageMode?: string) {
case 'deleteAfterRead':
return options.filter(option => {
return (
option.value === 10 || // 10 seconds (for testing)
option.value === 30 || // 30 seconds (for testing)
option.value === 10 || // 10 seconds (for development)
option.value === 30 || // 30 seconds (for development)
option.value === 60 || // 1 minute (for testing)
option.value === 300 || // 5 minutes
option.value === 3600 || // 1 hour
option.value === 43200 || // 12 hours

@ -15,6 +15,10 @@ export type DisappearingMessageType = typeof DisappearingMessageMode[number] | n
export const DisappearingMessageConversationSetting = ['off', ...DisappearingMessageMode, 'legacy'];
export type DisappearingMessageConversationType = typeof DisappearingMessageConversationSetting[number];
export const DEFAULT_TIMER_OPTION = {
PRIVATE_CONVERSATION: 86400, // 1 day
GROUP: 43200, // 12 hours
};
export type DisappearingMessageUpdate = {
expirationType: DisappearingMessageType;

@ -1,8 +1,7 @@
import { Data } from '../data/data';
// TODO update to agreed value between platforms
const featureReleaseTimestamp = 1677574800000; // unix 28/02/2023 09:00
// const featureReleaseTimestamp = 1676608378; // test value
const featureReleaseTimestamp = 1677488400; // unix 27/02/2023 09:00
let isFeatureReleased: boolean | undefined;
/**

Loading…
Cancel
Save