|
|
@@ -38,6 +38,7 @@ type State = {
|
|
|
config: Config
|
|
|
path: Path
|
|
|
session: Session[]
|
|
|
+ sessionTotal: number
|
|
|
session_status: {
|
|
|
[sessionID: string]: SessionStatus
|
|
|
}
|
|
|
@@ -98,6 +99,7 @@ function createGlobalSync() {
|
|
|
agent: [],
|
|
|
command: [],
|
|
|
session: [],
|
|
|
+ sessionTotal: 0,
|
|
|
session_status: {},
|
|
|
session_diff: {},
|
|
|
todo: {},
|
|
|
@@ -117,8 +119,10 @@ function createGlobalSync() {
|
|
|
|
|
|
async function loadSessions(directory: string) {
|
|
|
const [store, setStore] = child(directory)
|
|
|
- globalSDK.client.session
|
|
|
- .list({ directory })
|
|
|
+ const limit = store.limit
|
|
|
+
|
|
|
+ return globalSDK.client.session
|
|
|
+ .list({ directory, roots: true })
|
|
|
.then((x) => {
|
|
|
const fourHoursAgo = Date.now() - 4 * 60 * 60 * 1000
|
|
|
const nonArchived = (x.data ?? [])
|
|
|
@@ -128,10 +132,12 @@ function createGlobalSync() {
|
|
|
.sort((a, b) => a.id.localeCompare(b.id))
|
|
|
// Include up to the limit, plus any updated in the last 4 hours
|
|
|
const sessions = nonArchived.filter((s, i) => {
|
|
|
- if (i < store.limit) return true
|
|
|
+ if (i < limit) return true
|
|
|
const updated = new Date(s.time?.updated ?? s.time?.created).getTime()
|
|
|
return updated > fourHoursAgo
|
|
|
})
|
|
|
+ // Store total session count (used for "load more" pagination)
|
|
|
+ setStore("sessionTotal", nonArchived.length)
|
|
|
setStore("session", reconcile(sessions, { key: "id" }))
|
|
|
})
|
|
|
.catch((err) => {
|