Fix page navigator ordering regressions
parent
bedc85e7a9
commit
da88c9c6ed
|
@ -2,6 +2,7 @@ import { FilterList } from "./filter.tsx";
|
||||||
import { FilterOption } from "../types.ts";
|
import { FilterOption } from "../types.ts";
|
||||||
import { CompletionContext, CompletionResult } from "../deps.ts";
|
import { CompletionContext, CompletionResult } from "../deps.ts";
|
||||||
import { PageMeta } from "$sb/types.ts";
|
import { PageMeta } from "$sb/types.ts";
|
||||||
|
import { isFederationPath } from "$sb/lib/resolve.ts";
|
||||||
|
|
||||||
export function PageNavigator({
|
export function PageNavigator({
|
||||||
allPages,
|
allPages,
|
||||||
|
@ -21,7 +22,7 @@ export function PageNavigator({
|
||||||
const options: FilterOption[] = [];
|
const options: FilterOption[] = [];
|
||||||
for (const pageMeta of allPages) {
|
for (const pageMeta of allPages) {
|
||||||
// Order by last modified date in descending order
|
// Order by last modified date in descending order
|
||||||
let orderId = -pageMeta.lastModified;
|
let orderId = -new Date(pageMeta.lastModified).getTime();
|
||||||
// Unless it was opened in this session
|
// Unless it was opened in this session
|
||||||
if (pageMeta.lastOpened) {
|
if (pageMeta.lastOpened) {
|
||||||
orderId = -pageMeta.lastOpened;
|
orderId = -pageMeta.lastOpened;
|
||||||
|
@ -31,6 +32,11 @@ export function PageNavigator({
|
||||||
// ... then we put it all the way to the end
|
// ... then we put it all the way to the end
|
||||||
orderId = Infinity;
|
orderId = Infinity;
|
||||||
}
|
}
|
||||||
|
// And deprioritize federated pages too
|
||||||
|
if (isFederationPath(pageMeta.name)) {
|
||||||
|
orderId = Math.round(orderId / 10); // Just 10x lower the timestamp to push them down, should work
|
||||||
|
console.log("Deprioritizing", pageMeta);
|
||||||
|
}
|
||||||
options.push({
|
options.push({
|
||||||
...pageMeta,
|
...pageMeta,
|
||||||
orderId: orderId,
|
orderId: orderId,
|
||||||
|
|
Loading…
Reference in New Issue