chore(window): initialize closed time of openNoteContents to 0

This commit is contained in:
SiriusXT 2026-01-01 14:30:01 +08:00
parent 9c9e123e3d
commit 1078107776
5 changed files with 8 additions and 14 deletions

View File

@ -60,7 +60,7 @@ export default class TabManager extends Component {
savedWindows.push({
windowId: appContext.windowId,
createdAt: Date.now(),
closedAt: null,
closedAt: 0,
contexts: openNoteContexts
});
}
@ -154,7 +154,7 @@ export default class TabManager extends Component {
savedWindows.push({
windowId: appContext.windowId,
createdAt: Date.now(),
closedAt: null,
closedAt: 0,
contexts: filteredNoteContexts
});
}

View File

@ -34,7 +34,7 @@ export default () => {
{
windowId: "main",
createdAt: 0,
closedAt: null,
closedAt: 0,
contexts: parsed
}
];

View File

@ -47,7 +47,7 @@ async function initNotSyncedOptions(initialized: boolean, opts: NotSyncedOpts =
{
windowId: "main",
createdAt: 0,
closedAt: null,
closedAt: 0,
contexts: [
{
notePath: "root",
@ -266,7 +266,7 @@ function initStartupOptions() {
{
windowId: "main",
createdAt: 0,
closedAt: null,
closedAt: 0,
contexts: [
{
notePath: process.env.TRILIUM_START_NOTE_ID || "root",

View File

@ -149,7 +149,7 @@ async function createInitialDatabase(skipDemoDb?: boolean) {
{
windowId: "main",
createdAt: 0,
closedAt: null,
closedAt: 0,
contexts: [
{
notePath: startNoteId,

View File

@ -201,15 +201,9 @@ function updateTrayMenu() {
const openedWindowIds = windowService.getAllWindowIds();
const closedWindows = savedWindows
.filter(win => !openedWindowIds.includes(win.windowId))
.sort((a, b) => {
// If closedAt is null, it indicates an abnormal closure and should be placed at the end
if (a.closedAt === null && b.closedAt === null) return 0;
if (a.closedAt === null) return 1;
if (b.closedAt === null) return -1;
// Otherwise, sort by time in descending order
return b.closedAt - a.closedAt;
});
.sort((a, b) => { return b.closedAt - a.closedAt; }); // sort by time in descending order
const menuItems: Electron.MenuItemConstructorOptions[] = [];
for (const win of closedWindows) {
const activeCtx = win.contexts.find(c => c.active === true);
const activateNotePath = (activeCtx ?? win.contexts[0])?.notePath;