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 {
34
34
* @inheritdoc
35
35
*/
36
36
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 ( ) ;
47
38
}
48
39
49
40
/**
50
41
* @inheritdoc
51
42
*/
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 > {
53
48
if ( contextLevel !== 'course' ) {
54
49
return ;
55
50
}
56
51
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
+
57
59
return {
58
60
title : 'addon.block_searchforums.pluginname' ,
59
61
class : 'addon-block-search-forums' ,
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export class CoreBlockBaseHandler implements CoreBlockHandler {
47
47
block : CoreCourseBlock , // eslint-disable-line @typescript-eslint/no-unused-vars
48
48
contextLevel : string , // eslint-disable-line @typescript-eslint/no-unused-vars
49
49
instanceId : number , // eslint-disable-line @typescript-eslint/no-unused-vars
50
- ) : undefined | CoreBlockHandlerData | Promise < CoreBlockHandlerData > {
50
+ ) : undefined | CoreBlockHandlerData | Promise < undefined | CoreBlockHandlerData > {
51
51
// To be overridden.
52
52
return undefined ;
53
53
}
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ export interface CoreBlockHandler extends CoreDelegateHandler {
45
45
block : CoreCourseBlock ,
46
46
contextLevel : string ,
47
47
instanceId : number ,
48
- ) : undefined | CoreBlockHandlerData | Promise < CoreBlockHandlerData > ;
48
+ ) : undefined | CoreBlockHandlerData | Promise < undefined | CoreBlockHandlerData > ;
49
49
}
50
50
51
51
/**
You can’t perform that action at this time.
0 commit comments