mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 15:37:03 +03:00
Simplify UserBackground code
This commit is contained in:
parent
e13337e247
commit
18cedbabad
4 changed files with 14 additions and 32 deletions
|
|
@ -38,7 +38,6 @@ import {
|
||||||
} from 'Common/Cache';
|
} from 'Common/Cache';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
userBackground,
|
|
||||||
mailBox,
|
mailBox,
|
||||||
root,
|
root,
|
||||||
openPgpWorkerJs,
|
openPgpWorkerJs,
|
||||||
|
|
@ -112,16 +111,6 @@ class AppUser extends AbstractApp {
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
}, interval);
|
}, interval);
|
||||||
|
|
||||||
if (SettingsGet('UserBackgroundHash')) {
|
|
||||||
setTimeout(() => {
|
|
||||||
const img = userBackground(SettingsGet('UserBackgroundHash'));
|
|
||||||
if (img) {
|
|
||||||
$htmlCL.add('UserBackground');
|
|
||||||
doc.body.style.backgroundImage = "url("+img+")";
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
const fn = (ev=>$htmlCL.toggle('rl-ctrl-key-pressed', ev.ctrlKey)).debounce(500);
|
const fn = (ev=>$htmlCL.toggle('rl-ctrl-key-pressed', ev.ctrlKey)).debounce(500);
|
||||||
['keydown','keyup'].forEach(t => doc.addEventListener(t, fn));
|
['keydown','keyup'].forEach(t => doc.addEventListener(t, fn));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,14 +70,6 @@ export function change(email) {
|
||||||
return serverRequest('Change') + encodeURIComponent(email) + '/';
|
return serverRequest('Change') + encodeURIComponent(email) + '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} hash
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
export function userBackground(hash) {
|
|
||||||
return serverRequestRaw('UserBackground', hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} lang
|
* @param {string} lang
|
||||||
* @param {boolean} isAdmin
|
* @param {boolean} isAdmin
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ import ko from 'ko';
|
||||||
|
|
||||||
import { SaveSettingsStep, UploadErrorCode, Capa } from 'Common/Enums';
|
import { SaveSettingsStep, UploadErrorCode, Capa } from 'Common/Enums';
|
||||||
import { changeTheme, convertThemeName } from 'Common/Utils';
|
import { changeTheme, convertThemeName } from 'Common/Utils';
|
||||||
import { userBackground, themePreviewLink, serverRequest } from 'Common/Links';
|
import { themePreviewLink, serverRequest } from 'Common/Links';
|
||||||
import { i18n } from 'Common/Translator';
|
import { i18n } from 'Common/Translator';
|
||||||
import { doc, $htmlCL, Settings } from 'Common/Globals';
|
import { Settings } from 'Common/Globals';
|
||||||
|
|
||||||
import { ThemeStore } from 'Stores/Theme';
|
import { ThemeStore } from 'Stores/Theme';
|
||||||
|
|
||||||
|
|
@ -38,16 +38,6 @@ export class ThemesUserSettings {
|
||||||
Theme: value
|
Theme: value
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.background.hash.subscribe((value) => {
|
|
||||||
if (!value) {
|
|
||||||
$htmlCL.remove('UserBackground');
|
|
||||||
doc.body.removeAttribute('style');
|
|
||||||
} else {
|
|
||||||
$htmlCL.add('UserBackground');
|
|
||||||
doc.body.style.backgroundImage = "url("+userBackground(value)+")";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onBuild() {
|
onBuild() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
import { $htmlCL, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals';
|
import { doc, $htmlCL, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals';
|
||||||
import { isArray } from 'Common/Utils';
|
import { isArray } from 'Common/Utils';
|
||||||
|
import { serverRequestRaw } from 'Common/Links';
|
||||||
|
|
||||||
export const ThemeStore = {
|
export const ThemeStore = {
|
||||||
themes: ko.observableArray(),
|
themes: ko.observableArray(),
|
||||||
|
|
@ -25,3 +26,13 @@ export const ThemeStore = {
|
||||||
ThemeStore.theme = ko.observable('').extend({ limitedList: ThemeStore.themes });
|
ThemeStore.theme = ko.observable('').extend({ limitedList: ThemeStore.themes });
|
||||||
|
|
||||||
ThemeStore.isMobile.subscribe(value => $htmlCL.toggle('rl-mobile', value));
|
ThemeStore.isMobile.subscribe(value => $htmlCL.toggle('rl-mobile', value));
|
||||||
|
|
||||||
|
ThemeStore.userBackgroundHash.subscribe(value => {
|
||||||
|
if (value) {
|
||||||
|
$htmlCL.add('UserBackground');
|
||||||
|
doc.body.style.backgroundImage = "url("+serverRequestRaw('UserBackground', value)+")";
|
||||||
|
} else {
|
||||||
|
$htmlCL.remove('UserBackground');
|
||||||
|
doc.body.removeAttribute('style');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue