This commit is contained in:
wuyudi 2023-02-08 00:20:45 +09:00
parent 4b7f07ef6d
commit 2005434aed
5 changed files with 38 additions and 6 deletions

17
package-lock.json generated
View file

@ -43,6 +43,7 @@
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
"@rollup/plugin-inject": "5.0.3",
"@rollup/plugin-wasm": "6.1.1",
"@types/flux": "3.1.11",
"@types/node": "18.11.18",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
@ -1119,6 +1120,22 @@
"resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz",
"integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g=="
},
"node_modules/@types/fbemitter": {
"version": "2.0.32",
"resolved": "https://registry.npmjs.org/@types/fbemitter/-/fbemitter-2.0.32.tgz",
"integrity": "sha512-Hwq28bBlbmfCgLnNJvjl5ssTrbZCTSblI4vqPpqZrbbEL8vn5l2UivxhlMYfUY7a4SR8UB6RKoLjOZfljqAa6g==",
"dev": true
},
"node_modules/@types/flux": {
"version": "3.1.11",
"resolved": "https://registry.npmjs.org/@types/flux/-/flux-3.1.11.tgz",
"integrity": "sha512-Aq4UB1ZqAKcPbhB0GpgMw2sntvOh71he9tjz53TLKrI7rw3Y3LxCW5pTYY9IV455hQapm4pmxFjpqlWOs308Yg==",
"dev": true,
"dependencies": {
"@types/fbemitter": "*",
"@types/react": "*"
}
},
"node_modules/@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",

View file

@ -53,6 +53,7 @@
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
"@rollup/plugin-inject": "5.0.3",
"@rollup/plugin-wasm": "6.1.1",
"@types/flux": "3.1.11",
"@types/node": "18.11.18",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",

View file

@ -1,6 +1,6 @@
const secretStorageKeys = new Map();
export function storePrivateKey(keyId, privateKey) {
export function storePrivateKey(keyId, privateKey: Uint8Array) {
if (privateKey instanceof Uint8Array === false) {
throw new Error('Unable to store, privateKey is invalid.');
}
@ -16,6 +16,7 @@ export function getPrivateKey(keyId) {
}
export function deletePrivateKey(keyId) {
//@ts-ignore
delete secretStorageKeys.delete(keyId);
}

View file

@ -3,20 +3,30 @@ import appDispatcher from '../dispatcher';
import cons from './cons';
function getSettings() {
function getSettings(): Settings {
const settings = localStorage.getItem('settings');
if (settings === null) return null;
return JSON.parse(settings);
}
function setSettings(key, value) {
function setSettings(key: string, value) {
let settings = getSettings();
if (settings === null) settings = {};
if (settings === null) settings = new Settings();
settings[key] = value;
localStorage.setItem('settings', JSON.stringify(settings));
}
class Settings extends EventEmitter {
themes: string[];
themeIndex: number;
useSystemTheme: boolean;
isMarkdown: boolean;
isPeopleDrawer: boolean;
hideMembershipEvents: boolean;
hideNickAvatarEvents: boolean;
_showNotifications: boolean;
isNotificationSounds: boolean;
isTouchScreenDevice: boolean;
constructor() {
super();
@ -31,7 +41,10 @@ class Settings extends EventEmitter {
this._showNotifications = this.getShowNotifications();
this.isNotificationSounds = this.getIsNotificationSounds();
this.isTouchScreenDevice = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0);
this.isTouchScreenDevice =
// https://github.com/microsoft/vscode/issues/127822#issuecomment-874324028
// msMaxTouchPoints is for IE 10 which we don't support anymore, we can remove that.
'ontouchstart' in window || navigator.maxTouchPoints > 0;
}
getThemeIndex() {
@ -41,7 +54,7 @@ class Settings extends EventEmitter {
if (settings === null) return 0;
if (typeof settings.themeIndex === 'undefined') return 0;
// eslint-disable-next-line radix
return parseInt(settings.themeIndex);
return Math.floor(settings.themeIndex);
}
getThemeName() {