import React, { useState, useEffect } from 'react';
import './Settings.scss';
import initMatrix from '../../../client/initMatrix';
import cons from '../../../client/state/cons';
import settings from '../../../client/state/settings';
import navigation from '../../../client/state/navigation';
import {
toggleSystemTheme, toggleMarkdown, toggleMembershipEvents, toggleNickAvatarEvents,
toggleNotifications, toggleNotificationSounds,
} from '../../../client/action/settings';
import { usePermission } from '../../hooks/usePermission';
import Text from '../../atoms/text/Text';
import IconButton from '../../atoms/button/IconButton';
import Button from '../../atoms/button/Button';
import Toggle from '../../atoms/button/Toggle';
import Tabs from '../../atoms/tabs/Tabs';
import { MenuHeader } from '../../atoms/context-menu/ContextMenu';
import SegmentedControls from '../../atoms/segmented-controls/SegmentedControls';
import PopupWindow from '../../molecules/popup-window/PopupWindow';
import SettingTile from '../../molecules/setting-tile/SettingTile';
import ImportE2ERoomKeys from '../../molecules/import-export-e2e-room-keys/ImportE2ERoomKeys';
import ExportE2ERoomKeys from '../../molecules/import-export-e2e-room-keys/ExportE2ERoomKeys';
import { ImagePackUser, ImagePackGlobal } from '../../molecules/image-pack/ImagePack';
import GlobalNotification from '../../molecules/global-notification/GlobalNotification';
import KeywordNotification from '../../molecules/global-notification/KeywordNotification';
import IgnoreUserList from '../../molecules/global-notification/IgnoreUserList';
import ProfileEditor from '../profile-editor/ProfileEditor';
import CrossSigning from './CrossSigning';
import KeyBackup from './KeyBackup';
import DeviceManage from './DeviceManage';
import SunIC from '../../../../public/res/ic/outlined/sun.svg';
import EmojiIC from '../../../../public/res/ic/outlined/emoji.svg';
import LockIC from '../../../../public/res/ic/outlined/lock.svg';
import BellIC from '../../../../public/res/ic/outlined/bell.svg';
import InfoIC from '../../../../public/res/ic/outlined/info.svg';
import PowerIC from '../../../../public/res/ic/outlined/power.svg';
import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
import CinnySVG from '../../../../public/res/svg/cinny.svg';
import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog';
function AppearanceSection() {
const [, updateState] = useState({});
return (
Theme { toggleSystemTheme(); updateState({}); }}
/>
)}
content={Use light or dark mode based on the system settings.}
/>
{
if (settings.useSystemTheme) toggleSystemTheme();
settings.setTheme(index);
updateState({});
}}
/>
)}
/>
Room messages { toggleMarkdown(); updateState({}); }}
/>
)}
content={Format messages with markdown syntax before sending.}
/>
{ toggleMembershipEvents(); updateState({}); }}
/>
)}
content={Hide membership change messages from room timeline. (Join, Leave, Invite, Kick and Ban)}
/>
{ toggleNickAvatarEvents(); updateState({}); }}
/>
)}
content={Hide nick and avatar change messages from room timeline.}
/>
);
}
function NotificationsSection() {
const [permission, setPermission] = usePermission('notifications', window.Notification?.permission);
const [, updateState] = useState({});
const renderOptions = () => {
if (window.Notification === undefined) {
return Not supported in this browser.;
}
if (permission === 'granted') {
return (
{
toggleNotifications();
setPermission(window.Notification?.permission);
updateState({});
}}
/>
);
}
return (
);
};
return (
<>
Notification & SoundShow desktop notification when new messages arrive.}
/>
{ toggleNotificationSounds(); updateState({}); }}
/>
)}
content={Play sound when new messages arrive.}
/>
>
);
}
function EmojiSection() {
return (
<>
>
);
}
function SecuritySection() {
return (
Cross signing and backup
Export/Import encryption keysExport end-to-end encryption room keys to decrypt old messages in other session. In order to encrypt keys you need to set a password, which will be used while importing.
>
)}
/>
{'To decrypt older messages, Export E2EE room keys from Element (Settings > Security & Privacy > Encryption > Cryptography) and import them here. Imported keys are encrypted so you\'ll have to enter the password you set in order to decrypt it.'}
>
)}
/>
);
}
function AboutSection() {
return (
Application
Cinny
{`v${cons.version}`}Yet another matrix client