File tree Expand file tree Collapse file tree 3 files changed +15
-13
lines changed
addons/block/searchforums/services Expand file tree Collapse file tree 3 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -34,26 +34,28 @@ export class AddonBlockSearchForumsHandlerService extends CoreBlockBaseHandler {
3434 * @inheritdoc
3535 */
3636 async isEnabled ( ) : Promise < boolean > {
37- const enabled = await CoreSearchGlobalSearch . isEnabled ( ) ;
38-
39- if ( ! enabled ) {
40- return false ;
41- }
42-
43- const forumSearchAreas = [ 'mod_forum-activity' , 'mod_forum-post' ] ;
44- const searchAreas = await CoreSearchGlobalSearch . getSearchAreas ( ) ;
45-
46- return searchAreas . some ( ( { id } ) => forumSearchAreas . includes ( id ) ) ;
37+ return CoreSearchGlobalSearch . isEnabled ( ) ;
4738 }
4839
4940 /**
5041 * @inheritdoc
5142 */
52- getDisplayData ( block : CoreCourseBlock , contextLevel : string , instanceId : number ) : CoreBlockHandlerData | undefined {
43+ async getDisplayData (
44+ block : CoreCourseBlock ,
45+ contextLevel : string ,
46+ instanceId : number ,
47+ ) : Promise < undefined | CoreBlockHandlerData > {
5348 if ( contextLevel !== 'course' ) {
5449 return ;
5550 }
5651
52+ const forumSearchAreas = [ 'mod_forum-activity' , 'mod_forum-post' ] ;
53+ const searchAreas = await CoreSearchGlobalSearch . getSearchAreas ( ) ;
54+
55+ if ( ! searchAreas . some ( ( { id } ) => forumSearchAreas . includes ( id ) ) ) {
56+ return ;
57+ }
58+
5759 return {
5860 title : 'addon.block_searchforums.pluginname' ,
5961 class : 'addon-block-search-forums' ,
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export class CoreBlockBaseHandler implements CoreBlockHandler {
4747 block : CoreCourseBlock , // eslint-disable-line @typescript-eslint/no-unused-vars
4848 contextLevel : string , // eslint-disable-line @typescript-eslint/no-unused-vars
4949 instanceId : number , // eslint-disable-line @typescript-eslint/no-unused-vars
50- ) : undefined | CoreBlockHandlerData | Promise < CoreBlockHandlerData > {
50+ ) : undefined | CoreBlockHandlerData | Promise < undefined | CoreBlockHandlerData > {
5151 // To be overridden.
5252 return undefined ;
5353 }
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ export interface CoreBlockHandler extends CoreDelegateHandler {
4545 block : CoreCourseBlock ,
4646 contextLevel : string ,
4747 instanceId : number ,
48- ) : undefined | CoreBlockHandlerData | Promise < CoreBlockHandlerData > ;
48+ ) : undefined | CoreBlockHandlerData | Promise < undefined | CoreBlockHandlerData > ;
4949}
5050
5151/**
You can’t perform that action at this time.
0 commit comments