SHA256
Локализовать интерфейс SHiNE на русский и английский
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
// Пункт меню чата «Без звука» со сроком – общий для шапки чата и меню строки в списке чатов.
|
||||
// Срок выбирается во вложенном списке того же меню; включённый звук возвращается одним нажатием.
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
@@ -5,37 +6,37 @@ import { formatDmMuteUntil, getDmChatMutedUntil, setDmChatMuted } from '../servi
|
||||
import { showToast } from '../services/channels-ux.js';
|
||||
|
||||
const HOUR = 60 * 60 * 1000;
|
||||
const DURATIONS = [
|
||||
['На 1 час', HOUR],
|
||||
['На 8 часов', 8 * HOUR],
|
||||
['На сутки', 24 * HOUR],
|
||||
['На неделю', 7 * 24 * HOUR],
|
||||
['Навсегда', 0],
|
||||
const DURATIONS = () => [
|
||||
[t('screens.dm_mute_menu.text_007'), HOUR],
|
||||
[t('screens.dm_mute_menu.text_008'), 8 * HOUR],
|
||||
[t('screens.dm_mute_menu.text_009'), 24 * HOUR],
|
||||
[t('screens.dm_mute_menu.text_010'), 7 * 24 * HOUR],
|
||||
[t('screens.dm_mute_menu.text_011'), 0],
|
||||
];
|
||||
|
||||
export function createDmMuteMenuItem(chatId, { iconClass = '', onChange = null } = {}) {
|
||||
const until = getDmChatMutedUntil(chatId);
|
||||
if (until !== null) {
|
||||
return {
|
||||
label: 'Включить звук',
|
||||
hint: until ? `Без звука ${formatDmMuteUntil(until)}` : '',
|
||||
label: t('screens.dm_mute_menu.text_001'),
|
||||
hint: until ? t('screens.dm_mute_menu.text_005', { value1: formatDmMuteUntil(until) }) : '',
|
||||
iconHtml: iconHtml('bell', false, iconClass),
|
||||
action: () => {
|
||||
setDmChatMuted(chatId, false);
|
||||
showToast('Уведомления включены', { timeoutMs: 1400 });
|
||||
showToast(t('screens.dm_mute_menu.text_003'), { timeoutMs: 1400 });
|
||||
onChange?.(false);
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
label: 'Без звука',
|
||||
label: t('screens.dm_mute_menu.text_002'),
|
||||
iconHtml: iconHtml('bell-off', false, iconClass),
|
||||
submenu: DURATIONS.map(([label, ms]) => ({
|
||||
submenu: DURATIONS().map(([label, ms]) => ({
|
||||
label,
|
||||
action: () => {
|
||||
const untilMs = ms ? Date.now() + ms : 0;
|
||||
setDmChatMuted(chatId, true, { untilMs });
|
||||
showToast(untilMs ? `Уведомления выключены ${formatDmMuteUntil(untilMs)}` : 'Уведомления от этого чата выключены', { timeoutMs: 1800 });
|
||||
showToast(untilMs ? t('screens.dm_mute_menu.text_006', { value1: formatDmMuteUntil(untilMs) }) : t('screens.dm_mute_menu.text_004'), { timeoutMs: 1800 });
|
||||
onChange?.(true);
|
||||
},
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user