|
|
@ -51,22 +51,7 @@ export default class FiltersStorage extends AppManager { |
|
|
|
this.apiUpdatesManager.addMultipleEventsListeners({ |
|
|
|
this.apiUpdatesManager.addMultipleEventsListeners({ |
|
|
|
updateDialogFilter: this.onUpdateDialogFilter, |
|
|
|
updateDialogFilter: this.onUpdateDialogFilter, |
|
|
|
|
|
|
|
|
|
|
|
updateDialogFilters: (update) => { |
|
|
|
updateDialogFilters: this.onUpdateDialogFilters, |
|
|
|
//console.warn('updateDialogFilters', update);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const oldFilters = copy(this.filters); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.getDialogFilters(true).then((filters) => { |
|
|
|
|
|
|
|
for(const _filterId in oldFilters) { |
|
|
|
|
|
|
|
const filterId = +_filterId; |
|
|
|
|
|
|
|
if(!filters.find((filter) => filter.id === filterId)) { // * deleted
|
|
|
|
|
|
|
|
this.onUpdateDialogFilter({_: 'updateDialogFilter', id: filterId}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.onUpdateDialogFilterOrder({_: 'updateDialogFilterOrder', order: filters.map((filter) => filter.id)}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateDialogFilterOrder: this.onUpdateDialogFilterOrder |
|
|
|
updateDialogFilterOrder: this.onUpdateDialogFilterOrder |
|
|
|
}); |
|
|
|
}); |
|
|
@ -91,6 +76,10 @@ export default class FiltersStorage extends AppManager { |
|
|
|
} |
|
|
|
} |
|
|
|
}); */ |
|
|
|
}); */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.rootScope.addEventListener('premium_toggle', () => { |
|
|
|
|
|
|
|
this.onUpdateDialogFilters({_: 'updateDialogFilters'}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return this.appStateManager.getState().then((state) => { |
|
|
|
return this.appStateManager.getState().then((state) => { |
|
|
|
const filtersArr = this.prependFilters(state.filtersArr); |
|
|
|
const filtersArr = this.prependFilters(state.filtersArr); |
|
|
|
filtersArr.map((filter) => { |
|
|
|
filtersArr.map((filter) => { |
|
|
@ -174,6 +163,23 @@ export default class FiltersStorage extends AppManager { |
|
|
|
this.pushToState(); |
|
|
|
this.pushToState(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private onUpdateDialogFilters = (update: Update.updateDialogFilters) => { |
|
|
|
|
|
|
|
//console.warn('updateDialogFilters', update);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const oldFilters = copy(this.filters); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.getDialogFilters(true).then((filters) => { |
|
|
|
|
|
|
|
for(const _filterId in oldFilters) { |
|
|
|
|
|
|
|
const filterId = +_filterId; |
|
|
|
|
|
|
|
if(!filters.find((filter) => filter.id === filterId)) { // * deleted
|
|
|
|
|
|
|
|
this.onUpdateDialogFilter({_: 'updateDialogFilter', id: filterId}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.onUpdateDialogFilterOrder({_: 'updateDialogFilterOrder', order: filters.map((filter) => filter.id)}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
private onUpdateDialogFilterOrder = (update: Update.updateDialogFilterOrder) => { |
|
|
|
private onUpdateDialogFilterOrder = (update: Update.updateDialogFilterOrder) => { |
|
|
|
//console.log('updateDialogFilterOrder', update);
|
|
|
|
//console.log('updateDialogFilterOrder', update);
|
|
|
|
|
|
|
|
|
|
|
@ -533,4 +539,20 @@ export default class FiltersStorage extends AppManager { |
|
|
|
this.pushToState(); |
|
|
|
this.pushToState(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async isFilterIdAvailable(filterId: number) { |
|
|
|
|
|
|
|
if(REAL_FOLDERS.has(filterId)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isPremium = this.rootScope.premium; |
|
|
|
|
|
|
|
let isFolderAvailable = isPremium; |
|
|
|
|
|
|
|
if(!isPremium) { |
|
|
|
|
|
|
|
const config = await this.apiManager.getAppConfig(); |
|
|
|
|
|
|
|
const limit = config.dialog_filters_limit_default; |
|
|
|
|
|
|
|
isFolderAvailable = this.filtersArr.filter((filter) => !REAL_FOLDERS.has(filter.id)).slice(0, limit).some((filter) => filter.id === filterId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return isFolderAvailable; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|