ai_co_discuss 0.4.59 → 0.4.60
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/package.json +1 -1
- package/web/app.js +25 -0
- package/web/modern.js +1 -1
package/package.json
CHANGED
package/web/app.js
CHANGED
|
@@ -1155,8 +1155,32 @@ function remember_room(room_id) {
|
|
|
1155
1155
|
request_json("/api/rooms/last", { room_id }).catch(() => {});
|
|
1156
1156
|
}
|
|
1157
1157
|
|
|
1158
|
+
// Each room keeps its unsent composer (text, files, reply) while another room is open, until this page closes.
|
|
1159
|
+
const room_composer_drafts = new Map();
|
|
1160
|
+
|
|
1161
|
+
/** Keep the open room's unsent text, files and reply aside; true when there was something to keep. */
|
|
1162
|
+
function keep_room_composer() {
|
|
1163
|
+
const room_id = state.room?.id;
|
|
1164
|
+
if (!room_id) return false;
|
|
1165
|
+
const text = element("message-input").value;
|
|
1166
|
+
const reply = state.reply_to ? { id: state.reply_to, label: element("reply-label").textContent } : null;
|
|
1167
|
+
if (!text.trim() && !state.attachment_drafts.length && !reply) { room_composer_drafts.delete(room_id); return false; }
|
|
1168
|
+
room_composer_drafts.set(room_id, { text, drafts: state.attachment_drafts, reply });
|
|
1169
|
+
state.attachment_drafts = [];
|
|
1170
|
+
return true;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
/** Put back what the room had in its composer when it was left. */
|
|
1174
|
+
function restore_room_composer(room_id) {
|
|
1175
|
+
const kept = room_id && room_composer_drafts.get(room_id);
|
|
1176
|
+
if (!kept) return;
|
|
1177
|
+
room_composer_drafts.delete(room_id);
|
|
1178
|
+
fill_composer(kept.text, kept.drafts, kept.reply);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1158
1181
|
async function select_room(room_id) {
|
|
1159
1182
|
if (room_id) { state.welcome = false; state.welcome_folder = null; }
|
|
1183
|
+
keep_room_composer();
|
|
1160
1184
|
state.navigation_version++;
|
|
1161
1185
|
state.refresh_version++;
|
|
1162
1186
|
const listed = state.rooms.find((room) => room.id === room_id);
|
|
@@ -1189,6 +1213,7 @@ async function select_room(room_id) {
|
|
|
1189
1213
|
element("search-input").value = "";
|
|
1190
1214
|
element("mention-filter").setAttribute("aria-pressed", "false");
|
|
1191
1215
|
cancel_reply();
|
|
1216
|
+
restore_room_composer(state.room?.id);
|
|
1192
1217
|
select_tab("discussion", { refresh: false });
|
|
1193
1218
|
history.replaceState(null, "", state.room ? `/?room=${encodeURIComponent(room_id)}` : "/");
|
|
1194
1219
|
if (state.room) remember_room(room_id);
|