2023-01-03 11:55:46 -08:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-10-30 15:34:04 -05:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-08-26 09:10:58 -05:00
|
|
|
import * as durations from './durations';
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { LocalizerType } from '../types/Util';
|
2021-08-05 07:35:33 -05:00
|
|
|
import { getMutedUntilText } from './getMutedUntilText';
|
2022-05-23 18:37:53 +00:00
|
|
|
import { isConversationMuted } from './isConversationMuted';
|
2020-08-27 15:45:08 -04:00
|
|
|
|
2021-04-01 16:02:22 -05:00
|
|
|
export type MuteOption = {
|
2020-08-27 15:45:08 -04:00
|
|
|
name: string;
|
|
|
|
disabled?: boolean;
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
2021-08-05 07:35:33 -05:00
|
|
|
export function getMuteOptions(
|
2024-03-19 06:46:09 -07:00
|
|
|
muteExpiresAt: null | undefined | number,
|
2021-08-05 07:35:33 -05:00
|
|
|
i18n: LocalizerType
|
|
|
|
): Array<MuteOption> {
|
2020-08-27 15:45:08 -04:00
|
|
|
return [
|
2022-05-23 18:37:53 +00:00
|
|
|
...(muteExpiresAt && isConversationMuted({ muteExpiresAt })
|
2021-08-05 07:35:33 -05:00
|
|
|
? [
|
|
|
|
{
|
|
|
|
name: getMutedUntilText(muteExpiresAt, i18n),
|
|
|
|
disabled: true,
|
|
|
|
value: -1,
|
|
|
|
},
|
|
|
|
{
|
2023-03-29 17:03:25 -07:00
|
|
|
name: i18n('icu:unmute'),
|
2021-08-05 07:35:33 -05:00
|
|
|
value: 0,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: []),
|
2020-08-27 15:45:08 -04:00
|
|
|
{
|
2023-03-29 17:03:25 -07:00
|
|
|
name: i18n('icu:muteHour'),
|
2021-08-26 09:10:58 -05:00
|
|
|
value: durations.HOUR,
|
2020-08-27 15:45:08 -04:00
|
|
|
},
|
2021-04-09 09:19:38 -07:00
|
|
|
{
|
2023-03-29 17:03:25 -07:00
|
|
|
name: i18n('icu:muteEightHours'),
|
2021-08-26 09:10:58 -05:00
|
|
|
value: 8 * durations.HOUR,
|
2021-04-09 09:19:38 -07:00
|
|
|
},
|
2020-08-27 15:45:08 -04:00
|
|
|
{
|
2023-03-29 17:03:25 -07:00
|
|
|
name: i18n('icu:muteDay'),
|
2021-08-26 09:10:58 -05:00
|
|
|
value: durations.DAY,
|
2020-08-27 15:45:08 -04:00
|
|
|
},
|
|
|
|
{
|
2023-03-29 17:03:25 -07:00
|
|
|
name: i18n('icu:muteWeek'),
|
2021-08-26 09:10:58 -05:00
|
|
|
value: durations.WEEK,
|
2020-08-27 15:45:08 -04:00
|
|
|
},
|
|
|
|
{
|
2023-03-29 17:03:25 -07:00
|
|
|
name: i18n('icu:muteAlways'),
|
2021-04-09 09:19:38 -07:00
|
|
|
value: Number.MAX_SAFE_INTEGER,
|
2020-08-27 15:45:08 -04:00
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|