@alexsun-top/opencode-chat-room 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/package.json +6 -3
- package/server/assets/chat/admin-badge.js +1 -1
- package/server/assets/chat/admin.js +12 -9
- package/server/assets/chat/announcements.js +9 -2
- package/server/assets/chat/attachment-store.js +15 -6
- package/server/assets/chat/attachments.js +46 -31
- package/server/assets/chat/chat-background.js +8 -14
- package/server/assets/chat/clipboard.js +2 -1
- package/server/assets/chat/confirm-dialog.js +3 -3
- package/server/assets/chat/copy-action.js +0 -1
- package/server/assets/chat/diagram-viewer.js +7 -9
- package/server/assets/chat/doc-preview.js +18 -11
- package/server/assets/chat/editor.js +80 -58
- package/server/assets/chat/events.js +43 -30
- package/server/assets/chat/files.js +41 -13
- package/server/assets/chat/history-loader.js +5 -3
- package/server/assets/chat/image-zoom.js +21 -17
- package/server/assets/chat/install-prompt.js +10 -9
- package/server/assets/chat/integration-account-schema.js +5 -3
- package/server/assets/chat/integration-editor.js +0 -2
- package/server/assets/chat/integration-values.js +17 -11
- package/server/assets/chat/integrations.js +137 -80
- package/server/assets/chat/join-requests.js +19 -12
- package/server/assets/chat/markdown-footnotes.js +0 -1
- package/server/assets/chat/markdown.js +43 -34
- package/server/assets/chat/members.js +45 -22
- package/server/assets/chat/mentions.js +31 -7
- package/server/assets/chat/message-cache.js +1 -1
- package/server/assets/chat/message-polling.js +38 -19
- package/server/assets/chat/message-window.js +9 -5
- package/server/assets/chat/messages.js +53 -43
- package/server/assets/chat/palette.js +40 -26
- package/server/assets/chat/panels.js +0 -1
- package/server/assets/chat/pwa.js +5 -4
- package/server/assets/chat/questions.js +22 -20
- package/server/assets/chat/recall.js +39 -21
- package/server/assets/chat/receipts.js +9 -7
- package/server/assets/chat/reminders.js +22 -8
- package/server/assets/chat/replies.js +28 -12
- package/server/assets/chat/room-list.js +2 -2
- package/server/assets/chat/room-watcher.js +8 -4
- package/server/assets/chat/rooms.js +44 -36
- package/server/assets/chat/search.js +8 -6
- package/server/assets/chat/settings.js +12 -11
- package/server/assets/chat/shiki.js +1 -1
- package/server/assets/chat/shortcuts.js +0 -2
- package/server/assets/chat/side-pane.js +3 -2
- package/server/assets/chat/state.js +35 -26
- package/server/assets/chat/system-events.js +4 -4
- package/server/assets/chat/task-form.js +5 -5
- package/server/assets/chat/task-row.js +1 -1
- package/server/assets/chat/tasks.js +37 -25
- package/server/chat.html +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
- Keep the web client and service worker sources in TypeScript under `server/chat-src` and `server/sw.ts`, built by `tsc` into the existing `server/assets/chat/*.js` and `server/sw.js` URLs.
|
|
5
|
+
- Keep the web client and service worker sources in TypeScript under `server/chat-src` and `server/sw.ts`, built by `tsc` into the existing `server/assets/chat/*.js` and `server/sw.js` URLs. All 67 sources now pass strict TypeScript checks with no `any`, `@ts-nocheck`, or other suppressions; the published package and image still contain only generated JavaScript, and two builds are byte-for-byte reproducible.
|
|
6
|
+
- When the app opens offline without a restored session, the cached shell now shows a Settings button next to Retry, so local appearance, language, and connection settings stay reachable without the server. Room data still requires a connection.
|
|
6
7
|
- Serve the PWA shell and static assets from the service worker cache first, so opening the app no longer re-downloads every precached file from the server. Install reports downloading, ready with the number of optional cache gaps, or failed; a missing shell or chat entry module fails the install, while a missing optional asset becomes a runtime miss. The update prompt appears only for a waiting worker and never reloads on its own.
|
|
7
8
|
- Add an optional PostgreSQL backend to Channel D. Set `CHAT_ROOM_DATABASE_URL` to share the same `ChannelState` implementation on PostgreSQL 16 with `pg_advisory_xact_lock` serialization, or leave it unset for SQLite. `channeld migrate --state <sqlite> --to-postgres <url>` copies events, deliveries, receipts, and echoes with primary keys, ingress sequences, echo timestamps, per-table counts, and non-empty target refusal; removing the variable rolls back without touching SQLite. Single-instance only.
|
|
8
9
|
- Recover stale Channel D in-flight deliveries by adapter capability: adapters declaring `send.idempotency = "persistent_delivery_key"` return them to `pending` with the original delivery key, while every other adapter leaves them `unknown` and never resends automatically. Add `channeld retry --config <path> --delivery <id> --force` to move one `unknown` delivery back to `pending`; it rejects other states and a removed account, does not start the host, and `--force` acknowledges that a non-idempotent adapter resends from the first message part, so a duplicate is possible.
|
|
9
10
|
- Add a standalone Telegram Bot API adapter under `plugins/telegram`: long polling, text, image, and file delivery, inbound downloads with deduplication, 429 rate-limit mapping, and clean shutdown. Outbound text longer than Telegram's 4096-character limit is split in order without breaking a character, and a retried delivery resumes at the first unsent part within the same adapter process (a restart can repeat the first parts because Telegram has no idempotency key). It is one self-contained TypeScript file with no relative imports; real credentials and network are not exercised by the repository tests.
|
|
11
|
+
- Add seven standalone channel adapters covering ten platforms. Unit 1: Feishu (real-account verified, inbound and outbound, text/images/files). Unit 2: Telegram (protocol-tested, inbound and outbound text/images/files). Unit 3: Matrix (`/sync` inbound and text outbound). Unit 4: Slack (history polling inbound and text outbound). Unit 5: Discord (message polling inbound and text outbound, 2000-character chunking). Unit 6: Email (SMTP outbound with attachments; plaintext SMTP is refused unless `EMAIL_SMTP_ALLOW_PLAINTEXT=1` is set for a trusted relay). Unit 7: one webhook adapter for Microsoft Teams, Google Chat, WeCom, and DingTalk (outbound text, platform selected by account `platform`). Except for Feishu, protocol tests use local fake servers only; real credentials and production platform behavior are not exercised by the repository tests. The service still ships no built-in adapter; download the files from the GitHub Release and upload them in Platform integrations.
|
|
10
12
|
- Center the date on short system notice pills, keep long notice cards top-aligned, and treat the notice glyph as decoration instead of a button: no border, background, or pointer target. The announcements list and its status line reserve height so first load and refresh no longer jitter.
|
|
11
13
|
- Rename room reminder actions from pause/resume to disable/enable, gray out disabled reminders while keeping their actions usable, and reserve the list and status height so loading and refresh no longer shift the panel.
|
|
12
14
|
- Highlight TypeScript and JavaScript previews with Monaco's language definitions without starting a language-service worker. The editor keeps its read-only context menu, find, copy, download, and folding behavior; semantic diagnostics remain out of scope because the feature-register type graph breaks `tsc`.
|
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ When upgrading, quit OpenCode first or run `opencode plugin add @alexsun-top/ope
|
|
|
26
26
|
On a machine reachable by the other devices:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.8.
|
|
29
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.8.4 -- opencode-chat-room --host 0.0.0.0 --port 4399 --token 'your-password'
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
The server runs on Node.js 24.2+, Deno 2, or Bun. On each OpenCode machine, set the address and the same token, then start OpenCode:
|
|
@@ -46,7 +46,7 @@ Open `http://SERVER_IP:4399/chat` and enter the token in Settings. Instead of en
|
|
|
46
46
|
```bash
|
|
47
47
|
docker run --rm -p 4399:4399 -v chat-room-data:/data \
|
|
48
48
|
-e CHAT_ROOM_SERVER_TOKEN='your-password' \
|
|
49
|
-
ghcr.io/agentsyaml/opencode-chat-room:v0.8.
|
|
49
|
+
ghcr.io/agentsyaml/opencode-chat-room:v0.8.4
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
Rooms and files live in the `/data` volume; keep it across upgrades. A host bind mount must be writable by uid `10001`.
|
|
@@ -60,12 +60,12 @@ For Docker Compose, PostgreSQL state, S3-compatible storage, and all environment
|
|
|
60
60
|
- **Files:** attach, drag, or paste up to 500 MiB; preview images, media, Markdown, text, code, PDF, Word, Excel, and PowerPoint; open any preview full screen; download or delete.
|
|
61
61
|
- **Tasks and reminders:** track tasks in a side pane or modal; schedule one-time or cron reminders.
|
|
62
62
|
- **Search and shortcuts:** Alt+Space or Ctrl+P searches messages; `/` filters commands. More shortcuts are in Settings.
|
|
63
|
-
- **Terminal:** run `bunx --package @alexsun-top/opencode-chat-room@0.8.
|
|
63
|
+
- **Terminal:** run `bunx --package @alexsun-top/opencode-chat-room@0.8.4 opencode-chat-room cli` against the same server. Only the CLI loads OpenTUI.
|
|
64
64
|
- **Web app:** installs to a phone home screen and starts offline from cache; chat data is never cached.
|
|
65
65
|
|
|
66
66
|
## Optional services
|
|
67
67
|
|
|
68
|
-
Channel D is an optional forwarding sidecar for sending selected room messages to external platforms. It ships with no built-in adapter: download an adapter from the GitHub Release, upload it in Settings → Platform integrations, then add an account and a rule. Forwarding is explicit (`GET /rooms/:id/forward-targets`, `POST /rooms/:id/forward`); ordinary messages are never relayed automatically. See the [Channel D reference](docs/reference.en.md).
|
|
68
|
+
Channel D is an optional forwarding sidecar for sending selected room messages to external platforms. It ships with no built-in adapter: download an adapter from the GitHub Release, upload it in Settings → Platform integrations, then add an account and a rule. The release covers ten platforms — Feishu, Telegram, Matrix, Slack, Discord, Email, Microsoft Teams, Google Chat, WeCom, and DingTalk; the last four share one webhook adapter. Feishu is verified against a real account, while the others are protocol-tested until real credentials are supplied. Forwarding is explicit (`GET /rooms/:id/forward-targets`, `POST /rooms/:id/forward`); ordinary messages are never relayed automatically. See the [Channel D reference](docs/reference.en.md).
|
|
69
69
|
|
|
70
70
|
S3-compatible storage and PostgreSQL state are configured through environment variables. PostgreSQL supports multiple server instances; Channel D keeps its own single-host state. Both are covered in the [technical reference](docs/reference.en.md).
|
|
71
71
|
|
package/README.zh-CN.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
在一台其他设备可以访问的机器上运行:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.8.
|
|
29
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.8.4 -- opencode-chat-room --host 0.0.0.0 --port 4399 --token 'your-password'
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
服务端支持 Node.js 24.2+、Deno 2 或 Bun。在每台 OpenCode 机器上设置地址和同一个 token,然后启动 OpenCode:
|
|
@@ -46,7 +46,7 @@ opencode
|
|
|
46
46
|
```bash
|
|
47
47
|
docker run --rm -p 4399:4399 -v chat-room-data:/data \
|
|
48
48
|
-e CHAT_ROOM_SERVER_TOKEN='your-password' \
|
|
49
|
-
ghcr.io/agentsyaml/opencode-chat-room:v0.8.
|
|
49
|
+
ghcr.io/agentsyaml/opencode-chat-room:v0.8.4
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
房间和文件保存在 `/data` 卷里,升级时不要删除。宿主目录挂载必须允许 uid `10001` 写入。
|
|
@@ -60,12 +60,12 @@ Docker Compose、PostgreSQL 状态、S3 兼容存储和全部环境变量见[部
|
|
|
60
60
|
- **文件:** 添加、拖入或粘贴最大 500 MiB 的文件;预览图片、媒体、Markdown、文本、代码、PDF、Word、Excel 和 PowerPoint;全屏查看预览;下载或删除。
|
|
61
61
|
- **任务和提醒:** 在侧栏或弹窗里跟踪任务;设置一次性或 cron 提醒。
|
|
62
62
|
- **搜索和快捷键:** Alt+Space 或 Ctrl+P 搜索消息,`/` 过滤命令;更多快捷键在设置里。
|
|
63
|
-
- **终端:** 运行 `bunx --package @alexsun-top/opencode-chat-room@0.8.
|
|
63
|
+
- **终端:** 运行 `bunx --package @alexsun-top/opencode-chat-room@0.8.4 opencode-chat-room cli` 连接同一个服务端。只有 CLI 会加载 OpenTUI。
|
|
64
64
|
- **网页应用:** 可安装到手机主屏,离线时从缓存启动;聊天数据不会缓存。
|
|
65
65
|
|
|
66
66
|
## 可选服务
|
|
67
67
|
|
|
68
|
-
Channel D 是可选的转发侧车,把选定的房间消息发到外部平台。它不内置任何 adapter:从 GitHub Release 下载 adapter,在“设置 →
|
|
68
|
+
Channel D 是可选的转发侧车,把选定的房间消息发到外部平台。它不内置任何 adapter:从 GitHub Release 下载 adapter,在“设置 → 平台集成”上传,再添加账号和规则。Release 覆盖十个平台——飞书、Telegram、Matrix、Slack、Discord、Email、Microsoft Teams、Google Chat、WeCom 和钉钉;后四个共用一份 webhook adapter。飞书已用真实账号验证,其余在有真实凭据前只算协议测试通过。转发是显式操作(`GET /rooms/:id/forward-targets`、`POST /rooms/:id/forward`),普通消息不会自动转发。见 [Channel D 参考](docs/reference.zh-CN.md)。
|
|
69
69
|
|
|
70
70
|
S3 兼容存储和 PostgreSQL 状态通过环境变量配置。PostgreSQL 支持多个服务端实例;Channel D 保持自己的单实例状态。两者都写在[技术参考](docs/reference.zh-CN.md)里。
|
|
71
71
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexsun-top/opencode-chat-room",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "A chat-room server, web client, terminal client, and OpenCode/Codex/dsh plugins.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -86,8 +86,11 @@
|
|
|
86
86
|
"server": "node cli.ts",
|
|
87
87
|
"server:bun": "bun cli.ts",
|
|
88
88
|
"server:deno": "deno run --allow-env --allow-read --allow-write --allow-net cli.ts",
|
|
89
|
-
"test": "bun run build:web && bun scripts/check-web-build.ts && bun scripts/check-web-types.ts && for file in src/tests/*.test.ts server/*.test.ts; do bun test \"$file\" || exit; done && bun test src/tui/test --isolate",
|
|
90
|
-
"
|
|
89
|
+
"test": "bun run build:web && bun scripts/check-web-build.ts && bun scripts/check-web-types.ts && for file in src/tests/*.test.ts server/*.test.ts; do bun test \"$file\" || exit; done && bun run test:plugins && bun test src/tui/test --isolate",
|
|
90
|
+
"test:plugins": "for dir in plugins/*/tests; do bun test \"$dir\" || exit; done",
|
|
91
|
+
"typecheck": "bun run build:web && tsc --noEmit && bun scripts/check-web-types.ts && bun run typecheck:web-strict && bun run typecheck:sw-strict",
|
|
92
|
+
"typecheck:web-strict": "tsc -p tsconfig.web.strict.json",
|
|
93
|
+
"typecheck:sw-strict": "tsc -p tsconfig.sw.strict.json"
|
|
91
94
|
},
|
|
92
95
|
"engines": {
|
|
93
96
|
"node": ">=24.2.0"
|
|
@@ -6,7 +6,7 @@ export function isAdminAgent(app, sessionID) {
|
|
|
6
6
|
// Browser sessions are people; the backend binds the real membership and re-checks it.
|
|
7
7
|
export function isRoomAdmin(app) {
|
|
8
8
|
const room = app.state.room;
|
|
9
|
-
return
|
|
9
|
+
return room !== null && (app.state.myName === room.ownerId || (room.adminIds ?? []).includes(app.state.myName));
|
|
10
10
|
}
|
|
11
11
|
// Human administrators may remove any non-owner member; the designated agent only ordinary members.
|
|
12
12
|
export function canRemoveMember(app, target, selfIsAgent, sessionID) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { LS } from "./state.js";
|
|
2
2
|
import { isRoomAdmin } from "./admin-badge.js";
|
|
3
|
+
const errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
3
4
|
// Owners and delegated humans manage settings; the agent designation comes from
|
|
4
5
|
// the room payload and room owners manage it here instead of an operator token.
|
|
5
6
|
export function initAdmin(app) {
|
|
6
|
-
|
|
7
|
+
// The chat shell owns these ids for the page lifetime.
|
|
8
|
+
const $ = (selector) => app.$(selector);
|
|
9
|
+
const dialog = $("#editRoomDialog");
|
|
7
10
|
let agents = [], people = [], generation = 0, agentsReady = false, rosterReady = false, opener = null;
|
|
8
11
|
const tabs = [...dialog.querySelectorAll('[role="tab"]')];
|
|
9
12
|
// One tab stop for the visible tabs; arrow keys move selection like a native tab widget.
|
|
@@ -12,7 +15,7 @@ export function initAdmin(app) {
|
|
|
12
15
|
const selected = tab.dataset.editRoomTab === name;
|
|
13
16
|
tab.setAttribute("aria-selected", String(selected));
|
|
14
17
|
tab.tabIndex = selected ? 0 : -1;
|
|
15
|
-
const panel = document.getElementById(tab.getAttribute("aria-controls"));
|
|
18
|
+
const panel = document.getElementById(tab.getAttribute("aria-controls") ?? "");
|
|
16
19
|
if (panel)
|
|
17
20
|
panel.hidden = !selected;
|
|
18
21
|
if (selected && focus)
|
|
@@ -20,7 +23,7 @@ export function initAdmin(app) {
|
|
|
20
23
|
}
|
|
21
24
|
};
|
|
22
25
|
const onTabKey = (event) => {
|
|
23
|
-
const items = tabs.filter((tab) => !tab.hidden), index = items.indexOf(event.target);
|
|
26
|
+
const items = tabs.filter((tab) => !tab.hidden), index = event.target instanceof HTMLElement ? items.indexOf(event.target) : -1;
|
|
24
27
|
if (index < 0)
|
|
25
28
|
return;
|
|
26
29
|
const step = event.key === "ArrowUp" || event.key === "ArrowLeft" ? -1 : event.key === "ArrowDown" || event.key === "ArrowRight" ? 1 : 0;
|
|
@@ -64,7 +67,7 @@ export function initAdmin(app) {
|
|
|
64
67
|
const select = $("#editRoomSuccessor");
|
|
65
68
|
const names = [...new Set(people.map((person) => person.name))].filter((name) => name !== room.ownerId);
|
|
66
69
|
select.replaceChildren(new Option(app.t("successorNone"), ""), ...names.map((name) => new Option(name, name)));
|
|
67
|
-
select.value = names.includes(room.successorId) ? room.successorId : "";
|
|
70
|
+
select.value = room.successorId && names.includes(room.successorId) ? room.successorId : "";
|
|
68
71
|
}
|
|
69
72
|
async function loadAgents(gen) {
|
|
70
73
|
const room = app.state.room;
|
|
@@ -81,7 +84,7 @@ export function initAdmin(app) {
|
|
|
81
84
|
.filter((agent) => agent.membershipID && (agent.protocol === "v1" || agent.protocol === "v2" || agent.receiverOwnerID || agent.host));
|
|
82
85
|
for (const agent of agents)
|
|
83
86
|
select.append(new Option(agent.name, agent.sessionID));
|
|
84
|
-
select.value = agents.some((agent) => agent.sessionID === room.adminSessionID) ? room.adminSessionID : "";
|
|
87
|
+
select.value = agents.some((agent) => agent.sessionID === room.adminSessionID) ? room.adminSessionID ?? "" : "";
|
|
85
88
|
people = Object.values(registry).filter(isPerson);
|
|
86
89
|
renderOwnerOptions(room);
|
|
87
90
|
renderAdminIds(room);
|
|
@@ -91,7 +94,7 @@ export function initAdmin(app) {
|
|
|
91
94
|
}
|
|
92
95
|
catch (error) {
|
|
93
96
|
if (gen === generation)
|
|
94
|
-
$("#editRoomStatus").textContent = error
|
|
97
|
+
$("#editRoomStatus").textContent = errorMessage(error);
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
function open() {
|
|
@@ -122,7 +125,7 @@ export function initAdmin(app) {
|
|
|
122
125
|
$("#editRoomName").focus();
|
|
123
126
|
void loadAgents(++generation);
|
|
124
127
|
}
|
|
125
|
-
const isOwner = () => Boolean(app.state.room) && app.state.myName === app.state.room
|
|
128
|
+
const isOwner = () => Boolean(app.state.room) && app.state.myName === app.state.room?.ownerId;
|
|
126
129
|
const ownerDialog = $("#ownerOnlyDialog");
|
|
127
130
|
// The entry never disappears: a member who is neither owner nor admin gets a plain explanation.
|
|
128
131
|
function showOwnerOnly() {
|
|
@@ -169,7 +172,7 @@ export function initAdmin(app) {
|
|
|
169
172
|
...(owner && nextOwner && nextOwner !== room.ownerId ? { ownerId: nextOwner } : {}),
|
|
170
173
|
...(rosterReady ? { adminIds: checkedAdmins, successorId: $("#editRoomSuccessor").value || null } : {}),
|
|
171
174
|
};
|
|
172
|
-
const button = event.submitter;
|
|
175
|
+
const button = event.submitter instanceof HTMLButtonElement ? event.submitter : null;
|
|
173
176
|
if (button)
|
|
174
177
|
button.disabled = true;
|
|
175
178
|
try {
|
|
@@ -196,7 +199,7 @@ export function initAdmin(app) {
|
|
|
196
199
|
dialog.close();
|
|
197
200
|
}
|
|
198
201
|
catch (error) {
|
|
199
|
-
$("#editRoomStatus").textContent = error
|
|
202
|
+
$("#editRoomStatus").textContent = errorMessage(error);
|
|
200
203
|
}
|
|
201
204
|
finally {
|
|
202
205
|
if (button)
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { LS } from "./state.js";
|
|
2
2
|
export function initAnnouncements(app) {
|
|
3
|
-
const $ =
|
|
3
|
+
const $ = (selector) => {
|
|
4
|
+
const node = app.$(selector);
|
|
5
|
+
if (!node)
|
|
6
|
+
throw new Error(`Missing ${selector}`);
|
|
7
|
+
return node;
|
|
8
|
+
};
|
|
9
|
+
const drafts = new Map();
|
|
4
10
|
const surface = $("#announcementsDialog"), trigger = $("#btnAnnouncements"), list = $("#announcementList");
|
|
5
11
|
const dialog = $("#announcementDialog"), heading = $("#announcementDialogHeading");
|
|
6
12
|
const panelHeading = $("#announcementHeading"), chatView = $("#chatView");
|
|
@@ -209,8 +215,9 @@ export function initAnnouncements(app) {
|
|
|
209
215
|
}
|
|
210
216
|
}
|
|
211
217
|
catch (error) {
|
|
218
|
+
const failure = error;
|
|
212
219
|
if (currentRoom(id, context) && editorMatches(captured))
|
|
213
|
-
formStatus(
|
|
220
|
+
formStatus(failure.status === 403 ? failure.message : app.t("announcementLoadFailed"));
|
|
214
221
|
}
|
|
215
222
|
finally {
|
|
216
223
|
if (token === saveToken)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Durable recovery for pasted attachments. Text is written synchronously so it
|
|
2
2
|
// survives the same task that creates the file; other blobs use IndexedDB.
|
|
3
3
|
const DB_NAME = "oc-chat-attachments", STORE = "pending", TEXT_PREFIX = "chat.pendingText:";
|
|
4
|
-
let dbPromise;
|
|
4
|
+
let dbPromise = null;
|
|
5
5
|
function database() {
|
|
6
6
|
if (dbPromise)
|
|
7
7
|
return dbPromise;
|
|
@@ -48,6 +48,14 @@ async function remove(key) {
|
|
|
48
48
|
}
|
|
49
49
|
catch { /* Best effort; stale blobs are harmless. */ }
|
|
50
50
|
}
|
|
51
|
+
function isTextRecord(value) {
|
|
52
|
+
return typeof value === "object" && value !== null && "key" in value && "text" in value
|
|
53
|
+
&& typeof value.key === "string" && typeof value.text === "string";
|
|
54
|
+
}
|
|
55
|
+
function isBlobRecord(value) {
|
|
56
|
+
return typeof value === "object" && value !== null && "key" in value && "blob" in value
|
|
57
|
+
&& typeof value.key === "string" && value.blob instanceof Blob;
|
|
58
|
+
}
|
|
51
59
|
function readTexts() {
|
|
52
60
|
const records = [];
|
|
53
61
|
try {
|
|
@@ -62,7 +70,7 @@ function readTexts() {
|
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
72
|
catch { /* Storage may be blocked. */ }
|
|
65
|
-
return records.filter(
|
|
73
|
+
return records.filter(isTextRecord);
|
|
66
74
|
}
|
|
67
75
|
function writeText(record) {
|
|
68
76
|
try {
|
|
@@ -88,8 +96,9 @@ export function persist(item, roomId) {
|
|
|
88
96
|
item.durable = true;
|
|
89
97
|
return Promise.resolve(true);
|
|
90
98
|
}
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
const task = write({ ...record, blob: item.file }).then((ok) => { item.durable = ok; return ok; });
|
|
100
|
+
item.persist = task;
|
|
101
|
+
return task;
|
|
93
102
|
}
|
|
94
103
|
export function forget(item) {
|
|
95
104
|
forgetText(item.uploadID);
|
|
@@ -114,7 +123,7 @@ export async function recover(roomId, draft) {
|
|
|
114
123
|
continue;
|
|
115
124
|
}
|
|
116
125
|
try {
|
|
117
|
-
const content =
|
|
126
|
+
const content = record.text ?? record.blob ?? "";
|
|
118
127
|
const file = new File([content], record.name, { type: record.type || "text/plain", lastModified: record.lastModified });
|
|
119
128
|
restored.push({ file, uploadID: record.key, textSource: record.textSource, textContent: record.text });
|
|
120
129
|
}
|
|
@@ -129,7 +138,7 @@ async function readFiles() {
|
|
|
129
138
|
try {
|
|
130
139
|
const tx = db.transaction(STORE, "readonly");
|
|
131
140
|
const result = await done(tx.objectStore(STORE).getAll());
|
|
132
|
-
return Array.isArray(result) ? result : [];
|
|
141
|
+
return Array.isArray(result) ? result.filter(isBlobRecord) : [];
|
|
133
142
|
}
|
|
134
143
|
catch {
|
|
135
144
|
return [];
|
|
@@ -6,17 +6,24 @@ const MAX_BUFFERED_BYTES = 32 * 1024 * 1024; // Pasted files are small; larger o
|
|
|
6
6
|
const TEXT_LIMIT = 5000;
|
|
7
7
|
const previewTypes = new Set(["image/png", "image/jpeg", "image/gif", "image/webp", "image/avif", "image/bmp"]);
|
|
8
8
|
export function initAttachments(app) {
|
|
9
|
-
const $ =
|
|
9
|
+
const $ = (selector) => {
|
|
10
|
+
const node = app.$(selector);
|
|
11
|
+
if (!node)
|
|
12
|
+
throw new Error(`Missing ${selector}`);
|
|
13
|
+
return node;
|
|
14
|
+
};
|
|
15
|
+
const input = $("#msgInput"), list = $("#attachmentList"), tray = $("#attachmentTray"), picker = $("#attachmentPicker");
|
|
10
16
|
const drafts = new Map();
|
|
11
17
|
const statuses = new Map();
|
|
12
|
-
app.state.sendingRooms ||= new Set();
|
|
18
|
+
const sendingRooms = (app.state.sendingRooms ||= new Set());
|
|
13
19
|
let limit = null, configRequest = null, activeUploads = 0, eagerQueued = 0;
|
|
14
20
|
const converting = new Set(), restoring = new Set(), uploadWaiters = new Map();
|
|
15
21
|
let editorLock = null, unloadGuard = false;
|
|
16
22
|
const roomId = () => app.state.room?.id || "";
|
|
17
23
|
const filesFor = (id) => drafts.get(id) || [];
|
|
18
|
-
const
|
|
19
|
-
const
|
|
24
|
+
const resources = (items) => items.flatMap((item) => item.resource ? [item.resource] : []);
|
|
25
|
+
const markers = (items) => resources(items).map((resource) => `[[resource:${resource.id}]]`);
|
|
26
|
+
const validResource = (resource, id) => /^[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i.test(resource?.id ?? "") && resource?.roomID === id;
|
|
20
27
|
// crypto.randomUUID needs a secure context; the chat also runs on plain-HTTP LANs.
|
|
21
28
|
function newUploadID() {
|
|
22
29
|
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
@@ -67,7 +74,7 @@ export function initAttachments(app) {
|
|
|
67
74
|
}
|
|
68
75
|
const textFor = (id, caption) => {
|
|
69
76
|
const parts = [String(caption || "").trim(), ...markers(filesFor(id))].filter(Boolean);
|
|
70
|
-
return { text: parts.join("\n\n"), ids: filesFor(id)
|
|
77
|
+
return { text: parts.join("\n\n"), ids: resources(filesFor(id)).map((resource) => resource.id) };
|
|
71
78
|
};
|
|
72
79
|
function formatSize(size) {
|
|
73
80
|
if (size < 1024)
|
|
@@ -168,7 +175,7 @@ export function initAttachments(app) {
|
|
|
168
175
|
finally {
|
|
169
176
|
restoring.delete(id);
|
|
170
177
|
if (roomId() === id)
|
|
171
|
-
app.updateSendState();
|
|
178
|
+
app.updateSendState?.();
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
function lockComposer() {
|
|
@@ -193,29 +200,31 @@ export function initAttachments(app) {
|
|
|
193
200
|
if (selection)
|
|
194
201
|
input.setSelectionRange?.(selection[0], selection[1]);
|
|
195
202
|
}
|
|
203
|
+
// The composer keeps the whole draft item as its conversion; PreparedMessage
|
|
204
|
+
// only advertises a File, so assign through a view that accepts the wider value.
|
|
196
205
|
app.prepareMessage = prepareMessage;
|
|
197
206
|
const baseDraftCount = app.updateDraftCount;
|
|
198
207
|
app.updateDraftCount = () => {
|
|
199
208
|
if (!roomId()) {
|
|
200
209
|
$("#draftCount").classList.remove("over-limit");
|
|
201
|
-
return baseDraftCount();
|
|
210
|
+
return baseDraftCount?.();
|
|
202
211
|
}
|
|
203
212
|
const count = textFor(roomId(), input.value).text.length;
|
|
204
213
|
app.setText($("#draftCount"), "messageCount", { count });
|
|
205
214
|
$("#draftCount").classList.toggle("over-limit", count > TEXT_LIMIT);
|
|
206
215
|
};
|
|
207
216
|
app.updateSendState = () => {
|
|
208
|
-
const id = roomId(), message = id
|
|
209
|
-
$("#btnSend").disabled = !id || !(message?.ready || message?.canConvert) ||
|
|
217
|
+
const id = roomId(), message = id ? prepareMessage(id, input.value) : null;
|
|
218
|
+
$("#btnSend").disabled = !id || !(message?.ready || message?.canConvert) || sendingRooms.has(id) || converting.has(id) || restoring.has(id);
|
|
210
219
|
};
|
|
211
220
|
app.completeAttachments = (id, resourceIDs) => {
|
|
212
|
-
const used = new Set(resourceIDs), items = filesFor(id), removed = items.filter((item) => used.has(item.resource?.id));
|
|
221
|
+
const used = new Set(resourceIDs), items = filesFor(id), removed = items.filter((item) => used.has(item.resource?.id ?? ""));
|
|
213
222
|
for (const item of removed) {
|
|
214
223
|
forget(item);
|
|
215
224
|
if (item.previewUrl)
|
|
216
225
|
URL.revokeObjectURL(item.previewUrl);
|
|
217
226
|
}
|
|
218
|
-
const remaining = items.filter((item) => !used.has(item.resource?.id));
|
|
227
|
+
const remaining = items.filter((item) => !used.has(item.resource?.id ?? ""));
|
|
219
228
|
if (remaining.length)
|
|
220
229
|
drafts.set(id, remaining);
|
|
221
230
|
else {
|
|
@@ -225,7 +234,7 @@ export function initAttachments(app) {
|
|
|
225
234
|
if (roomId() === id)
|
|
226
235
|
render();
|
|
227
236
|
};
|
|
228
|
-
app.completeAttachmentsFromText = (id, text) => app.completeAttachments(id, [...String(text).matchAll(/\[\[resource:([\da-f-]{36})\]\]/gi)].map((match) => match[1]));
|
|
237
|
+
app.completeAttachmentsFromText = (id, text) => app.completeAttachments?.(id, [...String(text).matchAll(/\[\[resource:([\da-f-]{36})\]\]/gi)].map((match) => match[1]));
|
|
229
238
|
const applyLocale = app.applyLocale;
|
|
230
239
|
app.applyLocale = () => { applyLocale(); updateLocale(); };
|
|
231
240
|
function updateLocale() {
|
|
@@ -235,7 +244,9 @@ export function initAttachments(app) {
|
|
|
235
244
|
if (!row)
|
|
236
245
|
return;
|
|
237
246
|
const detail = row.querySelector(".attachment-detail"), progress = row.querySelector("progress");
|
|
238
|
-
|
|
247
|
+
if (!detail || !progress)
|
|
248
|
+
return;
|
|
249
|
+
detail.textContent = `${formatSize(item.file.size)} · ${item.status === "failed" ? app.t(item.errorKey ?? "", item.errorValues || {}) : item.status === "uploaded" ? app.t("uploadReady") : item.status === "uploading" ? app.t("uploadPercent", { percent: item.percent || 0 }) : app.t("uploadQueued")}`;
|
|
239
250
|
const retry = row.querySelector('[data-upload-action="retry"]');
|
|
240
251
|
if (retry) {
|
|
241
252
|
retry.textContent = app.t("retryUpload");
|
|
@@ -265,8 +276,8 @@ export function initAttachments(app) {
|
|
|
265
276
|
list.replaceChildren();
|
|
266
277
|
items.forEach((item, index) => { const row = renderItem(item); row.dataset.index = String(index); list.append(row); });
|
|
267
278
|
updateDurability();
|
|
268
|
-
app.updateDraftCount();
|
|
269
|
-
app.updateSendState();
|
|
279
|
+
app.updateDraftCount?.();
|
|
280
|
+
app.updateSendState?.();
|
|
270
281
|
});
|
|
271
282
|
}
|
|
272
283
|
app.renderAttachments = render;
|
|
@@ -287,7 +298,7 @@ export function initAttachments(app) {
|
|
|
287
298
|
name.className = "attachment-name";
|
|
288
299
|
name.textContent = item.file.name;
|
|
289
300
|
detail.className = `attachment-detail${item.status === "failed" ? " attachment-over-limit" : ""}`;
|
|
290
|
-
detail.textContent = `${formatSize(item.file.size)} · ${item.status === "failed" ? app.t(item.errorKey, item.errorValues || {}) : item.status === "uploaded" ? app.t("uploadReady") : item.status === "uploading" ? app.t("uploadPercent", { percent: item.percent || 0 }) : app.t("uploadQueued")}`;
|
|
301
|
+
detail.textContent = `${formatSize(item.file.size)} · ${item.status === "failed" ? app.t(item.errorKey ?? "", item.errorValues || {}) : item.status === "uploaded" ? app.t("uploadReady") : item.status === "uploading" ? app.t("uploadPercent", { percent: item.percent || 0 }) : app.t("uploadQueued")}`;
|
|
291
302
|
progress.max = item.file.size || 1;
|
|
292
303
|
progress.value = item.loaded || 0;
|
|
293
304
|
progress.hidden = item.status !== "uploading";
|
|
@@ -347,11 +358,12 @@ export function initAttachments(app) {
|
|
|
347
358
|
return Promise.resolve(limit);
|
|
348
359
|
if (!configRequest || refresh) {
|
|
349
360
|
const request = app.api("/resources/config").then((data) => {
|
|
350
|
-
|
|
361
|
+
const size = data.maxFileSizeBytes;
|
|
362
|
+
if (typeof size !== "number" || !Number.isSafeInteger(size) || size < 1)
|
|
351
363
|
throw new Error("Invalid upload limit");
|
|
352
364
|
if (configRequest === request)
|
|
353
|
-
limit =
|
|
354
|
-
return
|
|
365
|
+
limit = size;
|
|
366
|
+
return size;
|
|
355
367
|
}).finally(() => { if (configRequest === request)
|
|
356
368
|
configRequest = null; });
|
|
357
369
|
configRequest = request;
|
|
@@ -423,15 +435,16 @@ export function initAttachments(app) {
|
|
|
423
435
|
releaseBuffer(item);
|
|
424
436
|
if (item.cancelled)
|
|
425
437
|
return;
|
|
426
|
-
|
|
438
|
+
const failure = error;
|
|
439
|
+
if (failure.status === 413) {
|
|
427
440
|
limit = null;
|
|
428
441
|
item.errorKey = "fileTooLarge";
|
|
429
442
|
}
|
|
430
|
-
else if (
|
|
443
|
+
else if (failure.unreadable)
|
|
431
444
|
item.errorKey = "fileUnreadable";
|
|
432
445
|
else {
|
|
433
446
|
item.errorKey = "uploadFailed";
|
|
434
|
-
item.errorValues = { reason:
|
|
447
|
+
item.errorValues = { reason: failure.status ? `HTTP ${failure.status}` : failure.timeout ? "timeout" : failure.network ? "network" : failure.message };
|
|
435
448
|
}
|
|
436
449
|
item.status = "failed";
|
|
437
450
|
if (roomId() === id)
|
|
@@ -452,7 +465,8 @@ export function initAttachments(app) {
|
|
|
452
465
|
return await upload(id, item);
|
|
453
466
|
}
|
|
454
467
|
catch (error) {
|
|
455
|
-
|
|
468
|
+
const failure = error;
|
|
469
|
+
if (!failure.network || item.cancelled || item.retried)
|
|
456
470
|
throw error;
|
|
457
471
|
item.retried = true;
|
|
458
472
|
item.loaded = 0;
|
|
@@ -578,7 +592,7 @@ export function initAttachments(app) {
|
|
|
578
592
|
const baseSend = app.send;
|
|
579
593
|
app.send = async () => {
|
|
580
594
|
const id = roomId();
|
|
581
|
-
if (!id || converting.has(id) || restoring.has(id) ||
|
|
595
|
+
if (!id || converting.has(id) || restoring.has(id) || sendingRooms.has(id))
|
|
582
596
|
return false;
|
|
583
597
|
const message = prepareMessage(id, input.value);
|
|
584
598
|
if (!message.canConvert)
|
|
@@ -624,8 +638,8 @@ export function initAttachments(app) {
|
|
|
624
638
|
converting.delete(id);
|
|
625
639
|
if (roomId() === id) {
|
|
626
640
|
unlockComposer();
|
|
627
|
-
app.updateDraftCount();
|
|
628
|
-
app.updateSendState();
|
|
641
|
+
app.updateDraftCount?.();
|
|
642
|
+
app.updateSendState?.();
|
|
629
643
|
}
|
|
630
644
|
else
|
|
631
645
|
editorLock = null;
|
|
@@ -653,7 +667,7 @@ export function initAttachments(app) {
|
|
|
653
667
|
$("#btnAddAttachments").addEventListener("click", () => picker.click());
|
|
654
668
|
picker.addEventListener("change", () => { addFiles(picker.files || []); picker.value = ""; });
|
|
655
669
|
list.addEventListener("click", (event) => {
|
|
656
|
-
const button = event.target.closest
|
|
670
|
+
const button = event.target instanceof Element ? event.target.closest("[data-upload-action]") : null;
|
|
657
671
|
if (!button)
|
|
658
672
|
return;
|
|
659
673
|
const id = roomId(), index = Number(button.closest(".attachment-item")?.dataset.index), item = filesFor(id)[index];
|
|
@@ -675,10 +689,11 @@ export function initAttachments(app) {
|
|
|
675
689
|
chatView.addEventListener("dragenter", (event) => { if (!hasFiles(event))
|
|
676
690
|
return; event.preventDefault(); showDrop(); });
|
|
677
691
|
chatView.addEventListener("dragover", (event) => { if (!hasFiles(event))
|
|
678
|
-
return; event.preventDefault(); event.dataTransfer
|
|
679
|
-
|
|
692
|
+
return; event.preventDefault(); if (event.dataTransfer)
|
|
693
|
+
event.dataTransfer.dropEffect = "copy"; showDrop(); });
|
|
694
|
+
chatView.addEventListener("dragleave", (event) => { if (hasFiles(event) && !(event.relatedTarget instanceof Node && chatView.contains(event.relatedTarget)))
|
|
680
695
|
clearDrop(); });
|
|
681
|
-
chatView.addEventListener("drop", (event) => { if (!hasFiles(event))
|
|
696
|
+
chatView.addEventListener("drop", (event) => { if (!hasFiles(event) || !event.dataTransfer)
|
|
682
697
|
return; event.preventDefault(); clearDrop(); addFiles(event.dataTransfer.files); });
|
|
683
698
|
// Capture before the editor's paste handler: an oversized paste never enters the DOM.
|
|
684
699
|
input.addEventListener("paste", (event) => {
|
|
@@ -693,7 +708,7 @@ export function initAttachments(app) {
|
|
|
693
708
|
const images = Array.from(event.clipboardData?.items || []).filter((item) => item.kind === "file" && item.type.startsWith("image/")).map((item) => item.getAsFile()).filter(Boolean);
|
|
694
709
|
if (!images.length)
|
|
695
710
|
return;
|
|
696
|
-
if (!event.clipboardData
|
|
711
|
+
if (!event.clipboardData?.getData("text/plain"))
|
|
697
712
|
event.preventDefault();
|
|
698
713
|
addFiles(images, true);
|
|
699
714
|
}, true);
|
|
@@ -8,8 +8,9 @@ const clampOpacity = (value) => {
|
|
|
8
8
|
const number = Number(value);
|
|
9
9
|
return Number.isFinite(number) ? Math.min(100, Math.max(0, Math.round(number))) : DEFAULT_OPACITY;
|
|
10
10
|
};
|
|
11
|
+
const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
11
12
|
const normalize = (value) => {
|
|
12
|
-
if (!
|
|
13
|
+
if (!isRecord(value))
|
|
13
14
|
return null;
|
|
14
15
|
const opacity = clampOpacity(value.opacity);
|
|
15
16
|
if (value.kind === "image" && typeof value.image === "string" && value.image.startsWith("data:image/") && value.image.length <= MAX_DATA_URL_LENGTH) {
|
|
@@ -28,10 +29,7 @@ const readStored = () => {
|
|
|
28
29
|
};
|
|
29
30
|
const writeStored = (value) => {
|
|
30
31
|
try {
|
|
31
|
-
|
|
32
|
-
localStorage.setItem(GLOBAL_KEY, JSON.stringify(value));
|
|
33
|
-
else
|
|
34
|
-
localStorage.removeItem(GLOBAL_KEY);
|
|
32
|
+
localStorage.setItem(GLOBAL_KEY, JSON.stringify(value));
|
|
35
33
|
return true;
|
|
36
34
|
}
|
|
37
35
|
catch {
|
|
@@ -67,7 +65,7 @@ export function initChatBackground(app) {
|
|
|
67
65
|
const opacityField = $("#chatBackgroundOpacityField");
|
|
68
66
|
const preview = $("#chatBackgroundPreview"), fileName = $("#chatBackgroundFileName");
|
|
69
67
|
const status = $("#chatBackgroundStatus");
|
|
70
|
-
if (!dialog || !mode || !imageInput || !opacity || !imageField || !opacityField || !preview || !status)
|
|
68
|
+
if (!dialog || !mode || !imageInput || !opacity || !opacityValue || !imageField || !opacityField || !preview || !fileName || !status)
|
|
71
69
|
return;
|
|
72
70
|
let previewURL = null;
|
|
73
71
|
const clearPreview = () => {
|
|
@@ -77,10 +75,8 @@ export function initChatBackground(app) {
|
|
|
77
75
|
}
|
|
78
76
|
preview.hidden = true;
|
|
79
77
|
preview.removeAttribute("src");
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
fileName.textContent = "";
|
|
83
|
-
}
|
|
78
|
+
fileName.hidden = true;
|
|
79
|
+
fileName.textContent = "";
|
|
84
80
|
};
|
|
85
81
|
const setPreview = (src, name) => {
|
|
86
82
|
if (previewURL) {
|
|
@@ -89,10 +85,8 @@ export function initChatBackground(app) {
|
|
|
89
85
|
}
|
|
90
86
|
preview.src = src;
|
|
91
87
|
preview.hidden = false;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
fileName.hidden = !name;
|
|
95
|
-
}
|
|
88
|
+
fileName.textContent = name || "";
|
|
89
|
+
fileName.hidden = !name;
|
|
96
90
|
};
|
|
97
91
|
const setStatus = (key, values, error = false) => {
|
|
98
92
|
status.classList.toggle("is-error", error);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Clipboard writes with a legacy fallback for browsers or permissions that block
|
|
2
2
|
// the async Clipboard API. Mention copy keeps its marker HTML for later pastes.
|
|
3
|
+
const ESCAPES = { "&": "&", "<": "<", ">": ">", '"': """ };
|
|
3
4
|
export async function copyTextToClipboard(text, mentionSource = false) {
|
|
4
5
|
// The HTML marker lets a later paste rebuild mention chips; unmarked external text stays literal.
|
|
5
|
-
const html = mentionSource ? `<div data-chatroom-mentions>${String(text).replace(/[&<>"]/g, (char) =>
|
|
6
|
+
const html = mentionSource ? `<div data-chatroom-mentions>${String(text).replace(/[&<>"]/g, (char) => ESCAPES[char])}</div>` : "";
|
|
6
7
|
try {
|
|
7
8
|
if (html && navigator.clipboard?.write && typeof ClipboardItem !== "undefined") {
|
|
8
9
|
await navigator.clipboard.write([new ClipboardItem({ "text/plain": new Blob([text], { type: "text/plain" }), "text/html": new Blob([html], { type: "text/html" }) })]);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// One shared confirmation dialog replaces the browser's native confirmation
|
|
2
|
-
// window, so a destructive action stays inside the page.
|
|
3
1
|
export function initConfirmDialog(app) {
|
|
4
2
|
const dialog = app.$("#confirmDialog"), message = app.$("#confirmMessage");
|
|
5
3
|
const accept = app.$("#btnAcceptConfirm"), cancel = app.$("#btnCancelConfirm");
|
|
4
|
+
if (!dialog || !message || !accept || !cancel)
|
|
5
|
+
return;
|
|
6
6
|
let pending = null, opener = null;
|
|
7
7
|
const settle = (value) => { const resolve = pending; pending = null; resolve?.(value); };
|
|
8
|
-
|
|
8
|
+
const close = (value) => { settle(value); dialog.close(); };
|
|
9
9
|
app.confirmAction = (text) => {
|
|
10
10
|
// One dialog at a time: a newer request dismisses the open one as cancelled.
|
|
11
11
|
if (dialog.open)
|