@@ -4,7 +4,6 @@ import { htmlSafe } from "@ember/template";
4
4
import { isEmpty } from "@ember/utils" ;
5
5
import { hbs } from "ember-cli-htmlbars" ;
6
6
import { h } from "virtual-dom" ;
7
- import SearchAdvancedOptions from "discourse/components/search-advanced-options" ;
8
7
import { renderAvatar } from "discourse/helpers/user-avatar" ;
9
8
import { withPluginApi } from "discourse/lib/plugin-api" ;
10
9
import { registerTopicFooterDropdown } from "discourse/lib/register-topic-footer-dropdown" ;
@@ -816,35 +815,39 @@ export default {
816
815
return ;
817
816
}
818
817
819
- const currentUser = container . lookup ( "service:current-user" ) ;
820
- if ( currentUser ?. can_assign ) {
821
- SearchAdvancedOptions . reopen ( {
822
- updateSearchTermForAssignedUsername ( ) {
823
- const match = this . filterBlocks ( REGEXP_USERNAME_PREFIX ) ;
824
- const userFilter = this . searchedTerms ?. assigned ;
825
- let searchTerm = this . searchTerm || "" ;
826
- let keyword = "assigned" ;
827
-
828
- if ( userFilter ?. length !== 0 ) {
829
- if ( match . length !== 0 ) {
830
- searchTerm = searchTerm . replace (
831
- match [ 0 ] ,
832
- `${ keyword } :${ userFilter } `
833
- ) ;
834
- } else {
835
- searchTerm += ` ${ keyword } :${ userFilter } ` ;
818
+ withPluginApi ( "1.34.0" , ( api ) => {
819
+ const currentUser = container . lookup ( "service:current-user" ) ;
820
+ if ( currentUser ?. can_assign ) {
821
+ api . modifyClass (
822
+ "component:search-advanced-options" ,
823
+ ( Superclass ) =>
824
+ class extends Superclass {
825
+ updateSearchTermForAssignedUsername ( ) {
826
+ const match = this . filterBlocks ( REGEXP_USERNAME_PREFIX ) ;
827
+ const userFilter = this . searchedTerms ?. assigned ;
828
+ let searchTerm = this . searchTerm || "" ;
829
+ let keyword = "assigned" ;
830
+
831
+ if ( userFilter ?. length !== 0 ) {
832
+ if ( match . length !== 0 ) {
833
+ searchTerm = searchTerm . replace (
834
+ match [ 0 ] ,
835
+ `${ keyword } :${ userFilter } `
836
+ ) ;
837
+ } else {
838
+ searchTerm += ` ${ keyword } :${ userFilter } ` ;
839
+ }
840
+
841
+ this . _updateSearchTerm ( searchTerm ) ;
842
+ } else if ( match . length !== 0 ) {
843
+ searchTerm = searchTerm . replace ( match [ 0 ] , "" ) ;
844
+ this . _updateSearchTerm ( searchTerm ) ;
845
+ }
846
+ }
836
847
}
848
+ ) ;
849
+ }
837
850
838
- this . _updateSearchTerm ( searchTerm ) ;
839
- } else if ( match . length !== 0 ) {
840
- searchTerm = searchTerm . replace ( match [ 0 ] , "" ) ;
841
- this . _updateSearchTerm ( searchTerm ) ;
842
- }
843
- } ,
844
- } ) ;
845
- }
846
-
847
- withPluginApi ( "1.34.0" , ( api ) => {
848
851
extendTopicModel ( api ) ;
849
852
initialize ( api ) ;
850
853
registerTopicFooterButtons ( api ) ;
0 commit comments