File tree Expand file tree Collapse file tree 1 file changed +26
-8
lines changed
assets/javascripts/discourse/initializers Expand file tree Collapse file tree 1 file changed +26
-8
lines changed Original file line number Diff line number Diff line change 1
1
import TopicListItem from "discourse/components/topic-list-item" ;
2
+ import { withPluginApi } from "discourse/lib/plugin-api" ;
3
+ import { withSilencedDeprecations } from "discourse-common/lib/deprecated" ;
2
4
import discourseComputed from "discourse-common/utils/decorators" ;
3
5
4
6
export default {
5
7
name : "add-topic-list-class" ,
8
+
6
9
initialize ( ) {
7
- TopicListItem . reopen ( {
8
- @discourseComputed ( )
9
- unboundClassNames ( ) {
10
- let classList = this . _super ( ...arguments ) ;
11
- if ( this . topic . has_accepted_answer ) {
12
- classList += " status-solved" ;
10
+ withPluginApi ( "1.39.0" , ( api ) => {
11
+ // TODO: cvx - remove after the glimmer topic list transition
12
+ withSilencedDeprecations ( "discourse.hbr-topic-list-overrides" , ( ) => {
13
+ TopicListItem . reopen ( {
14
+ @discourseComputed ( )
15
+ unboundClassNames ( ) {
16
+ let classList = this . _super ( ...arguments ) ;
17
+ if ( this . topic . has_accepted_answer ) {
18
+ classList += " status-solved" ;
19
+ }
20
+ return classList ;
21
+ } ,
22
+ } ) ;
23
+ } ) ;
24
+
25
+ api . registerValueTransformer (
26
+ "topic-list-item-class" ,
27
+ ( { value, context } ) => {
28
+ if ( context . topic . get ( "has_accepted_answer" ) ) {
29
+ value . push ( "status-solved" ) ;
30
+ }
31
+ return value ;
13
32
}
14
- return classList ;
15
- } ,
33
+ ) ;
16
34
} ) ;
17
35
} ,
18
36
} ;
You can’t perform that action at this time.
0 commit comments