|
|
|
@ -51,22 +51,7 @@ export default class FiltersStorage extends AppManager {
@@ -51,22 +51,7 @@ export default class FiltersStorage extends AppManager {
|
|
|
|
|
this.apiUpdatesManager.addMultipleEventsListeners({ |
|
|
|
|
updateDialogFilter: this.onUpdateDialogFilter, |
|
|
|
|
|
|
|
|
|
updateDialogFilters: (update) => { |
|
|
|
|
//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)}); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
updateDialogFilters: this.onUpdateDialogFilters, |
|
|
|
|
|
|
|
|
|
updateDialogFilterOrder: this.onUpdateDialogFilterOrder |
|
|
|
|
}); |
|
|
|
@ -91,6 +76,10 @@ export default class FiltersStorage extends AppManager {
@@ -91,6 +76,10 @@ export default class FiltersStorage extends AppManager {
|
|
|
|
|
} |
|
|
|
|
}); */ |
|
|
|
|
|
|
|
|
|
this.rootScope.addEventListener('premium_toggle', () => { |
|
|
|
|
this.onUpdateDialogFilters({_: 'updateDialogFilters'}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return this.appStateManager.getState().then((state) => { |
|
|
|
|
const filtersArr = this.prependFilters(state.filtersArr); |
|
|
|
|
filtersArr.map((filter) => { |
|
|
|
@ -174,6 +163,23 @@ export default class FiltersStorage extends AppManager {
@@ -174,6 +163,23 @@ export default class FiltersStorage extends AppManager {
|
|
|
|
|
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) => { |
|
|
|
|
//console.log('updateDialogFilterOrder', update);
|
|
|
|
|
|
|
|
|
@ -533,4 +539,20 @@ export default class FiltersStorage extends AppManager {
@@ -533,4 +539,20 @@ export default class FiltersStorage extends AppManager {
|
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|