mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
* fix(message-list): rebuild virtual window when scroll leaves the rendered range Scroll-driven renderWindow calls previously never rebuilt the DOM, so scrolling past the overscan showed only spacer blank space until an unrelated data change forced a full re-render. The window now rebuilds whenever the computed visible range is not fully contained in the rendered one, keeping the no-op (and the existing rebuild rate limiter) for ranges that are already rendered. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(messages): refetch channel tail when revisiting a previously loaded channel The server only delivers live message broadcasts for the focused channel, so a channel's loaded window stops updating once the user switches away. Switching channels now drops the left channel's loaded flag so the next visit refetches the live tail, while keeping the old rows rendered until the refetch merges in (pending/failed rows are preserved). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(channel-sidebar): assign distinct slots when reordering channels with tied positions Categories whose channels share a position value (the server does not enforce uniqueness, and new channels default to position 0) previously produced an empty or partial reorder on drop, leaving the final order ambiguous. Tied slots are now nudged into a strictly increasing sequence before being reassigned, while already-distinct groups keep their range. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(embeds): keep the link-preview abort timer armed until the body is read The link-preview fetch previously cleared its 5 s abort timer as soon as response headers arrived, so reading the response body was unbounded in time and size. The timer is now cleared in a finally after the body read, so the timeout covers the whole request and the 50 KB parse cap applies as documented. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(message-list): anchor scroll-to-bottom and jump-to-present controls outside the scroller The two floating controls were appended inside the overflow scroller, so they were part of its scrollable overflow and translated away with the content whenever the user scrolled up — precisely when they become visible. They now anchor to a position:relative frame that wraps the scroller, keeping them pinned to the viewport edge. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(voice): reset the pinned input device before cycling the mic to default Selecting the default microphone (or losing the selected one to a hot unplug) only muted and unmuted the existing track, which kept capturing from the previously pinned device. The shared cycle now resets the capture device to the system default first so both paths actually reach it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(voice): re-check supersession after camera publish before announcing camera on A camera disable that completes while the enable's publishTrack call is still in flight now causes the enable to unpublish and stop its track and skip the enabled announcement, so the server's last word matches the local state instead of reporting a stopped camera as on. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(voice): re-check supersession across the screenshare publish loop A screenshare disable that completes while a publish in the enable loop is still in flight now stops the loop before the remaining tracks are published; the enable attempt unpublishes and stops all of its tracks and skips the enabled announcement, so tracks held only by that attempt are released and the server's last word matches the local state. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(sidebar): rethrow channel modal API failures so modals can recover The create/edit/delete channel callbacks caught API errors and only showed a toast, so the awaiting modal never saw the failure and left its submit button disabled with the in-flight label. The callbacks now rethrow after toasting, letting each modal re-enable its button and render its inline error so the user can retry without losing the form. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(messages): carry pending and failed rows across the prepend trim When a scroll-up page pushed a channel past the per-channel cap, prependMessages trimmed the tail wholesale, deleting pending/failed optimistic rows that hold the only copy of the user's composed text. The trim now carries those rows across, matching the other window-replacing writers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(channel-sidebar): re-resolve the drop container when the sidebar re-renders mid-drag A store-driven sidebar re-render while a drag is in flight rebuilds the channel rows, detaching the container captured at mousedown; detached rows report all-zero rects, so the drop and the hover indicator could never resolve. The global handlers now re-target the live row, its container, and the store's current group snapshot before hit-testing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(delete-channel-modal): re-arm the confirm button when a delete fails The confirm button was only restored from the catch block, so a caller that handled the failure itself and resolved left the button disabled on 'Deleting...' with no way to retry. Restoration now runs in a finally block whenever the modal is still open, regardless of how the callback settled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(dm-sidebar): keep the presence dot when an avatar image loads The avatar swap cleared the whole circle before inserting the fetched image, which also removed the online/idle/dnd/offline dot on 1:1 rows. The initial now lives in its own node and only that node is replaced, so the presence dot survives the image arriving. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(formatting): compute the yesterday boundary from the calendar date The relative-day fence post was derived by subtracting a fixed 24 hours from local midnight, which lands inside the wrong calendar day when a DST transition makes the local day 23 or 25 hours long. It is now built from the calendar date directly, so hover and expanded message timestamps keep the correct Yesterday label around transitions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU * fix(message-input): keep the empty-edit guard active while attachments are queued Edits are text-only, so a queued attachment no longer bypasses the empty-content guard while editing. Submitting an edit whose text was cleared is now refused with edit mode intact, matching the behavior when nothing is attached. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0188TWF92r4aNM7T6eiiD7sU --------- Co-authored-by: Claude <noreply@anthropic.com>
159 lines
5.0 KiB
TypeScript
159 lines
5.0 KiB
TypeScript
/**
|
|
* DeleteChannelModal — confirmation dialog for deleting a channel.
|
|
* Shows channel name and requires explicit confirmation.
|
|
*/
|
|
|
|
import { applyDialogSemantics, focusDialog, trapFocus } from "@lib/a11y";
|
|
import { createElement, setText, appendChildren } from "@lib/dom";
|
|
import { createIcon } from "@lib/icons";
|
|
import type { MountableComponent } from "@lib/safe-render";
|
|
|
|
export interface DeleteChannelModalOptions {
|
|
readonly channelId: number;
|
|
readonly channelName: string;
|
|
readonly onConfirm: () => Promise<void>;
|
|
readonly onClose: () => void;
|
|
}
|
|
|
|
export function createDeleteChannelModal(options: DeleteChannelModalOptions): MountableComponent {
|
|
const { channelName, onConfirm, onClose } = options;
|
|
const ac = new AbortController();
|
|
let overlay: HTMLDivElement | null = null;
|
|
let restoreFocus: (() => void) | null = null;
|
|
|
|
function mount(container: Element): void {
|
|
overlay = createElement("div", {
|
|
class: "modal-overlay visible",
|
|
"data-testid": "delete-channel-modal",
|
|
});
|
|
|
|
const modal = createElement("div", { class: "modal" });
|
|
applyDialogSemantics(modal, { labelledBy: "delete-channel-title" });
|
|
trapFocus(modal, ac.signal);
|
|
|
|
// Header
|
|
const header = createElement("div", { class: "modal-header" });
|
|
const title = createElement("h3", { id: "delete-channel-title" }, "Delete Channel");
|
|
// Icon-only button: without a label a screen reader announces just "button".
|
|
const closeBtn = createElement("button", {
|
|
class: "modal-close",
|
|
type: "button",
|
|
"aria-label": "Close",
|
|
});
|
|
closeBtn.textContent = "";
|
|
closeBtn.appendChild(createIcon("x", 14));
|
|
closeBtn.addEventListener("click", onClose, { signal: ac.signal });
|
|
appendChildren(header, title, closeBtn);
|
|
|
|
// Body
|
|
const body = createElement("div", { class: "modal-body" });
|
|
const warning = createElement("div", { class: "modal-danger-text" });
|
|
appendChildren(
|
|
warning,
|
|
"Are you sure you want to delete ",
|
|
createElement("strong", {}, `#${channelName}`),
|
|
"? This action cannot be undone and all messages in this channel will be lost.",
|
|
);
|
|
body.appendChild(warning);
|
|
|
|
// Error display
|
|
const errorEl = createElement("div", {
|
|
style: "color: var(--red); font-size: 13px; display: none; margin-top: 8px;",
|
|
"data-testid": "delete-channel-error",
|
|
});
|
|
body.appendChild(errorEl);
|
|
|
|
// Footer
|
|
const footer = createElement("div", { class: "modal-footer" });
|
|
const cancelBtn = createElement(
|
|
"button",
|
|
{ class: "btn-modal-cancel", type: "button" },
|
|
"Cancel",
|
|
);
|
|
cancelBtn.addEventListener("click", onClose, { signal: ac.signal });
|
|
|
|
const deleteBtn = createElement(
|
|
"button",
|
|
{
|
|
class: "btn-danger",
|
|
type: "button",
|
|
"data-testid": "delete-channel-confirm",
|
|
},
|
|
"Delete Channel",
|
|
);
|
|
|
|
deleteBtn.addEventListener(
|
|
"click",
|
|
async () => {
|
|
deleteBtn.setAttribute("disabled", "true");
|
|
setText(deleteBtn, "Deleting...");
|
|
|
|
try {
|
|
await onConfirm();
|
|
} catch (err) {
|
|
errorEl.style.display = "block";
|
|
setText(errorEl, err instanceof Error ? err.message : "Failed to delete channel");
|
|
} finally {
|
|
// Re-arm the button whether the caller rejected or handled the
|
|
// failure itself and resolved. A successful delete destroys the
|
|
// modal inside onConfirm, so the overlay is gone and this no-ops.
|
|
if (overlay?.isConnected === true) {
|
|
deleteBtn.removeAttribute("disabled");
|
|
setText(deleteBtn, "Delete Channel");
|
|
}
|
|
}
|
|
},
|
|
{ signal: ac.signal },
|
|
);
|
|
|
|
appendChildren(footer, cancelBtn, deleteBtn);
|
|
appendChildren(modal, header, body, footer);
|
|
overlay.appendChild(modal);
|
|
|
|
// Close on backdrop click
|
|
overlay.addEventListener(
|
|
"click",
|
|
(e) => {
|
|
if (e.target === overlay) {
|
|
onClose();
|
|
}
|
|
},
|
|
{ signal: ac.signal },
|
|
);
|
|
|
|
// Escape cancels — it must never stand in for the destructive confirm.
|
|
// Document-level so it works wherever focus sits; guarded on the overlay
|
|
// still being attached because the listener lives until destroy() aborts it.
|
|
document.addEventListener(
|
|
"keydown",
|
|
(e: KeyboardEvent) => {
|
|
if (e.key === "Escape" && overlay?.isConnected === true) {
|
|
onClose();
|
|
}
|
|
},
|
|
{ signal: ac.signal },
|
|
);
|
|
|
|
container.appendChild(overlay);
|
|
|
|
// Move focus in (lands on the header's close button, safely away from the
|
|
// destructive confirm) and remember the opener for destroy() to restore.
|
|
restoreFocus = focusDialog(modal);
|
|
}
|
|
|
|
function destroy(): void {
|
|
ac.abort();
|
|
if (overlay !== null) {
|
|
overlay.remove();
|
|
overlay = null;
|
|
}
|
|
// Every close path (X, Cancel, backdrop, Escape) funnels through the
|
|
// caller's onClose, which calls destroy() — the single place focus
|
|
// returns to the opener.
|
|
restoreFocus?.();
|
|
restoreFocus = null;
|
|
}
|
|
|
|
return { mount, destroy };
|
|
}
|