mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-10 15:08:28 +03:00
Remove addHook/runHook system as it is never used
This commit is contained in:
parent
996723a486
commit
d88855ebd9
7 changed files with 1 additions and 128 deletions
|
|
@ -21,7 +21,6 @@ import {
|
|||
import { $htmlCL, leftPanelDisabled, bMobileDevice } from 'Common/Globals';
|
||||
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
import { runHook } from 'Common/Plugins';
|
||||
|
||||
import {
|
||||
initMessageFlagsFromCache,
|
||||
|
|
@ -924,8 +923,6 @@ class AppUser extends AbstractApp {
|
|||
const customLoginLink = pString(Settings.appSettingsGet('customLoginLink'));
|
||||
if (!customLoginLink) {
|
||||
startScreens([LoginUserScreen]);
|
||||
|
||||
runHook('rl-start-login-screens');
|
||||
} else {
|
||||
routeOff();
|
||||
setHash(root(), true);
|
||||
|
|
@ -1061,8 +1058,6 @@ class AppUser extends AbstractApp {
|
|||
|
||||
addEventListener('rl.auto-logout', () => this.logout());
|
||||
|
||||
runHook('rl-start-user-screens');
|
||||
|
||||
if (Settings.settingsGet('WelcomePageUrl')) {
|
||||
setTimeout(() => this.bootstartWelcomePopup(Settings.settingsGet('WelcomePageUrl')), 1000);
|
||||
}
|
||||
|
|
@ -1104,8 +1099,6 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
|
||||
setInterval(() => dispatchEvent(new CustomEvent('reload-time')), 60000);
|
||||
|
||||
runHook('rl-start-screens');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,36 +1,9 @@
|
|||
import { data as GlobalsData } from 'Common/Globals';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
const SIMPLE_HOOKS = {},
|
||||
USER_VIEW_MODELS_HOOKS = [],
|
||||
const USER_VIEW_MODELS_HOOKS = [],
|
||||
ADMIN_VIEW_MODELS_HOOKS = [];
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {Function} callback
|
||||
*/
|
||||
export function addHook(name, callback) {
|
||||
if (typeof callback === 'function') {
|
||||
if (!Array.isArray(SIMPLE_HOOKS[name])) {
|
||||
SIMPLE_HOOKS[name] = [];
|
||||
}
|
||||
|
||||
SIMPLE_HOOKS[name].push(callback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {Array=} args = []
|
||||
*/
|
||||
export function runHook(name, args = []) {
|
||||
if (Array.isArray(SIMPLE_HOOKS[name])) {
|
||||
SIMPLE_HOOKS[name].forEach(callback => {
|
||||
callback(...args);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {?}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { runHook } from 'Common/Plugins';
|
||||
import { $htmlCL, VIEW_MODELS, popupVisibilityNames } from 'Common/Globals';
|
||||
|
||||
import { pString, createCommandLegacy, isNonEmptyArray } from 'Common/Utils';
|
||||
|
|
@ -120,17 +119,6 @@ export function hideScreenPopup(ViewModelClassToHide) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} hookName
|
||||
* @param {Function} ViewModelClass
|
||||
* @param {mixed=} params = null
|
||||
*/
|
||||
export function vmRunHook(hookName, ViewModelClass, params = null) {
|
||||
ViewModelClass.__names.forEach(name => {
|
||||
runHook(hookName, [name, ViewModelClass.__vm, params]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} ViewModelClass
|
||||
* @param {Object=} vmScreen
|
||||
|
|
@ -146,9 +134,6 @@ export function buildViewModel(ViewModelClass, vmScreen) {
|
|||
ViewModelClass.__builded = true;
|
||||
ViewModelClass.__vm = vm;
|
||||
|
||||
vm.onShowTrigger = ko.observable(false);
|
||||
vm.onHideTrigger = ko.observable(false);
|
||||
|
||||
vm.viewModelName = ViewModelClass.__name;
|
||||
vm.viewModelNames = ViewModelClass.__names;
|
||||
vm.viewModelTemplateID = ViewModelClass.__templateID;
|
||||
|
|
@ -177,23 +162,13 @@ export function buildViewModel(ViewModelClass, vmScreen) {
|
|||
popupVisibilityNames.push(vm.viewModelName);
|
||||
vm.viewModelDom.css('z-index', 3000 + popupVisibilityNames().length + 10);
|
||||
|
||||
if (vm.onShowTrigger) {
|
||||
vm.onShowTrigger(!vm.onShowTrigger());
|
||||
}
|
||||
|
||||
vm.onShowWithDelay && setTimeout(()=>vm.onShowWithDelay, 500);
|
||||
} else {
|
||||
vm.onHide && vm.onHide();
|
||||
vm.onHideWithDelay && setTimeout(()=>vm.onHideWithDelay, 500);
|
||||
|
||||
if (vm.onHideTrigger) {
|
||||
vm.onHideTrigger(!vm.onHideTrigger());
|
||||
}
|
||||
|
||||
vm.restoreKeyScope();
|
||||
|
||||
vmRunHook('view-model-on-hide', ViewModelClass);
|
||||
|
||||
popupVisibilityNames.remove(vm.viewModelName);
|
||||
vm.viewModelDom.css('z-index', 2000);
|
||||
|
||||
|
|
@ -202,8 +177,6 @@ export function buildViewModel(ViewModelClass, vmScreen) {
|
|||
});
|
||||
}
|
||||
|
||||
vmRunHook('view-model-pre-build', ViewModelClass, vmDom);
|
||||
|
||||
ko.applyBindingAccessorsToNode(
|
||||
vmDom[0],
|
||||
{
|
||||
|
|
@ -217,8 +190,6 @@ export function buildViewModel(ViewModelClass, vmScreen) {
|
|||
if (vm && ViewType.Popup === position) {
|
||||
vm.registerPopupKeyDown();
|
||||
}
|
||||
|
||||
vmRunHook('view-model-post-build', ViewModelClass, vmDom);
|
||||
} else {
|
||||
console.log('Cannot find view model position: ' + position);
|
||||
}
|
||||
|
|
@ -248,8 +219,6 @@ export function showScreenPopup(ViewModelClassToShow, params = []) {
|
|||
|
||||
const af = ModalView.__dom[0].querySelector('[autofocus]');
|
||||
af && af.focus();
|
||||
|
||||
vmRunHook('view-model-on-show', ModalView, params || []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -323,10 +292,6 @@ export function screenOnRoute(screenName, subPart) {
|
|||
currentScreen.onHide && currentScreen.onHide();
|
||||
currentScreen.onHideWithDelay && setTimeout(()=>currentScreen.onHideWithDelay(), 500);
|
||||
|
||||
if (currentScreen.onHideTrigger) {
|
||||
currentScreen.onHideTrigger(!currentScreen.onHideTrigger());
|
||||
}
|
||||
|
||||
if (isNonEmptyArray(currentScreen.viewModels())) {
|
||||
currentScreen.viewModels().forEach(ViewModelClass => {
|
||||
if (
|
||||
|
|
@ -339,10 +304,6 @@ export function screenOnRoute(screenName, subPart) {
|
|||
|
||||
ViewModelClass.__vm.onHide && ViewModelClass.__vm.onHide();
|
||||
ViewModelClass.__vm.onHideWithDelay && setTimeout(()=>ViewModelClass.__vm.onHideWithDelay(), 500);
|
||||
|
||||
if (ViewModelClass.__vm.onHideTrigger) {
|
||||
ViewModelClass.__vm.onHideTrigger(!ViewModelClass.__vm.onHideTrigger());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -354,11 +315,6 @@ export function screenOnRoute(screenName, subPart) {
|
|||
// show screen
|
||||
if (currentScreen && !isSameScreen) {
|
||||
currentScreen.onShow && currentScreen.onShow();
|
||||
if (currentScreen.onShowTrigger) {
|
||||
currentScreen.onShowTrigger(!currentScreen.onShowTrigger());
|
||||
}
|
||||
|
||||
runHook('screen-on-show', [currentScreen.screenName(), currentScreen]);
|
||||
|
||||
if (isNonEmptyArray(currentScreen.viewModels())) {
|
||||
currentScreen.viewModels().forEach(ViewModelClass => {
|
||||
|
|
@ -373,16 +329,11 @@ export function screenOnRoute(screenName, subPart) {
|
|||
ViewModelClass.__vm.viewModelVisibility(true);
|
||||
|
||||
ViewModelClass.__vm.onShow && ViewModelClass.__vm.onShow();
|
||||
if (ViewModelClass.__vm.onShowTrigger) {
|
||||
ViewModelClass.__vm.onShowTrigger(!ViewModelClass.__vm.onShowTrigger());
|
||||
}
|
||||
|
||||
const af = ViewModelClass.__dom[0].querySelector('[autofocus]');
|
||||
af && af.focus();
|
||||
|
||||
ViewModelClass.__vm.onShowWithDelay && setTimeout(()=>ViewModelClass.__vm.onShowWithDelay, 200);
|
||||
|
||||
vmRunHook('view-model-on-show', ViewModelClass);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -422,10 +373,7 @@ export function startScreens(screensClasses) {
|
|||
if (vmScreen && !vmScreen.__started && vmScreen.__start) {
|
||||
vmScreen.__started = true;
|
||||
vmScreen.__start();
|
||||
|
||||
runHook('screen-pre-start', [vmScreen.screenName(), vmScreen]);
|
||||
vmScreen.onStart && vmScreen.onStart();
|
||||
runHook('screen-post-start', [vmScreen.screenName(), vmScreen]);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { pInt, pString } from 'Common/Utils';
|
|||
import { DEFAULT_AJAX_TIMEOUT, TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT } from 'Common/Consts';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { data as GlobalsData } from 'Common/Globals';
|
||||
import { runHook } from 'Common/Plugins';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
import { AbstractBasicPromises } from 'Promises/AbstractBasic';
|
||||
|
|
@ -68,8 +67,6 @@ class AbstractAjaxPromises extends AbstractBasicPromises {
|
|||
init.body = new URLSearchParams(formData);
|
||||
}
|
||||
|
||||
runHook('ajax-default-request', [action, params, additionalGetString]);
|
||||
|
||||
this.setTrigger(fTrigger, true);
|
||||
|
||||
if (window.AbortController) {
|
||||
|
|
@ -110,13 +107,6 @@ class AbstractAjaxPromises extends AbstractBasicPromises {
|
|||
type = StorageResultType.Error;
|
||||
break;
|
||||
}
|
||||
runHook('ajax-default-response', [
|
||||
action,
|
||||
StorageResultType.Success === type ? data : null,
|
||||
type,
|
||||
isCached,
|
||||
params
|
||||
]);
|
||||
*/
|
||||
this.setTrigger(fTrigger, false);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { StorageResultType, Notification } from 'Common/Enums';
|
|||
import { pInt, pString } from 'Common/Utils';
|
||||
import { data as GlobalsData } from 'Common/Globals';
|
||||
import { ajax } from 'Common/Links';
|
||||
import { runHook } from 'Common/Plugins';
|
||||
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
|
|
@ -81,14 +80,6 @@ class AbstractAjaxRemote {
|
|||
GlobalsData.iTokenErrorCount = 0;
|
||||
}
|
||||
|
||||
runHook('ajax-default-response', [
|
||||
sRequestAction,
|
||||
StorageResultType.Success === sType ? oData : null,
|
||||
sType,
|
||||
bCached,
|
||||
oRequestParameters
|
||||
]);
|
||||
|
||||
if (fCallback) {
|
||||
fCallback(
|
||||
sType,
|
||||
|
|
@ -222,8 +213,6 @@ class AbstractAjaxRemote {
|
|||
|
||||
sGetAdd = pString(sGetAdd);
|
||||
|
||||
runHook('ajax-default-request', [sAction, oParameters, sGetAdd]);
|
||||
|
||||
return this.ajaxRequest(
|
||||
fCallback,
|
||||
oParameters,
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ import { convertLangName, triggerAutocompleteInputChange } from 'Common/Utils';
|
|||
|
||||
import { getNotification, getNotificationFromResponse, reload as translatorReload } from 'Common/Translator';
|
||||
|
||||
import * as Plugins from 'Common/Plugins';
|
||||
|
||||
import AppStore from 'Stores/User/App';
|
||||
import LanguageStore from 'Stores/Language';
|
||||
|
||||
|
|
@ -172,23 +170,6 @@ class LoginUserView extends AbstractViewNext {
|
|||
return false;
|
||||
}
|
||||
|
||||
let pluginResultCode = 0,
|
||||
pluginResultMessage = '';
|
||||
|
||||
const fSubmitResult = (iResultCode, sResultMessage) => {
|
||||
pluginResultCode = iResultCode || 0;
|
||||
pluginResultMessage = sResultMessage || '';
|
||||
};
|
||||
|
||||
Plugins.runHook('user-login-submit', [fSubmitResult]);
|
||||
if (0 < pluginResultCode) {
|
||||
this.submitError(getNotification(pluginResultCode));
|
||||
return false;
|
||||
} else if (pluginResultMessage) {
|
||||
this.submitError(pluginResultMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
const fLoginRequest = (sLoginPassword) => {
|
||||
|
|
|
|||
1
dev/bootstrap.js
vendored
1
dev/bootstrap.js
vendored
|
|
@ -44,7 +44,6 @@ export default (App) => {
|
|||
rl.addSettingsViewModel = Plugins.addSettingsViewModel;
|
||||
rl.addSettingsViewModelForAdmin = Plugins.addSettingsViewModelForAdmin;
|
||||
|
||||
rl.addHook = Plugins.addHook;
|
||||
rl.settingsGet = Plugins.mainSettingsGet;
|
||||
rl.pluginSettingsGet = Plugins.settingsGet;
|
||||
rl.pluginRemoteRequest = Plugins.remoteRequest;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue