|
@@ -119,15 +119,25 @@ export function DialogSessionList() {
|
|
|
))
|
|
))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function orderByRecency(sessionsList: NonNullable<ReturnType<typeof sessions>>) {
|
|
|
|
|
+ return sessionsList
|
|
|
|
|
+ .filter((x) => x.parentID === undefined)
|
|
|
|
|
+ .toSorted((a, b) => b.time.updated - a.time.updated)
|
|
|
|
|
+ .map((x) => x.id)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const [browseOrder] = createSignal<string[]>(orderByRecency(sync.data.session))
|
|
|
|
|
+
|
|
|
const options = createMemo(() => {
|
|
const options = createMemo(() => {
|
|
|
const today = new Date().toDateString()
|
|
const today = new Date().toDateString()
|
|
|
- return sessions()
|
|
|
|
|
- .filter((x) => x.parentID === undefined)
|
|
|
|
|
- .toSorted((a, b) => {
|
|
|
|
|
- const updatedDay = new Date(b.time.updated).setHours(0, 0, 0, 0) - new Date(a.time.updated).setHours(0, 0, 0, 0)
|
|
|
|
|
- if (updatedDay !== 0) return updatedDay
|
|
|
|
|
- return b.time.created - a.time.created
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ const sessionMap = new Map(sessions().filter((x) => x.parentID === undefined).map((x) => [x.id, x]))
|
|
|
|
|
+
|
|
|
|
|
+ const searchResult = searchResults()
|
|
|
|
|
+ const displayOrder = searchResult ? orderByRecency(searchResult) : browseOrder()
|
|
|
|
|
+
|
|
|
|
|
+ return displayOrder
|
|
|
|
|
+ .map((id) => sessionMap.get(id))
|
|
|
|
|
+ .filter((x) => x !== undefined)
|
|
|
.map((x) => {
|
|
.map((x) => {
|
|
|
const workspace = x.workspaceID ? project.workspace.get(x.workspaceID) : undefined
|
|
const workspace = x.workspaceID ? project.workspace.get(x.workspaceID) : undefined
|
|
|
|
|
|