mirror of
https://github.com/zadam/trilium.git
synced 2026-01-02 20:54:24 +01:00
chore(window): avoid reduce error when no candidates
This commit is contained in:
parent
0af7b8b145
commit
2e30683b7b
@ -144,10 +144,12 @@ export default class TabManager extends Component {
|
||||
// Filter out the oldest entry (excluding the main window)
|
||||
if (savedWindows?.length >= MAX_SAVED_WINDOWS) {
|
||||
const candidates = savedWindows.filter(w => w.windowId !== "main");
|
||||
const oldest = candidates.reduce((a, b) =>
|
||||
a.createdAt < b.createdAt ? a : b
|
||||
);
|
||||
savedWindows.splice(savedWindows.indexOf(oldest), 1);
|
||||
if (candidates.length > 0) {
|
||||
const oldest = candidates.reduce((a, b) =>
|
||||
a.createdAt < b.createdAt ? a : b
|
||||
);
|
||||
savedWindows.splice(savedWindows.indexOf(oldest), 1);
|
||||
}
|
||||
}
|
||||
savedWindows.push({
|
||||
windowId: appContext.windowId,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user