SHA256
Добавить проверку звука в браузере
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
} from '../services/dm-chat-prefs.js';
|
||||
import { DEVICE_PREFS_EVENT, getDevicePref, setDevicePref } from '../services/device-prefs.js';
|
||||
import { showToast } from '../services/channels-ux.js';
|
||||
import { testDmSound } from '../services/dm-audio.js';
|
||||
|
||||
export const pageMeta = { id: 'notification-settings-view', get title() { return t('screens.notification_settings_view.text_001'); } };
|
||||
|
||||
@@ -47,6 +48,43 @@ export function render({ navigate, chrome } = {}) {
|
||||
soundSwitch.addEventListener('change', () => setDevicePref('dmSound', soundSwitch.checked));
|
||||
soundList.append(soundRow);
|
||||
|
||||
const soundTestRow = document.createElement('div');
|
||||
soundTestRow.className = 'nav-row nav-row--action';
|
||||
soundTestRow.innerHTML = `
|
||||
<span class="nav-row__text">
|
||||
<span class="nav-row__label"></span>
|
||||
<span class="nav-row__hint"></span>
|
||||
</span>
|
||||
`;
|
||||
soundTestRow.querySelector('.nav-row__label').textContent = t('screens.notification_settings_view.text_025');
|
||||
soundTestRow.querySelector('.nav-row__hint').textContent = t('screens.notification_settings_view.text_026');
|
||||
const soundTestButton = document.createElement('button');
|
||||
soundTestButton.type = 'button';
|
||||
soundTestButton.className = 'primary-btn nav-row__button';
|
||||
soundTestButton.textContent = t('screens.notification_settings_view.text_025');
|
||||
soundTestButton.addEventListener('click', async () => {
|
||||
soundTestButton.disabled = true;
|
||||
soundTestButton.textContent = t('screens.notification_settings_view.text_027');
|
||||
try {
|
||||
const result = await testDmSound();
|
||||
const message = {
|
||||
played: t('screens.notification_settings_view.text_028'),
|
||||
unsupported: t('screens.notification_settings_view.text_029'),
|
||||
blocked: t('screens.notification_settings_view.text_030'),
|
||||
disabled: t('screens.notification_settings_view.text_031'),
|
||||
error: t('screens.notification_settings_view.text_032'),
|
||||
}[result.code] || t('screens.notification_settings_view.text_032');
|
||||
showToast(message, { kind: result.ok ? 'success' : 'error' });
|
||||
} finally {
|
||||
if (!disposed) {
|
||||
soundTestButton.disabled = false;
|
||||
soundTestButton.textContent = t('screens.notification_settings_view.text_025');
|
||||
}
|
||||
}
|
||||
});
|
||||
soundTestRow.append(soundTestButton);
|
||||
soundList.append(soundTestRow);
|
||||
|
||||
// Системные уведомления – когда приложение свёрнуто или закрыто.
|
||||
const systemList = document.createElement('div');
|
||||
systemList.className = 'nav-list';
|
||||
|
||||
Reference in New Issue
Block a user