Fix Sieve Circular dependency

This commit is contained in:
the-djmaze 2022-03-11 13:01:46 +01:00
parent ea25d9bce4
commit 9bae77bfa1
2 changed files with 34 additions and 36 deletions

View file

@ -1,5 +1,3 @@
import { SieveScriptModel } from 'Sieve/Model/Script';
export const
// import { i18n } from 'Common/Translator';
i18n = rl.i18n,
@ -58,32 +56,4 @@ export const
setError = text => {
serverError(true);
serverErrorDesc(text);
},
updateList = () => {
if (!loading()) {
loading(true);
serverError(false);
Remote.request('Filters', (iError, data) => {
loading(false);
scripts([]);
if (iError) {
capa([]);
setError(getNotification(iError));
} else {
capa(data.Result.Capa);
/*
scripts(
data.Result.Scripts.map(aItem => SieveScriptModel.reviveFromJson(aItem)).filter(v => v)
);
*/
forEachObjectValue(data.Result.Scripts, value => {
value = SieveScriptModel.reviveFromJson(value);
value && scripts.push(value)
});
}
});
}
};

View file

@ -1,15 +1,16 @@
import {
capa,
scripts,
forEachObjectValue,
getNotification,
loading,
Remote,
scripts,
serverError,
serverErrorDesc,
setError,
updateList,
getNotification,
Remote
setError
} from 'Sieve/Utils';
import { SieveScriptModel } from 'Sieve/Model/Script';
import { SieveScriptPopupView } from 'Sieve/View/Script';
// SieveUserStore
@ -17,7 +18,6 @@ window.Sieve = {
capa: capa,
scripts: scripts,
setError: setError,
updateList: updateList,
loading: loading,
serverError: serverError,
serverErrorDesc: serverErrorDesc,
@ -25,6 +25,34 @@ window.Sieve = {
folderList: null,
updateList: () => {
if (!loading()) {
loading(true);
serverError(false);
Remote.request('Filters', (iError, data) => {
loading(false);
scripts([]);
if (iError) {
capa([]);
setError(getNotification(iError));
} else {
capa(data.Result.Capa);
/*
scripts(
data.Result.Scripts.map(aItem => SieveScriptModel.reviveFromJson(aItem)).filter(v => v)
);
*/
forEachObjectValue(data.Result.Scripts, value => {
value = SieveScriptModel.reviveFromJson(value);
value && scripts.push(value)
});
}
});
}
},
deleteScript: script => {
serverError(false);
Remote.request('FiltersScriptDelete',