Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions lib/public/modules/emoji-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,24 @@ export function buildEmojiPicker(opts) {
}

function doUpload() {
if (!pendingFile) return;
// Both early returns below used to be silent — the control (rendered
// by showSlugConfirm) is only reachable once a file is already
// selected, but a defensive check that fires with zero user feedback
// is indistinguishable from the picker doing nothing at all. Surface
// both via the same toast used for server-side upload failures (line
// ~285) so "nothing happened" never happens silently again.
if (!pendingFile) {
showToast("Couldn't add custom emoji", "warn");
return;
}
var slug = slugInput.value.trim().toLowerCase()
.replace(/[^a-z0-9_-]+/g, "-")
.replace(/^-+|-+$/g, "")
.slice(0, 64);
if (!slug || !/^[a-z0-9_-]{1,64}$/.test(slug)) return;
if (!slug || !/^[a-z0-9_-]{1,64}$/.test(slug)) {
showToast("Enter a valid name", "warn");
return;
}

// Check for duplicate in the already-fetched list
var existing = customList || [];
Expand All @@ -274,9 +286,14 @@ export function buildEmojiPicker(opts) {
showToast(result.error || "Upload failed", "warn");
return;
}
// Refresh the custom grid after upload
// Refresh the custom grid after upload. buildCustomPanel() already
// repaints the grid it just (re)built via its own fresh
// renderCustomGrid closure (see below) — calling the outer
// renderCustomGrid here re-renders the ORPHANED grid captured by
// this closure at the time doUpload's panel was built, which is
// detached from the DOM the moment buildCustomPanel() runs again.
customList = null;
fetchCustomList(function () { buildCustomPanel(); renderCustomGrid(); });
fetchCustomList(function () { buildCustomPanel(); });
});
}

Expand Down Expand Up @@ -352,8 +369,12 @@ export function buildEmojiPicker(opts) {
delBtn.addEventListener("click", function (e) {
e.stopPropagation();
deleteCustomIcon(entry.slug).then(function () {
// Same stale-closure hazard as the upload success path above:
// buildCustomPanel() already repaints via its own fresh
// renderCustomGrid; the closure captured here is orphaned
// once buildCustomPanel() rebuilds the panel.
customList = null;
fetchCustomList(function () { buildCustomPanel(); renderCustomGrid(); });
fetchCustomList(function () { buildCustomPanel(); });
});
});
tile.appendChild(delBtn);
Expand Down
Loading