DEV: Replace without usage and update deprecation handling (#34971)

Refactor `recentSearches` logic in `search.js` to replace the deprecated
`without` with a `filter` function. Update deprecation workflow to log
usages of the `discourse.native-array-extensions.without` method.
This commit is contained in:
Sérgio Saquetim
2025-09-24 20:11:48 -03:00
committed by GitHub
parent a8d4d47265
commit 8624dabc4b
2 changed files with 5 additions and 1 deletions
@@ -258,6 +258,10 @@ const DeprecationWorkflow = new DiscourseDeprecationWorkflow([
handler: "log",
matchId: "discourse.native-array-extensions.findBy",
},
{
handler: "log",
matchId: "discourse.native-array-extensions.without",
},
{
handler: ["silence", "counter"],
matchId: /^discourse\.native-array-extensions\..+$/,
@@ -272,7 +272,7 @@ export function updateRecentSearches(currentUser, term) {
let recentSearches = Object.assign(currentUser.recent_searches || []);
if (recentSearches.includes(term)) {
recentSearches = recentSearches.without(term);
recentSearches = recentSearches.filter((item) => item !== term);
} else if (recentSearches.length === MAX_RECENT_SEARCHES) {
recentSearches.popObject();
}