Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit 3f3b602

Browse files
authored
DEV: Use modifyClass instead of reopen (#615)
1 parent 8c52b9a commit 3f3b602

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

assets/javascripts/discourse/initializers/extend-for-assigns.js

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { htmlSafe } from "@ember/template";
44
import { isEmpty } from "@ember/utils";
55
import { hbs } from "ember-cli-htmlbars";
66
import { h } from "virtual-dom";
7-
import SearchAdvancedOptions from "discourse/components/search-advanced-options";
87
import { renderAvatar } from "discourse/helpers/user-avatar";
98
import { withPluginApi } from "discourse/lib/plugin-api";
109
import { 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

Comments
 (0)