@agenticmail/api 0.9.7 → 0.9.8
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/public/js/app.js +25 -11
package/package.json
CHANGED
package/public/js/app.js
CHANGED
|
@@ -179,10 +179,20 @@ function onFolderSelect(folder) {
|
|
|
179
179
|
// Folder switches go through here too so the URL is the source of truth
|
|
180
180
|
// for "what's on screen". If you bookmark or copy-paste a URL like
|
|
181
181
|
// http://127.0.0.1:3829/#/folder/sent, opening it lands you on Sent.
|
|
182
|
+
// Track which view shape is currently on screen so the router knows
|
|
183
|
+
// whether navigating back to #/folder/<x> for the SAME folder should
|
|
184
|
+
// re-render the list. Without this, hitting Back from #/m/54 to
|
|
185
|
+
// #/folder/inbox would early-return because state.selectedFolder is
|
|
186
|
+
// still 'inbox' (it never changed when the message opened) — leaving
|
|
187
|
+
// the message-detail view stuck on screen even though the URL bar
|
|
188
|
+
// flipped back to the folder.
|
|
189
|
+
let currentView = 'folder'; // 'folder' | 'message' | 'draft'
|
|
190
|
+
|
|
182
191
|
function route() {
|
|
183
192
|
const hash = location.hash || '#/inbox';
|
|
184
193
|
const msgMatch = hash.match(/^#\/m\/(\d+)$/);
|
|
185
194
|
if (msgMatch) {
|
|
195
|
+
currentView = 'message';
|
|
186
196
|
openMessage(Number(msgMatch[1]));
|
|
187
197
|
return;
|
|
188
198
|
}
|
|
@@ -191,23 +201,27 @@ function route() {
|
|
|
191
201
|
// row click handler emits #/d/<uuid> for draft rows.
|
|
192
202
|
const draftMatch = hash.match(/^#\/d\/([a-zA-Z0-9-]+)$/);
|
|
193
203
|
if (draftMatch) {
|
|
204
|
+
currentView = 'draft';
|
|
194
205
|
openDraft(draftMatch[1]);
|
|
195
206
|
return;
|
|
196
207
|
}
|
|
197
208
|
const folderMatch = hash.match(/^#\/folder\/([a-z]+)$/);
|
|
198
209
|
const folder = folderMatch ? folderMatch[1] : 'inbox';
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
|
|
210
|
+
// Skip the reload ONLY when we're already showing this folder's
|
|
211
|
+
// list view. Coming back from a message / draft → folder must
|
|
212
|
+
// always re-render the list, even if state.selectedFolder hasn't
|
|
213
|
+
// changed since the message was opened.
|
|
214
|
+
if (currentView === 'folder' && state.selectedFolder === folder) return;
|
|
215
|
+
const folderChanged = state.selectedFolder !== folder;
|
|
205
216
|
state.selectedFolder = folder;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
217
|
+
currentView = 'folder';
|
|
218
|
+
if (folderChanged) {
|
|
219
|
+
// Fresh folder → page 1. Preserved across silent SSE refreshes so
|
|
220
|
+
// a new arrival doesn't yank the user back from page 3. We also
|
|
221
|
+
// re-render the sidebar so the active-folder highlight updates.
|
|
222
|
+
state.pagination = { offset: 0, limit: 50, total: 0 };
|
|
223
|
+
renderSidebar(onFolderSelect);
|
|
224
|
+
}
|
|
211
225
|
if (state.selectedAgent) loadList(state.selectedAgent, folder);
|
|
212
226
|
}
|
|
213
227
|
window.addEventListener('hashchange', route);
|