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

@ -190,11 +190,29 @@ export function useTimerOptionsByMode(disappearingMessageMode?: string) {
const options = state.timerOptions.timerOptions; const options = state.timerOptions.timerOptions;
switch (disappearingMessageMode) { 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': case 'deleteAfterSend':
return options.filter(option => { return options.filter(option => {
return ( return (
option.value === 10 || // 10 seconds (for testing) option.value === 10 || // 10 seconds (for development)
option.value === 30 || // 30 seconds (for testing) option.value === 30 || // 30 seconds (for development)
option.value === 60 || // 1 minute (for testing)
option.value === 43200 || // 12 hours option.value === 43200 || // 12 hours
option.value === 86400 || // 1 day option.value === 86400 || // 1 day
option.value === 604800 || // 1 week option.value === 604800 || // 1 week
@ -204,8 +222,9 @@ export function useTimerOptionsByMode(disappearingMessageMode?: string) {
case 'deleteAfterRead': case 'deleteAfterRead':
return options.filter(option => { return options.filter(option => {
return ( return (
option.value === 10 || // 10 seconds (for testing) option.value === 10 || // 10 seconds (for development)
option.value === 30 || // 30 seconds (for testing) option.value === 30 || // 30 seconds (for development)
option.value === 60 || // 1 minute (for testing)
option.value === 300 || // 5 minutes option.value === 300 || // 5 minutes
option.value === 3600 || // 1 hour option.value === 3600 || // 1 hour
option.value === 43200 || // 12 hours option.value === 43200 || // 12 hours

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

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

Loading…
Cancel
Save