@alexsun-top/opencode-chat-room 0.8.3 → 0.8.5
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 +7 -1
- package/README.md +5 -5
- package/README.zh-CN.md +5 -5
- package/cli.ts +1 -1
- package/dist/cli.js +35 -16
- package/package.json +15 -9
- package/packages/chat-room-channeld/README.md +3 -2
- package/packages/chat-room-channeld/src/inbound.ts +3 -6
- package/packages/chat-room-channeld/src/pg/sql.mjs +157 -142
- package/packages/chat-room-channeld/src/pg/sql.mts +175 -0
- package/packages/chat-room-channeld/src/pg/worker.mjs +107 -99
- package/packages/chat-room-channeld/src/pg/worker.mts +166 -0
- package/plugin.ts +1 -1
- package/server/assets/chat/admin-badge.js +1 -1
- package/server/assets/chat/admin.js +16 -10
- package/server/assets/chat/announcements.js +12 -2
- package/server/assets/chat/attachment-store.js +15 -6
- package/server/assets/chat/attachments.js +48 -33
- 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 +1 -2
- package/server/assets/chat/diagram-viewer.js +7 -9
- package/server/assets/chat/doc-preview.js +19 -12
- package/server/assets/chat/editor.js +87 -61
- package/server/assets/chat/events.js +49 -34
- package/server/assets/chat/files.js +45 -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 +2 -2
- package/server/assets/chat/integration-values.js +17 -11
- package/server/assets/chat/integrations.js +138 -81
- package/server/assets/chat/join-requests.js +20 -13
- package/server/assets/chat/markdown-footnotes.js +8 -8
- package/server/assets/chat/markdown.js +48 -38
- package/server/assets/chat/members.js +48 -25
- package/server/assets/chat/mentions.js +39 -12
- package/server/assets/chat/message-cache.js +2 -2
- package/server/assets/chat/message-polling.js +40 -21
- package/server/assets/chat/message-window.js +10 -6
- package/server/assets/chat/messages.js +70 -46
- package/server/assets/chat/office-preview.js +3 -3
- package/server/assets/chat/palette.js +45 -29
- package/server/assets/chat/panels.js +19 -1
- package/server/assets/chat/pwa.js +5 -4
- package/server/assets/chat/questions.js +25 -22
- package/server/assets/chat/recall.js +39 -21
- package/server/assets/chat/receipts.js +9 -7
- package/server/assets/chat/reminders.js +25 -8
- package/server/assets/chat/replies.js +34 -15
- package/server/assets/chat/resource-format.js +2 -2
- package/server/assets/chat/room-list.js +2 -2
- package/server/assets/chat/room-watcher.js +8 -4
- package/server/assets/chat/rooms.js +51 -40
- package/server/assets/chat/search.js +8 -6
- package/server/assets/chat/settings.js +16 -14
- package/server/assets/chat/shiki.js +1 -1
- package/server/assets/chat/shortcuts.js +3 -3
- package/server/assets/chat/side-pane.js +4 -3
- package/server/assets/chat/state.js +65 -37
- package/server/assets/chat/system-events.js +6 -5
- package/server/assets/chat/system-messages.js +15 -15
- package/server/assets/chat/task-form.js +5 -5
- package/server/assets/chat/task-row.js +1 -1
- package/server/assets/chat/tasks.js +41 -28
- package/server/assets/chat/window-controls.js +3 -2
- package/server/assets/conversation.css +14 -2
- package/server/assets/doc-preview.css +6 -0
- package/server/assets/office/THIRD-PARTY-NOTICES.txt +23 -1
- package/server/assets/office/licenses/docx-preview-HEADER.txt +6 -0
- package/server/assets/office/licenses/echarts-LICENSE-d3.txt +27 -0
- package/server/assets/office/licenses/echarts-NOTICE.txt +5 -0
- package/server/assets/office/licenses/immediate-LICENSE.txt +20 -0
- package/server/assets/office/licenses/lie-LICENSE.txt +7 -0
- package/server/assets/office/licenses/pako-LICENSE.txt +21 -0
- package/server/assets/office/licenses/pako-ZLIB.txt +18 -0
- package/server/assets/office/licenses/setimmediate-LICENSE.txt +20 -0
- package/server/chat.html +1 -0
- package/server/sw.js +3 -1
- package/skills/chatroom/SKILL.md +9 -0
- package/src/README.md +1 -1
- package/src/agent/agent-receipts.ts +12 -4
- package/src/center/center-client.ts +1 -1
- package/src/state/pg-sql.mjs +157 -142
- package/src/state/pg-sql.mts +175 -0
- package/src/state/pg-worker.mjs +107 -99
- package/src/state/pg-worker.mts +166 -0
- package/src/state/store.ts +21 -7
- package/src/tui/app-types.mjs +1 -0
- package/src/tui/app-types.mts +175 -0
- package/src/tui/app.mjs +426 -423
- package/src/tui/app.mts +500 -0
- package/src/tui/config.mjs +166 -158
- package/src/tui/config.mts +247 -0
- package/src/tui/http.mjs +239 -206
- package/src/tui/http.mts +412 -0
- package/src/tui/i18n.mjs +17 -20
- package/src/tui/i18n.mts +42 -0
- package/src/tui/info-app.mjs +431 -427
- package/src/tui/info-app.mts +500 -0
- package/src/tui/info-content.mjs +205 -199
- package/src/tui/info-content.mts +341 -0
- package/src/tui/join-app.mjs +75 -64
- package/src/tui/join-app.mts +99 -0
- package/src/tui/locales/en.mjs +302 -320
- package/src/tui/locales/en.mts +349 -0
- package/src/tui/locales/zh-CN.mjs +302 -320
- package/src/tui/locales/zh-CN.mts +349 -0
- package/src/tui/main.mjs +219 -213
- package/src/tui/main.mts +255 -0
- package/src/tui/markdown.mjs +128 -272
- package/src/tui/markdown.mts +152 -0
- package/src/tui/mentions.mjs +181 -184
- package/src/tui/mentions.mts +251 -0
- package/src/tui/message-app.mjs +181 -173
- package/src/tui/message-app.mts +213 -0
- package/src/tui/message-view.mjs +90 -111
- package/src/tui/message-view.mts +151 -0
- package/src/tui/messages.mjs +55 -49
- package/src/tui/messages.mts +106 -0
- package/src/tui/palette-app.mjs +364 -344
- package/src/tui/palette-app.mts +388 -0
- package/src/tui/palette.mjs +100 -98
- package/src/tui/palette.mts +176 -0
- package/src/tui/prefs.mjs +56 -63
- package/src/tui/prefs.mts +126 -0
- package/src/tui/reminder-app.mjs +191 -181
- package/src/tui/reminder-app.mts +228 -0
- package/src/tui/room-settings-app.mjs +257 -242
- package/src/tui/room-settings-app.mts +301 -0
- package/src/tui/session.mjs +30 -29
- package/src/tui/session.mts +51 -0
- package/src/tui/settings-app.mjs +151 -138
- package/src/tui/settings-app.mts +179 -0
- package/src/tui/ui-content.mjs +426 -421
- package/src/tui/ui-content.mts +499 -0
- package/src/tui/ui-help.mjs +58 -67
- package/src/tui/ui-help.mts +87 -0
- package/src/tui/ui-mentions.mjs +34 -36
- package/src/tui/ui-mentions.mts +60 -0
- package/src/tui/ui-overlay-view.mjs +259 -267
- package/src/tui/ui-overlay-view.mts +322 -0
- package/src/tui/ui-suggest-view.mjs +54 -57
- package/src/tui/ui-suggest-view.mts +78 -0
- package/src/tui/ui-suggest.mjs +164 -167
- package/src/tui/ui-suggest.mts +248 -0
- package/src/tui/ui-theme.mjs +52 -57
- package/src/tui/ui-theme.mts +98 -0
- package/src/tui/ui-view.mjs +267 -275
- package/src/tui/ui-view.mts +308 -0
- package/src/tui/ui.mjs +372 -359
- package/src/tui/ui.mts +440 -0
- package/src/tui/wire.mjs +215 -0
- package/src/tui/wire.mts +383 -0
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { LS } from "./state.js";
|
|
2
|
+
import { closeOnBackdrop } from "./panels.js";
|
|
2
3
|
export function initReminders(app) {
|
|
3
|
-
const $ =
|
|
4
|
+
const $ = (selector) => {
|
|
5
|
+
const element = app.$(selector);
|
|
6
|
+
if (!element)
|
|
7
|
+
throw new Error(`Missing element: ${selector}`);
|
|
8
|
+
return element;
|
|
9
|
+
};
|
|
10
|
+
const surface = $("#remindersDialog"), trigger = $("#btnReminders"), list = $("#reminderList");
|
|
4
11
|
const dialog = $("#reminderDialog"), newButton = $("#btnNewReminder");
|
|
5
12
|
const heading = $("#reminderDialogHeading"), panelHeading = $("#reminderHeading"), submit = $("#btnSubmitReminder");
|
|
6
13
|
const chatView = $("#chatView");
|
|
@@ -91,7 +98,10 @@ export function initReminders(app) {
|
|
|
91
98
|
}
|
|
92
99
|
const current = (id, context) => roomId() === id && roomGeneration === context;
|
|
93
100
|
const invalidateLoads = () => { generation++; };
|
|
94
|
-
const errorText = (error) =>
|
|
101
|
+
const errorText = (error) => {
|
|
102
|
+
const failure = error instanceof Error ? error : null;
|
|
103
|
+
return failure?.message || app.t("requestFailed", { status: failure?.status || "?" });
|
|
104
|
+
};
|
|
95
105
|
function formDraft() {
|
|
96
106
|
return { type: $("#reminderType").value, at: $("#reminderAt").value, cron: $("#reminderCron").value, timezone: $("#reminderTimezone").value, text: $("#reminderText").value };
|
|
97
107
|
}
|
|
@@ -106,7 +116,7 @@ export function initReminders(app) {
|
|
|
106
116
|
// datetime-local has no zone; format the stored instant in its own zone so saving reproduces it.
|
|
107
117
|
function inputValue(iso, timezone) {
|
|
108
118
|
const parts = Object.fromEntries(new Intl.DateTimeFormat("en-CA", { timeZone: timezone, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", hourCycle: "h23" })
|
|
109
|
-
.formatToParts(new Date(iso)).map((part) => [part.type, part.value]));
|
|
119
|
+
.formatToParts(new Date(iso ?? "")).map((part) => [part.type, part.value]));
|
|
110
120
|
return `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}`;
|
|
111
121
|
}
|
|
112
122
|
function editDraft(reminder) {
|
|
@@ -117,7 +127,7 @@ export function initReminders(app) {
|
|
|
117
127
|
}
|
|
118
128
|
function formatTime(value, timezone) {
|
|
119
129
|
const effectiveZone = timezone || "UTC";
|
|
120
|
-
const formatted = new Intl.DateTimeFormat(undefined, { timeZone: effectiveZone, dateStyle: "medium", timeStyle: "short" }).format(new Date(value));
|
|
130
|
+
const formatted = new Intl.DateTimeFormat(undefined, { timeZone: effectiveZone, dateStyle: "medium", timeStyle: "short" }).format(new Date(value ?? ""));
|
|
121
131
|
return `${formatted} · ${effectiveZone}`;
|
|
122
132
|
}
|
|
123
133
|
function render() {
|
|
@@ -193,6 +203,8 @@ export function initReminders(app) {
|
|
|
193
203
|
}
|
|
194
204
|
async function update(reminder, paused) {
|
|
195
205
|
const id = roomId(), context = roomGeneration;
|
|
206
|
+
if (!id)
|
|
207
|
+
return;
|
|
196
208
|
try {
|
|
197
209
|
await app.api(`/rooms/${encodeURIComponent(id)}/reminders/${encodeURIComponent(reminder.id)}`, { method: "PATCH", body: JSON.stringify({ sessionID: LS.sessionID, paused }) });
|
|
198
210
|
if (current(id, context)) {
|
|
@@ -212,6 +224,8 @@ export function initReminders(app) {
|
|
|
212
224
|
}
|
|
213
225
|
async function erase(reminder) {
|
|
214
226
|
const id = roomId(), context = roomGeneration;
|
|
227
|
+
if (!id)
|
|
228
|
+
return;
|
|
215
229
|
try {
|
|
216
230
|
await app.api(`/rooms/${encodeURIComponent(id)}/reminders/${encodeURIComponent(reminder.id)}`, { method: "DELETE", body: JSON.stringify({ sessionID: LS.sessionID }) });
|
|
217
231
|
if (current(id, context)) {
|
|
@@ -242,7 +256,7 @@ export function initReminders(app) {
|
|
|
242
256
|
const schedule = type.value === "once"
|
|
243
257
|
? { type: "once", at: `${date.value}:00`, ...(zone ? { timezone: zone } : {}) }
|
|
244
258
|
: { type: "cron", expression: cron.value.trim(), ...(zone ? { timezone: zone } : {}) };
|
|
245
|
-
if (!id || !text || text.length > 2000 || !validZone(zone) || type.value === "once" && !date.value || type.value === "cron" && !validCron(schedule.expression))
|
|
259
|
+
if (!id || !text || text.length > 2000 || !validZone(zone) || type.value === "once" && !date.value || type.value === "cron" && !validCron(schedule.expression || ""))
|
|
246
260
|
return formStatus(app.t("reminderInvalid"));
|
|
247
261
|
if (saving)
|
|
248
262
|
return;
|
|
@@ -252,9 +266,10 @@ export function initReminders(app) {
|
|
|
252
266
|
// Keep the stored schedule when only the text changed, so a fired one-time reminder stays editable.
|
|
253
267
|
try {
|
|
254
268
|
const editingId = editing?.id;
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
&& (
|
|
269
|
+
const editingSchedule = editing?.schedule;
|
|
270
|
+
const sameSchedule = editingSchedule ? editingSchedule.type === type.value
|
|
271
|
+
&& (type.value === "once" ? inputValue(editingSchedule.at, zone || "UTC") === date.value : editingSchedule.expression === schedule.expression)
|
|
272
|
+
&& (editingSchedule.timezone || "UTC") === (zone || "UTC") : false;
|
|
258
273
|
const result = await app.api(`/rooms/${encodeURIComponent(id)}/reminders${editingId ? `/${encodeURIComponent(editingId)}` : ""}`, { method: editingId ? "PATCH" : "POST", body: JSON.stringify({ sessionID: LS.sessionID, text, ...(sameSchedule ? {} : { schedule }) }) });
|
|
259
274
|
if (current(id, context)) {
|
|
260
275
|
invalidateLoads();
|
|
@@ -285,6 +300,8 @@ export function initReminders(app) {
|
|
|
285
300
|
dialog.addEventListener("close", () => { editing = null; });
|
|
286
301
|
trigger.addEventListener("click", () => { app.closePanels(); openSurface(); });
|
|
287
302
|
$("#btnCloseReminders").addEventListener("click", () => closeSurface());
|
|
303
|
+
// The reminder list is a list, so a backdrop click closes it; the editor stays.
|
|
304
|
+
closeOnBackdrop(surface, () => closeSurface());
|
|
288
305
|
surface.addEventListener("cancel", (event) => { event.preventDefault(); closeSurface(); });
|
|
289
306
|
surface.addEventListener("close", () => {
|
|
290
307
|
if (pendingReopen) {
|
|
@@ -2,7 +2,13 @@ import { LS } from "./state.js";
|
|
|
2
2
|
import { replaceEditorRange, setEditorSelection, setCaret } from "./editor.js";
|
|
3
3
|
import { icon } from "./icons.js";
|
|
4
4
|
export function initReplies(app) {
|
|
5
|
-
const $ =
|
|
5
|
+
const $ = (selector) => {
|
|
6
|
+
const node = app.$(selector);
|
|
7
|
+
if (!node)
|
|
8
|
+
throw new Error(`Missing ${selector}`);
|
|
9
|
+
return node;
|
|
10
|
+
};
|
|
11
|
+
const targets = new Map(Object.entries(LS.replyDrafts || {}).filter(([, item]) => validTarget(item)));
|
|
6
12
|
$("#replyCancel").textContent = app.t("cancelReply");
|
|
7
13
|
app.replyTargetFor = (roomId) => targets.get(roomId);
|
|
8
14
|
app.setReplyTarget = (roomId, target) => {
|
|
@@ -12,7 +18,7 @@ export function initReplies(app) {
|
|
|
12
18
|
targets.delete(roomId);
|
|
13
19
|
LS.replyDrafts = Object.fromEntries(targets);
|
|
14
20
|
if (app.state.room?.id === roomId)
|
|
15
|
-
app.renderReplyPreview();
|
|
21
|
+
app.renderReplyPreview?.();
|
|
16
22
|
};
|
|
17
23
|
app.clearReplyTarget = (roomId) => app.setReplyTarget(roomId, null);
|
|
18
24
|
app.renderReplyPreview = () => {
|
|
@@ -27,7 +33,7 @@ export function initReplies(app) {
|
|
|
27
33
|
bindMessageActions(app);
|
|
28
34
|
}
|
|
29
35
|
function validTarget(item) {
|
|
30
|
-
return item && typeof item.id === "string" && typeof item.text === "string" && typeof item.senderId === "string";
|
|
36
|
+
return Boolean(item && typeof item.id === "string" && typeof item.text === "string" && typeof item.senderId === "string");
|
|
31
37
|
}
|
|
32
38
|
function excerpt(text) { return String(text).replace(/<at>@([^<]+)<\/at>/g, "@$1").replace(/\s+/g, " ").trim().slice(0, 180); }
|
|
33
39
|
function bindMessageActions(app) {
|
|
@@ -54,11 +60,17 @@ function bindMessageActions(app) {
|
|
|
54
60
|
}
|
|
55
61
|
return row;
|
|
56
62
|
};
|
|
57
|
-
$("#msgList")
|
|
58
|
-
|
|
63
|
+
const list = $("#msgList");
|
|
64
|
+
if (!list)
|
|
65
|
+
return;
|
|
66
|
+
list.addEventListener("click", (event) => {
|
|
67
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
68
|
+
const button = target?.closest("[data-reply-message], [data-reply-target-id]");
|
|
59
69
|
if (!button || !app.state.room)
|
|
60
70
|
return;
|
|
61
71
|
const room = app.state.room, id = button.dataset.replyMessage || button.dataset.replyTargetId;
|
|
72
|
+
if (!id)
|
|
73
|
+
return;
|
|
62
74
|
if (button.dataset.replyMessage)
|
|
63
75
|
selectReply(app.state.room.messages.find((item) => item.id === id), app);
|
|
64
76
|
else
|
|
@@ -68,11 +80,13 @@ function bindMessageActions(app) {
|
|
|
68
80
|
function selectReply(message, app) {
|
|
69
81
|
if (!message || !app.state.room)
|
|
70
82
|
return;
|
|
83
|
+
const input = app.$("#msgInput");
|
|
84
|
+
if (!input)
|
|
85
|
+
return;
|
|
71
86
|
const roomId = app.state.room.id;
|
|
72
|
-
removeAutoMention(app.replyTargetFor(roomId),
|
|
87
|
+
removeAutoMention(app.replyTargetFor?.(roomId), input);
|
|
73
88
|
const target = { id: message.id, text: message.text, senderId: message.senderId, senderSessionID: message.senderSessionID, isQuestion: Boolean(message.isQuestion) };
|
|
74
89
|
const name = uniqueAuthor(message, app);
|
|
75
|
-
const input = app.$("#msgInput");
|
|
76
90
|
if (name && !input.value.includes(`<at>@${name}</at>`)) {
|
|
77
91
|
const prefix = `<at>@${name}</at> `;
|
|
78
92
|
target.autoMention = name;
|
|
@@ -84,32 +98,37 @@ function selectReply(message, app) {
|
|
|
84
98
|
input.focus({ preventScroll: true });
|
|
85
99
|
}
|
|
86
100
|
function cancelReply(app) {
|
|
87
|
-
const roomId = app.state.room?.id, target = roomId && app.replyTargetFor(roomId);
|
|
101
|
+
const roomId = app.state.room?.id, target = roomId && app.replyTargetFor?.(roomId);
|
|
88
102
|
if (!roomId || !target)
|
|
89
103
|
return;
|
|
90
104
|
removeAutoMention(target, app.$("#msgInput"));
|
|
91
105
|
app.clearReplyTarget(roomId);
|
|
92
106
|
}
|
|
93
107
|
function removeAutoMention(target, input) {
|
|
108
|
+
if (!input)
|
|
109
|
+
return;
|
|
94
110
|
const prefix = target?.autoMention && `<at>@${target.autoMention}</at> `;
|
|
95
111
|
if (prefix && input.value.startsWith(prefix)) {
|
|
96
112
|
setEditorSelection(input, 0, prefix.length);
|
|
97
|
-
getSelection()
|
|
113
|
+
getSelection()?.deleteFromDocument();
|
|
98
114
|
setCaret(input, 0);
|
|
99
115
|
input.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "deleteContentBackward" }));
|
|
100
116
|
}
|
|
101
117
|
}
|
|
102
118
|
function uniqueAuthor(message, app) {
|
|
103
|
-
const members = app.state.memberSessions.get(app.state.room?.id) || [];
|
|
119
|
+
const members = app.state.memberSessions.get(app.state.room?.id ?? "") || [];
|
|
104
120
|
const matches = message.senderSessionID ? members.filter((item) => item.sessionID === message.senderSessionID)
|
|
105
121
|
: members.filter((item) => item.name === message.senderId);
|
|
106
|
-
const
|
|
107
|
-
|
|
122
|
+
const only = matches.length === 1 ? matches[0] : undefined;
|
|
123
|
+
if (!only)
|
|
124
|
+
return "";
|
|
125
|
+
const name = only.name;
|
|
126
|
+
return members.filter((item) => item.name === name).length === 1 && only.sessionID !== LS.sessionID && name !== "all" ? name : "";
|
|
108
127
|
}
|
|
109
128
|
function senderName(message, app) {
|
|
110
129
|
if (message.senderSessionID === LS.sessionID)
|
|
111
130
|
return app.t("you");
|
|
112
|
-
const members = app.state.memberSessions.get(app.state.room?.id) || [];
|
|
131
|
+
const members = app.state.memberSessions.get(app.state.room?.id ?? "") || [];
|
|
113
132
|
const match = message.senderSessionID && members.find((item) => item.sessionID === message.senderSessionID);
|
|
114
133
|
if (match)
|
|
115
134
|
return match.name;
|
|
@@ -117,7 +136,7 @@ function senderName(message, app) {
|
|
|
117
136
|
}
|
|
118
137
|
function quoteButton(message, app) {
|
|
119
138
|
const button = document.createElement("button"), targetId = message.answerToMessageID;
|
|
120
|
-
const original = app.state.room
|
|
139
|
+
const original = app.state.room?.messages.find((item) => item.id === targetId);
|
|
121
140
|
button.type = "button";
|
|
122
141
|
button.className = "reply-quote";
|
|
123
142
|
button.dataset.replyTargetId = targetId;
|
|
@@ -175,7 +194,7 @@ async function jumpToOriginal(roomId, messageId, app) {
|
|
|
175
194
|
row.classList.remove("jump-flash");
|
|
176
195
|
void row.offsetWidth;
|
|
177
196
|
row.classList.add("jump-flash");
|
|
178
|
-
row._jumpFlashTimer = setTimeout(() => row.classList.remove("jump-flash"), 900);
|
|
197
|
+
row._jumpFlashTimer = window.setTimeout(() => row.classList.remove("jump-flash"), 900);
|
|
179
198
|
}
|
|
180
199
|
}
|
|
181
200
|
const quote = document.querySelector(`[data-reply-target-id="${CSS.escape(messageId)}"]`);
|
|
@@ -61,7 +61,7 @@ function isTextMime(mime) {
|
|
|
61
61
|
return mime.startsWith("text/") || TEXT_MIMES.has(mime);
|
|
62
62
|
}
|
|
63
63
|
export function docPreviewFormat(resource) {
|
|
64
|
-
const mime = String(resource?.mimeType || "").split(";")[0].trim().toLowerCase();
|
|
64
|
+
const mime = (String(resource?.mimeType || "").split(";")[0] ?? "").trim().toLowerCase();
|
|
65
65
|
const name = String(resource?.name || "");
|
|
66
66
|
const ext = fileExtension(name);
|
|
67
67
|
if (mime === "application/pdf" || ext === "pdf")
|
|
@@ -76,7 +76,7 @@ export function docPreviewFormat(resource) {
|
|
|
76
76
|
const knownExtension = Object.hasOwn(EXTENSION_LANGUAGES, ext);
|
|
77
77
|
if (!knownExtension && !isTextMime(mime))
|
|
78
78
|
return null;
|
|
79
|
-
const language = knownExtension ? EXTENSION_LANGUAGES[ext] : MIME_LANGUAGES[mime]
|
|
79
|
+
const language = (knownExtension ? EXTENSION_LANGUAGES[ext] : MIME_LANGUAGES[mime]) ?? "";
|
|
80
80
|
return { kind: "text", language, label: LANGUAGE_NAMES[language] || (ext ? ext.toUpperCase() : "Text") };
|
|
81
81
|
}
|
|
82
82
|
export const isDocPreviewResource = (resource) => docPreviewFormat(resource) !== null;
|
|
@@ -27,7 +27,7 @@ export function renderRoomOptions(app, list, rooms) {
|
|
|
27
27
|
const meta = document.createElement("span");
|
|
28
28
|
meta.className = "r-meta";
|
|
29
29
|
const shownRoom = entry?.room || room;
|
|
30
|
-
meta.textContent = app.t("roomMeta", { members: shownRoom.participants.length, count: shownRoom.messages.length });
|
|
30
|
+
meta.textContent = app.t("roomMeta", { members: (shownRoom.participants || []).length, count: shownRoom.messages.length });
|
|
31
31
|
const preview = document.createElement("span");
|
|
32
32
|
preview.className = "r-preview";
|
|
33
33
|
preview.textContent = entry ? formatRoomPreview(entry, shownRoom.messages.at(-1), app) : "";
|
|
@@ -48,7 +48,7 @@ export function renderRoomOptions(app, list, rooms) {
|
|
|
48
48
|
button.append(badge);
|
|
49
49
|
}
|
|
50
50
|
button.addEventListener("click", () => {
|
|
51
|
-
const name = app.state.myName || app.$("#inName")
|
|
51
|
+
const name = app.state.myName || app.$("#inName")?.value.trim() || app.t("guest");
|
|
52
52
|
// A protected room must ask before turning a click into a join request.
|
|
53
53
|
if (!joined && approval && !pending && app.confirmAction) {
|
|
54
54
|
void app.confirmAction(app.t("joinApprovalPrompt", { name: room.name })).then((ok) => { if (ok)
|
|
@@ -44,8 +44,11 @@ export async function watchRoom(roomId, app) {
|
|
|
44
44
|
entry.room.participants = latest.participants;
|
|
45
45
|
entry.room.openQuestions = latest.openQuestions;
|
|
46
46
|
if (sawQuestion) {
|
|
47
|
-
app
|
|
48
|
-
|
|
47
|
+
const roomList = app.$("#roomList"), roomListChat = app.$("#roomListChat");
|
|
48
|
+
if (roomList)
|
|
49
|
+
app.renderRoomOptions(roomList, app.state.availableRooms || []);
|
|
50
|
+
if (roomListChat)
|
|
51
|
+
app.renderRoomOptions(roomListChat, app.state.availableRooms || []);
|
|
49
52
|
}
|
|
50
53
|
entry.room.messages = [...new Map([...entry.room.messages, ...latest.messages].map((message) => [message.id, message])).values()].sort((a, b) => a.createdAt - b.createdAt).slice(-LOADED_MESSAGE_LIMIT);
|
|
51
54
|
for (const message of latest.messages)
|
|
@@ -71,9 +74,10 @@ export async function watchRoom(roomId, app) {
|
|
|
71
74
|
await watchRoom(roomId, app);
|
|
72
75
|
}
|
|
73
76
|
catch (error) {
|
|
74
|
-
|
|
77
|
+
const status = error instanceof Error && "status" in error ? error.status : undefined;
|
|
78
|
+
if (status === 401)
|
|
75
79
|
app.openChatSettings();
|
|
76
|
-
else if (
|
|
80
|
+
else if (status === 404)
|
|
77
81
|
await app.removeJoinedRoom(roomId, { reason: false });
|
|
78
82
|
}
|
|
79
83
|
}
|
|
@@ -5,8 +5,11 @@ import { watchRoom } from "./room-watcher.js";
|
|
|
5
5
|
import { cacheRoomSoon, deleteCachedRoom, loadCachedRooms } from "./message-cache.js";
|
|
6
6
|
import { renderRoomOptions } from "./room-list.js";
|
|
7
7
|
import { initPanels } from "./panels.js";
|
|
8
|
+
const statusOf = (error) => error instanceof Error && "status" in error ? error.status : undefined;
|
|
9
|
+
const messageOf = (error) => error instanceof Error ? error.message : "";
|
|
10
|
+
const isNetworkError = (error) => error instanceof Error && "network" in error && Boolean(error.network);
|
|
8
11
|
export function initRooms(app) {
|
|
9
|
-
const $ = app
|
|
12
|
+
const $ = (selector) => app.$(selector);
|
|
10
13
|
initPanels(app);
|
|
11
14
|
let roomListGeneration = 0;
|
|
12
15
|
let autoRefresh;
|
|
@@ -50,20 +53,23 @@ export function initRooms(app) {
|
|
|
50
53
|
$("#chatView").hidden = false;
|
|
51
54
|
};
|
|
52
55
|
app.renderHead = () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
const room = app.state.room;
|
|
57
|
+
if (!room)
|
|
58
|
+
return;
|
|
59
|
+
$("#roomName").textContent = room.name;
|
|
60
|
+
$("#roomIdShort").textContent = room.id.slice(0, 8);
|
|
61
|
+
$("#btnCopyId").title = app.t("copyRoomIdTitle", { id: room.id });
|
|
56
62
|
$("#btnCopyId").setAttribute("aria-label", app.t("copyRoomId"));
|
|
57
63
|
$("#railIdentity").textContent = app.state.myName;
|
|
58
64
|
$("#profileAvatar").textContent = Array.from(app.state.myName.trim())[0]?.toLocaleUpperCase() || "?";
|
|
59
|
-
const description =
|
|
65
|
+
const description = room.description || "";
|
|
60
66
|
$("#roomDescription").textContent = description;
|
|
61
67
|
$("#roomDescription").hidden = !description;
|
|
62
|
-
$("#roomPolicy").hidden =
|
|
68
|
+
$("#roomPolicy").hidden = room.joinPolicy !== "approval";
|
|
63
69
|
// Everyone sees the settings entry; people who cannot manage the room get a
|
|
64
70
|
// secondary style and an explanation. Dissolving the room stays the owner's call.
|
|
65
|
-
const owner = app.state.myName ===
|
|
66
|
-
const admin = owner || (
|
|
71
|
+
const owner = app.state.myName === room.ownerId;
|
|
72
|
+
const admin = owner || (room.adminIds ?? []).includes(app.state.myName);
|
|
67
73
|
$("#btnEditRoom").classList.toggle("menu-secondary", !admin);
|
|
68
74
|
$("#btnDeleteRoom").hidden = !owner;
|
|
69
75
|
app.updateTitle();
|
|
@@ -84,7 +90,7 @@ export function initRooms(app) {
|
|
|
84
90
|
};
|
|
85
91
|
app.ensureJoinedRoom = (room, name) => {
|
|
86
92
|
const existing = app.state.rooms.get(room.id);
|
|
87
|
-
const entry = existing || { unreadIds: new Map(), unreadOverflow: false, preview: "", previewAt: 0, position: 0, readTs: 0, receivedTs: room.messages.at(-1)?.createdAt ?? 0, recallVersion: 0 };
|
|
93
|
+
const entry = existing || { room, name, unreadIds: new Map(), unreadOverflow: false, preview: "", previewAt: 0, position: 0, readTs: 0, receivedTs: room.messages.at(-1)?.createdAt ?? 0, recallVersion: 0 };
|
|
88
94
|
entry.unreadIds ||= new Map();
|
|
89
95
|
entry.unreadOverflow ||= false;
|
|
90
96
|
const latest = room.messages.at(-1), savedReadTs = app.state.lastReadTs.get(room.id) ?? (typeof room.lastReadTs === "number" ? room.lastReadTs : undefined);
|
|
@@ -155,7 +161,7 @@ export function initRooms(app) {
|
|
|
155
161
|
// Cached history can hold thousands of messages. Render the newest window
|
|
156
162
|
// first so switching stays immediate; older rows are prepended on demand.
|
|
157
163
|
app.renderMessages(false, 300);
|
|
158
|
-
app.restoreReadingPosition?.(
|
|
164
|
+
app.restoreReadingPosition?.();
|
|
159
165
|
app.state.readAnchorGuard = null;
|
|
160
166
|
app.startPolling();
|
|
161
167
|
if (entry.recallStale) {
|
|
@@ -168,8 +174,8 @@ export function initRooms(app) {
|
|
|
168
174
|
$("#msgInput").tabIndex = 0;
|
|
169
175
|
$("#msgInput").draftValue = app.state.drafts.get(roomId) || "";
|
|
170
176
|
app.renderReplyPreview?.();
|
|
171
|
-
app.renderFailedMessages();
|
|
172
|
-
app.autoGrow($("#msgInput"));
|
|
177
|
+
app.renderFailedMessages?.();
|
|
178
|
+
app.autoGrow?.($("#msgInput"));
|
|
173
179
|
// A restored draft and late layout can resize the composer after the initial bottom
|
|
174
180
|
// pin. Keep following for a few frames instead of sampling one fragile moment.
|
|
175
181
|
let settleFrames = 0;
|
|
@@ -183,8 +189,8 @@ export function initRooms(app) {
|
|
|
183
189
|
requestAnimationFrame(settleBottom);
|
|
184
190
|
};
|
|
185
191
|
requestAnimationFrame(settleBottom);
|
|
186
|
-
app.updateDraftCount();
|
|
187
|
-
app.updateSendState();
|
|
192
|
+
app.updateDraftCount?.();
|
|
193
|
+
app.updateSendState?.();
|
|
188
194
|
app.hideSendError();
|
|
189
195
|
app.updateBadge();
|
|
190
196
|
app.updateJump();
|
|
@@ -219,7 +225,7 @@ export function initRooms(app) {
|
|
|
219
225
|
app.enterRoom(room, name, intent);
|
|
220
226
|
}
|
|
221
227
|
catch (error) {
|
|
222
|
-
if (error
|
|
228
|
+
if (statusOf(error) === 401) {
|
|
223
229
|
app.state.pendingAction = { type: "join", roomId, name };
|
|
224
230
|
if (app.state.room) {
|
|
225
231
|
app.openChatSettings();
|
|
@@ -230,12 +236,12 @@ export function initRooms(app) {
|
|
|
230
236
|
app.showJoinError("authRetry");
|
|
231
237
|
}
|
|
232
238
|
}
|
|
233
|
-
else if (error
|
|
239
|
+
else if (statusOf(error) === 409) {
|
|
234
240
|
app.showJoinError("joinNameTaken");
|
|
235
241
|
void app.refreshRoomList();
|
|
236
242
|
}
|
|
237
243
|
else {
|
|
238
|
-
app.showJoinError(error
|
|
244
|
+
app.showJoinError(isNetworkError(error) ? "networkRetry" : "joinFailed", { message: messageOf(error) });
|
|
239
245
|
void app.refreshRoomList();
|
|
240
246
|
}
|
|
241
247
|
}
|
|
@@ -246,10 +252,11 @@ export function initRooms(app) {
|
|
|
246
252
|
app.createRoom = async (pending) => {
|
|
247
253
|
if (app.state.joinBusy)
|
|
248
254
|
return;
|
|
249
|
-
const
|
|
250
|
-
const
|
|
251
|
-
const
|
|
252
|
-
const
|
|
255
|
+
const action = pending;
|
|
256
|
+
const fromChat = action?.fromChat ?? Boolean(app.state.room);
|
|
257
|
+
const name = action?.name || (fromChat ? app.state.myName : $("#inName").value.trim()) || LS.name || app.t("guest");
|
|
258
|
+
const roomName = action?.roomName || $(fromChat ? "#inRoomNameChat" : "#inRoomName").value.trim();
|
|
259
|
+
const joinPolicy = action?.joinPolicy ?? ((fromChat ? $("#inApprovalRequiredChat").checked : $("#inApprovalRequired").checked) ? "approval" : "open");
|
|
253
260
|
if (!roomName) {
|
|
254
261
|
if (!fromChat)
|
|
255
262
|
return app.showJoinError("roomNameRequired");
|
|
@@ -282,7 +289,7 @@ export function initRooms(app) {
|
|
|
282
289
|
app.enterRoom(room, name, intent);
|
|
283
290
|
}
|
|
284
291
|
catch (error) {
|
|
285
|
-
if (error
|
|
292
|
+
if (statusOf(error) === 401) {
|
|
286
293
|
app.state.pendingAction = { type: "create", name, roomName, fromChat, joinPolicy };
|
|
287
294
|
if (fromChat) {
|
|
288
295
|
app.closeCreateRoomDialog(false);
|
|
@@ -296,13 +303,13 @@ export function initRooms(app) {
|
|
|
296
303
|
}
|
|
297
304
|
else if (fromChat) {
|
|
298
305
|
if ($("#createRoomDialog")?.open)
|
|
299
|
-
app.showCreateRoomError("createFailed", { message: error
|
|
306
|
+
app.showCreateRoomError("createFailed", { message: messageOf(error) });
|
|
300
307
|
else
|
|
301
|
-
app.showSendError("createFailed", { message: error
|
|
308
|
+
app.showSendError("createFailed", { message: messageOf(error) });
|
|
302
309
|
void app.refreshRoomList();
|
|
303
310
|
}
|
|
304
311
|
else {
|
|
305
|
-
app.showJoinError("createFailed", { message: error
|
|
312
|
+
app.showJoinError("createFailed", { message: messageOf(error) });
|
|
306
313
|
void app.refreshRoomList();
|
|
307
314
|
}
|
|
308
315
|
}
|
|
@@ -384,7 +391,7 @@ export function initRooms(app) {
|
|
|
384
391
|
clearTimeout(app.state.watcherTimer);
|
|
385
392
|
if (!app.state.rooms.size && !app.state.restorePending?.size && !app.state.restoreRetry)
|
|
386
393
|
return;
|
|
387
|
-
app.state.watcherTimer = setTimeout(async () => {
|
|
394
|
+
app.state.watcherTimer = window.setTimeout(async () => {
|
|
388
395
|
// A hidden tab has no reader; skip background room polling until it is
|
|
389
396
|
// visible again (the next timer tick after visibility resumes).
|
|
390
397
|
if (typeof document !== "undefined" && document.hidden) {
|
|
@@ -436,7 +443,7 @@ export function initRooms(app) {
|
|
|
436
443
|
catch (error) {
|
|
437
444
|
if (generation !== roomListGeneration)
|
|
438
445
|
return;
|
|
439
|
-
if (error
|
|
446
|
+
if (statusOf(error) === 401) {
|
|
440
447
|
if (!app.state.room && !app.state.restored) {
|
|
441
448
|
app.showJoin(false);
|
|
442
449
|
app.openTokenBox();
|
|
@@ -455,7 +462,7 @@ export function initRooms(app) {
|
|
|
455
462
|
}
|
|
456
463
|
if (!app.state.restored) {
|
|
457
464
|
app.state.restoreRetry = true;
|
|
458
|
-
app.state.restorePending = new Set([...app.state.joinedIds, LS.roomId].filter(Boolean));
|
|
465
|
+
app.state.restorePending = new Set([...app.state.joinedIds, LS.roomId].filter((id) => Boolean(id)));
|
|
459
466
|
app.startRoomWatcher();
|
|
460
467
|
}
|
|
461
468
|
}
|
|
@@ -472,7 +479,7 @@ export function initRooms(app) {
|
|
|
472
479
|
try {
|
|
473
480
|
const activeId = LS.roomId;
|
|
474
481
|
const directIds = rooms.filter((room) => room.kind === "direct" && room.directSessionIDs?.includes(LS.sessionID)).map((room) => room.id);
|
|
475
|
-
const candidates = [...new Set([activeId, ...rooms.filter((room) => room.joined).map((room) => room.id), ...app.state.joinedIds, ...directIds].filter(Boolean))];
|
|
482
|
+
const candidates = [...new Set([activeId, ...rooms.filter((room) => room.joined).map((room) => room.id), ...app.state.joinedIds, ...directIds].filter((id) => Boolean(id)))];
|
|
476
483
|
const valid = new Set();
|
|
477
484
|
const unresolved = new Set();
|
|
478
485
|
let authFailed = false;
|
|
@@ -495,11 +502,11 @@ export function initRooms(app) {
|
|
|
495
502
|
catch (error) {
|
|
496
503
|
if (generation !== roomListGeneration)
|
|
497
504
|
return;
|
|
498
|
-
if (error
|
|
505
|
+
if (statusOf(error) !== 404) {
|
|
499
506
|
unresolved.add(roomId);
|
|
500
|
-
if (error
|
|
507
|
+
if (statusOf(error) === 401)
|
|
501
508
|
authFailed = true;
|
|
502
|
-
if (error
|
|
509
|
+
if (statusOf(error) === 401)
|
|
503
510
|
app.state.room ? app.openChatSettings() : app.openTokenBox();
|
|
504
511
|
}
|
|
505
512
|
}
|
|
@@ -553,13 +560,13 @@ export function initRooms(app) {
|
|
|
553
560
|
catch (error) {
|
|
554
561
|
if (generation !== roomListGeneration)
|
|
555
562
|
return;
|
|
556
|
-
if (error
|
|
563
|
+
if (statusOf(error) !== 404) {
|
|
557
564
|
app.state.restorePending ||= new Set();
|
|
558
565
|
app.state.restorePending.add(room.id);
|
|
559
566
|
app.state.joinedIds.add(room.id);
|
|
560
567
|
app.saveJoinedIds();
|
|
561
568
|
app.state.restored = false;
|
|
562
|
-
if (error
|
|
569
|
+
if (statusOf(error) === 401)
|
|
563
570
|
app.state.room ? app.openChatSettings() : app.openTokenBox();
|
|
564
571
|
}
|
|
565
572
|
}
|
|
@@ -584,21 +591,22 @@ export function initRooms(app) {
|
|
|
584
591
|
app.saveFailedMessages(room.id, []);
|
|
585
592
|
}
|
|
586
593
|
catch (error) {
|
|
587
|
-
app.showSendError("sendFailed", { message: error
|
|
594
|
+
app.showSendError("sendFailed", { message: messageOf(error) });
|
|
588
595
|
}
|
|
589
596
|
};
|
|
590
597
|
app.copyRoomId = async () => {
|
|
591
598
|
const button = $("#btnCopyId");
|
|
599
|
+
const roomId = app.state.room.id;
|
|
592
600
|
try {
|
|
593
|
-
await navigator.clipboard.writeText(
|
|
601
|
+
await navigator.clipboard.writeText(roomId);
|
|
594
602
|
// Swap a class so the ID span survives; flash() would overwrite the whole
|
|
595
603
|
// button and then restore it to "undefined" (the button has no data-i18n).
|
|
596
604
|
clearTimeout(button._copiedTimer);
|
|
597
605
|
button.classList.add("copied");
|
|
598
|
-
button._copiedTimer = setTimeout(() => button.classList.remove("copied"), 1200);
|
|
606
|
+
button._copiedTimer = window.setTimeout(() => button.classList.remove("copied"), 1200);
|
|
599
607
|
}
|
|
600
608
|
catch {
|
|
601
|
-
app.showSendError("copyFailed", { id:
|
|
609
|
+
app.showSendError("copyFailed", { id: roomId });
|
|
602
610
|
}
|
|
603
611
|
};
|
|
604
612
|
app.autoJoin = async () => {
|
|
@@ -617,8 +625,11 @@ export function initRooms(app) {
|
|
|
617
625
|
async function bounded(items, limit, action) {
|
|
618
626
|
let cursor = 0;
|
|
619
627
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
620
|
-
while (cursor < items.length)
|
|
621
|
-
|
|
628
|
+
while (cursor < items.length) {
|
|
629
|
+
const item = items[cursor++];
|
|
630
|
+
if (item !== undefined)
|
|
631
|
+
await action(item);
|
|
632
|
+
}
|
|
622
633
|
}));
|
|
623
634
|
}
|
|
624
635
|
function syncCachedRooms(rooms, app) {
|
|
@@ -6,6 +6,7 @@ export const SEARCH_RESULT_LIMIT = 100;
|
|
|
6
6
|
export const SEARCH_MESSAGE_LIMIT = LOADED_MESSAGE_LIMIT;
|
|
7
7
|
const PAGE_LIMIT = 100;
|
|
8
8
|
const MAX_PAGES_PER_ROOM = Math.ceil(SEARCH_MESSAGE_LIMIT / PAGE_LIMIT);
|
|
9
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
9
10
|
export function initSearch(app) {
|
|
10
11
|
app.searchMessages = (query, scope = "room") => searchMessages(app, query, scope);
|
|
11
12
|
app.openSearchHit = (hit) => openSearchHit(app, hit);
|
|
@@ -48,14 +49,14 @@ export async function openSearchHit(app, hit) {
|
|
|
48
49
|
return false;
|
|
49
50
|
try {
|
|
50
51
|
const page = await app.api(`/rooms/${encodeURIComponent(roomId)}/history?beforeSeq=${seq + 1}&limit=${PAGE_LIMIT}`);
|
|
51
|
-
if (app.state.rooms.get(roomId) !== entry)
|
|
52
|
+
if (app.state.rooms.get(roomId) !== entry || !isRecord(page))
|
|
52
53
|
return false;
|
|
53
54
|
const messages = Array.isArray(page.messages) ? page.messages : [];
|
|
54
55
|
mergeHistory(entry, roomId, messages);
|
|
55
56
|
if (page.hasMore) {
|
|
56
57
|
// Continue upward pagination from the oldest message now loaded.
|
|
57
58
|
const oldest = entry.room.messages.find((message) => Number.isSafeInteger(message.seq))?.seq;
|
|
58
|
-
if (Number.isSafeInteger(oldest))
|
|
59
|
+
if (typeof oldest === "number" && Number.isSafeInteger(oldest))
|
|
59
60
|
entry.historyBeforeSeq = oldest;
|
|
60
61
|
}
|
|
61
62
|
else {
|
|
@@ -80,7 +81,7 @@ export async function openSearchHit(app, hit) {
|
|
|
80
81
|
app.state.readAnchorGuard = null;
|
|
81
82
|
app.renderMessages(false);
|
|
82
83
|
const row = document.querySelector(`[data-msg-id="${CSS.escape(messageId)}"]`);
|
|
83
|
-
if (!row)
|
|
84
|
+
if (!(row instanceof HTMLElement))
|
|
84
85
|
return false;
|
|
85
86
|
flashMessageRow(app, row);
|
|
86
87
|
return true;
|
|
@@ -117,8 +118,9 @@ async function collectRoomHits(app, roomId, needle, hits) {
|
|
|
117
118
|
while (!entry.historyComplete && Number.isSafeInteger(entry.historyBeforeSeq)
|
|
118
119
|
&& entry.room.messages.length < SEARCH_MESSAGE_LIMIT && pages++ < MAX_PAGES_PER_ROOM) {
|
|
119
120
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
121
|
+
const beforeSeq = typeof entry.historyBeforeSeq === "number" ? entry.historyBeforeSeq : 0;
|
|
122
|
+
const page = await app.api(`/rooms/${encodeURIComponent(roomId)}/history?beforeSeq=${beforeSeq}&limit=${PAGE_LIMIT}`);
|
|
123
|
+
if (app.state.rooms.get(roomId) !== entry || !isRecord(page))
|
|
122
124
|
return;
|
|
123
125
|
const messages = Array.isArray(page.messages) ? page.messages : [];
|
|
124
126
|
scan(messages);
|
|
@@ -127,7 +129,7 @@ async function collectRoomHits(app, roomId, needle, hits) {
|
|
|
127
129
|
entry.historyComplete = !page.hasMore;
|
|
128
130
|
if (entry.historyComplete)
|
|
129
131
|
entry.historyBeforeSeq = null;
|
|
130
|
-
else if (next === null || next >=
|
|
132
|
+
else if (next === null || next >= beforeSeq)
|
|
131
133
|
break;
|
|
132
134
|
else
|
|
133
135
|
entry.historyBeforeSeq = next;
|