Skip to content

Commit

Permalink
Merge branch 'master' into OwnCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
djmaze committed Jul 20, 2021
2 parents 9657578 + 5ef2b6d commit 2aed429
Show file tree
Hide file tree
Showing 78 changed files with 777 additions and 880 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
1. Install node.js - `https://nodejs.org/download/`
2. Install yarn - `https://yarnpkg.com/en/docs/install`
3. Install gulp - `npm install gulp -g`
4. Fork snappymail - `https://github.com/the-djmaze/snappymail/issues/new#fork-destination-box`
4. Fork snappymail from https://github.com/the-djmaze/snappymail
5. Clone snappymail - `git clone git@github.com:USERNAME/snappymail.git snappymail`
6. `cd snappymail`
7. Install install all dependencies - `yarn install`
Expand Down
22 changes: 10 additions & 12 deletions dev/App/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
} from 'Common/Cache';

import {
userBackground,
mailBox,
root,
openPgpWorkerJs,
Expand Down Expand Up @@ -81,6 +80,8 @@ import { ComposePopupView } from 'View/Popup/Compose';
import { FolderSystemPopupView } from 'View/Popup/FolderSystem';
import { AskPopupView } from 'View/Popup/Ask';

import { timeToNode } from 'Common/Momentor';

// Every 5 minutes
const refreshFolders = 300000;

Expand Down Expand Up @@ -110,16 +111,6 @@ class AppUser extends AbstractApp {
lastTime = currentTime;
}, 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);
['keydown','keyup'].forEach(t => doc.addEventListener(t, fn));

Expand Down Expand Up @@ -1020,7 +1011,14 @@ class AppUser extends AbstractApp {
this.hideLoading();
}

setInterval(() => dispatchEvent(new CustomEvent('reload-time')), 60000);
setInterval(this.reloadTime(), 60000);
}

reloadTime()
{
setTimeout(() =>
doc.querySelectorAll('[data-bind*="moment:"]').forEach(element => timeToNode(element))
, 1)
}

showMessageComposer(params = [])
Expand Down
8 changes: 0 additions & 8 deletions dev/Common/Links.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ export function change(email) {
return serverRequest('Change') + encodeURIComponent(email) + '/';
}

/**
* @param {string} hash
* @returns {string}
*/
export function userBackground(hash) {
return serverRequestRaw('UserBackground', hash);
}

/**
* @param {string} lang
* @param {boolean} isAdmin
Expand Down
6 changes: 0 additions & 6 deletions dev/Common/Momentor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { doc } from 'Common/Globals';
import { i18n } from 'Common/Translator';

export function timestampToString(timeStampInUTC, formatStr) {
Expand Down Expand Up @@ -53,8 +52,3 @@ export function timeToNode(element, time) {
console.error(e);
}
}

addEventListener('reload-time', () => setTimeout(() =>
doc.querySelectorAll('[data-bind*="moment:"]').forEach(element => timeToNode(element))
, 1)
);
51 changes: 35 additions & 16 deletions dev/Common/Selector.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import ko from 'ko';
import { isArray } from 'Common/Utils';

/*
oCallbacks:
ItemSelect
MiddleClick
AutoSelect
ItemGetUid
UpOrDown
*/

export class Selector {
/**
* @param {koProperty} koList
Expand Down Expand Up @@ -209,11 +218,9 @@ export class Selector {

itemSelected(item) {
if (this.isListChecked()) {
if (!item) {
(this.oCallbacks.onItemSelect || (()=>{}))(item || null);
}
item || (this.oCallbacks.ItemSelect || (()=>{}))(null);
} else if (item) {
(this.oCallbacks.onItemSelect || (()=>{}))(item);
(this.oCallbacks.ItemSelect || (()=>{}))(item);
}
}

Expand All @@ -226,20 +233,32 @@ export class Selector {
this.oContentScrollable = contentScrollable;

if (contentScrollable) {
let getItem = selector => {
let el = event.target.closestWithin(selector, contentScrollable);
return el ? ko.dataFor(el) : null;
};

contentScrollable.addEventListener('click', event => {
let el = event.target.closestWithin(this.sItemSelector, contentScrollable);
el && this.actionClick(ko.dataFor(el), event);

el = event.target.closestWithin(this.sItemCheckedSelector, contentScrollable);
if (el) {
const item = ko.dataFor(el);
const item = getItem(this.sItemCheckedSelector);
if (item) {
if (event.shiftKey) {
this.actionClick(item, event);
} else {
this.focusedItem(item);
item.checked(!item.checked());
}
}
});

contentScrollable.addEventListener('auxclick', event => {
if (1 == event.button) {
const item = getItem(this.sItemSelector);
if (item) {
if (event.shiftKey) {
this.actionClick(item, event);
} else {
this.focusedItem(item);
item.checked(!item.checked());
}
this.focusedItem(item);
(this.oCallbacks.MiddleClick || (()=>{}))(item);
}
}
});
Expand Down Expand Up @@ -271,7 +290,7 @@ export class Selector {
* @returns {boolean}
*/
autoSelect() {
return !!(this.oCallbacks.onAutoSelect || (()=>true))();
return !!(this.oCallbacks.AutoSelect || (()=>true))();
}

/**
Expand All @@ -281,7 +300,7 @@ export class Selector {
getItemUid(item) {
let uid = '';

const getItemUidCallback = this.oCallbacks.onItemGetUid || null;
const getItemUidCallback = this.oCallbacks.ItemGetUid || null;
if (getItemUidCallback && item) {
uid = getItemUidCallback(item);
}
Expand Down Expand Up @@ -312,7 +331,7 @@ export class Selector {
} else if (++i < listLen) {
result = list[i];
}
result || (this.oCallbacks.onUpUpOrDownDown || (()=>true))('ArrowUp' === sEventKey);
result || (this.oCallbacks.UpOrDown || (()=>true))('ArrowUp' === sEventKey);
} else if ('Home' === sEventKey) {
result = list[0];
} else if ('End' === sEventKey) {
Expand Down
2 changes: 1 addition & 1 deletion dev/Common/Translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function reload(admin, language) {
// reload the data
if (init()) {
i18nToNodes(doc);
dispatchEvent(new CustomEvent('reload-time'));
admin || rl.app.reloadTime();
trigger(!trigger());
}
script.remove();
Expand Down
7 changes: 0 additions & 7 deletions dev/Model/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,6 @@ export class MessageModel extends AbstractModel {
}
}

storeDataInDom() {
if (this.body) {
this.body.rlIsHtml = !!this.isHtml();
this.body.rlHasImages = !!this.hasImages();
}
}

fetchDataFromDom() {
if (this.body) {
this.isHtml(!!this.body.rlIsHtml);
Expand Down
14 changes: 2 additions & 12 deletions dev/Settings/User/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import ko from 'ko';

import { SaveSettingsStep, UploadErrorCode, Capa } from 'Common/Enums';
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 { doc, $htmlCL, Settings } from 'Common/Globals';
import { Settings } from 'Common/Globals';

import { ThemeStore } from 'Stores/Theme';

Expand Down Expand Up @@ -38,16 +38,6 @@ export class ThemesUserSettings {
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() {
Expand Down
13 changes: 12 additions & 1 deletion dev/Stores/Theme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 { serverRequestRaw } from 'Common/Links';

export const ThemeStore = {
themes: ko.observableArray(),
Expand All @@ -25,3 +26,13 @@ export const ThemeStore = {
ThemeStore.theme = ko.observable('').extend({ limitedList: ThemeStore.themes });

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

0 comments on commit 2aed429

Please sign in to comment.