@@ -4,7 +4,6 @@ import { htmlSafe } from "@ember/template";
44import { isEmpty } from "@ember/utils" ;
55import { hbs } from "ember-cli-htmlbars" ;
66import { h } from "virtual-dom" ;
7- import SearchAdvancedOptions from "discourse/components/search-advanced-options" ;
87import { renderAvatar } from "discourse/helpers/user-avatar" ;
98import { withPluginApi } from "discourse/lib/plugin-api" ;
109import { registerTopicFooterDropdown } from "discourse/lib/register-topic-footer-dropdown" ;
@@ -816,35 +815,39 @@ export default {
816815 return ;
817816 }
818817
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+ }
836847 }
848+ ) ;
849+ }
837850
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 ) => {
848851 extendTopicModel ( api ) ;
849852 initialize ( api ) ;
850853 registerTopicFooterButtons ( api ) ;
0 commit comments