Merge pull request #2485 from dpalou/MOBILE-3454
MOBILE-3454 filters: Support disabling check text filtersmain
commit
4f4484fd0c
|
@ -65,10 +65,10 @@ export class CoreFilterProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not WS get available in context is avalaible.
|
||||
* Returns whether or not WS get available in context is available.
|
||||
*
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with true if ws is avalaible, false otherwise.
|
||||
* @return Promise resolved with true if ws is available, false otherwise.
|
||||
* @since 3.4
|
||||
*/
|
||||
canGetAvailableInContext(siteId?: string): Promise<boolean> {
|
||||
|
@ -78,10 +78,10 @@ export class CoreFilterProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not WS get available in context is avalaible in a certain site.
|
||||
* Returns whether or not WS get available in context is available in a certain site.
|
||||
*
|
||||
* @param site Site. If not defined, current site.
|
||||
* @return Promise resolved with true if ws is avalaible, false otherwise.
|
||||
* @return Promise resolved with true if ws is available, false otherwise.
|
||||
* @since 3.4
|
||||
*/
|
||||
canGetAvailableInContextInSite(site?: CoreSite): boolean {
|
||||
|
@ -90,6 +90,53 @@ export class CoreFilterProvider {
|
|||
return site.wsAvailable('core_filters_get_available_in_context');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not we can get the available filters: the WS is available and the feature isn't disabled.
|
||||
*
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with boolean: whethe can get filters.
|
||||
*/
|
||||
async canGetFilters(siteId?: string): Promise<boolean> {
|
||||
const wsAvailable = await this.canGetAvailableInContext(siteId);
|
||||
const disabled = await this.checkFiltersDisabled(siteId);
|
||||
|
||||
return wsAvailable && !disabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not we can get the available filters: the WS is available and the feature isn't disabled.
|
||||
*
|
||||
* @param site Site. If not defined, current site.
|
||||
* @return Promise resolved with boolean: whethe can get filters.
|
||||
*/
|
||||
canGetFiltersInSite(site?: CoreSite): boolean {
|
||||
return this.canGetAvailableInContextInSite(site) && this.checkFiltersDisabledInSite(site);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not checking the available filters is disabled in the site.
|
||||
*
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with boolean: whether it's disabled.
|
||||
*/
|
||||
async checkFiltersDisabled(siteId?: string): Promise<boolean> {
|
||||
const site = await this.sitesProvider.getSite(siteId);
|
||||
|
||||
return this.checkFiltersDisabledInSite(site);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not checking the available filters is disabled in the site.
|
||||
*
|
||||
* @param site Site. If not defined, current site.
|
||||
* @return Whether it's disabled.
|
||||
*/
|
||||
checkFiltersDisabledInSite(site?: CoreSite): boolean {
|
||||
site = site || this.sitesProvider.getCurrentSite();
|
||||
|
||||
return site.isFeatureDisabled('CoreFilterDelegate');
|
||||
}
|
||||
|
||||
/**
|
||||
* Given some HTML code, this function returns the text as safe HTML.
|
||||
*
|
||||
|
|
|
@ -173,7 +173,7 @@ export class CoreFilterHelperProvider {
|
|||
|
||||
/**
|
||||
* Get the filters in a certain context, performing some checks like the site version.
|
||||
* It's recommended to use this function instead of canGetAvailableInContext because this function will check if
|
||||
* It's recommended to use this function instead of canGetFilters + getEnabledFilters because this function will check if
|
||||
* it's really needed to call the WS.
|
||||
*
|
||||
* @param contextLevel The context level.
|
||||
|
@ -193,7 +193,7 @@ export class CoreFilterHelperProvider {
|
|||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
siteId = site.getId();
|
||||
|
||||
return this.filterProvider.canGetAvailableInContext(siteId).then((canGet) => {
|
||||
return this.filterProvider.canGetFilters(siteId).then((canGet) => {
|
||||
if (!canGet) {
|
||||
options.filter = true;
|
||||
|
||||
|
|
|
@ -471,7 +471,7 @@ export class CorePushNotificationsProvider {
|
|||
extraFeatures = this.utils.isTrueOrOne(data.extrafeatures);
|
||||
|
||||
// Get the filters to apply to text and message. Don't use FIlterHelper to prevent circular dependencies.
|
||||
this.filterProvider.canGetAvailableInContext(site.getId()).then((canGet) => {
|
||||
this.filterProvider.canGetFilters(site.getId()).then((canGet) => {
|
||||
if (!canGet) {
|
||||
// We cannot check which filters are available, apply them all.
|
||||
return this.filterDelegate.getEnabledFilters(options.contextLevel, options.instanceId);
|
||||
|
|
Loading…
Reference in New Issue