commit
0c49a451f7
|
@ -34,26 +34,28 @@ export class AddonBlockSearchForumsHandlerService extends CoreBlockBaseHandler {
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(): Promise<boolean> {
|
||||
const enabled = await CoreSearchGlobalSearch.isEnabled();
|
||||
|
||||
if (!enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const forumSearchAreas = ['mod_forum-activity', 'mod_forum-post'];
|
||||
const searchAreas = await CoreSearchGlobalSearch.getSearchAreas();
|
||||
|
||||
return searchAreas.some(({ id }) => forumSearchAreas.includes(id));
|
||||
return CoreSearchGlobalSearch.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData | undefined {
|
||||
async getDisplayData(
|
||||
block: CoreCourseBlock,
|
||||
contextLevel: string,
|
||||
instanceId: number,
|
||||
): Promise<undefined | CoreBlockHandlerData> {
|
||||
if (contextLevel !== 'course') {
|
||||
return;
|
||||
}
|
||||
|
||||
const forumSearchAreas = ['mod_forum-activity', 'mod_forum-post'];
|
||||
const searchAreas = await CoreSearchGlobalSearch.getSearchAreas();
|
||||
|
||||
if (!searchAreas.some(({ id }) => forumSearchAreas.includes(id))) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
title: 'addon.block_searchforums.pluginname',
|
||||
class: 'addon-block-search-forums',
|
||||
|
|
|
@ -47,7 +47,7 @@ export class CoreBlockBaseHandler implements CoreBlockHandler {
|
|||
block: CoreCourseBlock, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
contextLevel: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
instanceId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
): undefined | CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
): undefined | CoreBlockHandlerData | Promise<undefined | CoreBlockHandlerData> {
|
||||
// To be overridden.
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ export interface CoreBlockHandler extends CoreDelegateHandler {
|
|||
block: CoreCourseBlock,
|
||||
contextLevel: string,
|
||||
instanceId: number,
|
||||
): undefined | CoreBlockHandlerData | Promise<CoreBlockHandlerData>;
|
||||
): undefined | CoreBlockHandlerData | Promise<undefined | CoreBlockHandlerData>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue