mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-10 07:16:33 -04:00
Fix #5492: sort :back by newest members
This commit is contained in:
parent
20f60a2119
commit
1f4c5a2c33
|
|
@ -68,7 +68,7 @@ export class TabHistoryCompletionSource extends Completions.CompletionSourceFuse
|
|||
href: node["href"],
|
||||
parent: node["parent"],
|
||||
id: node["id"],
|
||||
level: node["level"] === 0 ? node["level"] : node["level"] - 1,
|
||||
level: node["level"],
|
||||
time: node["time"],
|
||||
})
|
||||
for (const child of node["children"]) {
|
||||
|
|
@ -77,6 +77,17 @@ export class TabHistoryCompletionSource extends Completions.CompletionSourceFuse
|
|||
return flat
|
||||
}
|
||||
|
||||
private sortPathsOldestFirst(tree) {
|
||||
for (const node of tree) {
|
||||
this.sortPathsOldestFirst(node["children"])
|
||||
node["latestTime"] = Math.max(
|
||||
node["time"],
|
||||
...node["children"].map(child => child["latestTime"]),
|
||||
)
|
||||
}
|
||||
tree.sort((a, b) => a["latestTime"] - b["latestTime"])
|
||||
}
|
||||
|
||||
private addFormatTimeSpan(tree) {
|
||||
const now = Date.now()
|
||||
for (const node of tree) {
|
||||
|
|
@ -111,6 +122,7 @@ export class TabHistoryCompletionSource extends Completions.CompletionSourceFuse
|
|||
if (!history) history = { list: [] }
|
||||
const tree = this.makeTree(history["list"])
|
||||
if (tree.length > 0) {
|
||||
this.sortPathsOldestFirst(tree[0]["children"])
|
||||
history["list"] = this.flattenTree(tree[0]).reverse()
|
||||
}
|
||||
this.addFormatTimeSpan(history["list"])
|
||||
|
|
|
|||
Loading…
Reference in a new issue