1
1
import { withPluginApi } from "discourse/lib/plugin-api" ;
2
2
import discourseComputed from "discourse-common/utils/decorators" ;
3
+ import { inject as service } from "@ember/service" ;
4
+
5
+ const enabledCategories = settings . enabled_categories
6
+ . split ( "|" )
7
+ . map ( ( id ) => parseInt ( id , 10 ) )
8
+ . filter ( ( id ) => id ) ;
3
9
4
10
export default {
5
11
name : "topic-thumbnails-init" ,
@@ -11,13 +17,27 @@ export default {
11
17
const site = api . container . lookup ( "site:main" ) ;
12
18
13
19
api . modifyClass ( "component:topic-list-item" , {
14
- @discourseComputed
15
- expandPinned ( ) {
16
- const shouldOverride = site . mobileView
20
+ excerptsRouter : service ( "router" ) ,
21
+
22
+ @discourseComputed (
23
+ "excerptsRouter.currentRouteName" ,
24
+ "excerptsRouter.currentRoute.attributes.category.id"
25
+ )
26
+ excerptsViewingCategoryId ( currentRouteName , categoryId ) {
27
+ if ( ! currentRouteName . match ( / ^ d i s c o v e r y \. / ) ) return ;
28
+ return categoryId ;
29
+ } ,
30
+
31
+ @discourseComputed ( "excerptsViewingCategoryId" )
32
+ expandPinned ( viewingCategory ) {
33
+ const overrideInCategory =
34
+ enabledCategories . length === 0 ||
35
+ enabledCategories . includes ( viewingCategory ) ;
36
+ const overrideOnDevice = site . mobileView
17
37
? settings . show_excerpts_mobile
18
38
: settings . show_excerpts_desktop ;
19
39
20
- return shouldOverride ? true : this . _super ( ) ;
40
+ return overrideInCategory && overrideOnDevice ? true : this . _super ( ) ;
21
41
} ,
22
42
} ) ;
23
43
} ,
0 commit comments