Fix community creator search and avatars
This commit is contained in:
1 parent
d3b1d01058
commit
863cf3e0ef
8 files changed
+84
-16
No files matched your search
@@ -35,6 +35,38 @@
|
||||
avatar.title = profile.displayName || profile.user?.userName || "Profile";
|
||||
}
|
||||
|
||||
function wireTopbarSearch() {
|
||||
const input = document.getElementById("topbarSearchInput");
|
||||
if (!input || input.dataset.searchReady === "true") return;
|
||||
|
||||
input.dataset.searchReady = "true";
|
||||
const params = new URLSearchParams(location.search);
|
||||
if (location.pathname.includes("community") && params.has("search")) {
|
||||
input.value = params.get("search") || "";
|
||||
}
|
||||
|
||||
let searchTimeout;
|
||||
input.addEventListener("input", () => {
|
||||
if (!location.pathname.includes("community")) return;
|
||||
|
||||
clearTimeout(searchTimeout);
|
||||
searchTimeout = setTimeout(() => {
|
||||
if (typeof window.applyCreatorSearch === "function") {
|
||||
window.applyCreatorSearch(input.value);
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
|
||||
input.addEventListener("keydown", (event) => {
|
||||
if (event.key !== "Enter") return;
|
||||
|
||||
const search = input.value.trim();
|
||||
location.href = search
|
||||
? `/community?search=${encodeURIComponent(search)}`
|
||||
: "/community";
|
||||
});
|
||||
}
|
||||
|
||||
async function hydrateTopbarProfile() {
|
||||
try {
|
||||
const profile = currentProfile || (await loadCurrentProfile());
|
||||
@@ -56,6 +88,7 @@
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
if (document.getElementById("topbarAvatar")) hydrateTopbarProfile();
|
||||
wireTopbarSearch();
|
||||
});
|
||||
|
||||
if (document.body) {
|
||||
|
||||
Reference in new issue
Block a user