mirror of
https://github.com/zotero/zotero.git
synced 2026-10-03 02:21:49 +00:00
citation dlg: fix hang when main window is closed
When fetching open tabs for the citation dialog, fall back to the last saved session state if the main window is closed. Session state was already being updated when zotero pane is closed. Fixes: #5661
This commit is contained in:
parent
ead0924a79
commit
be8c64b2bf
1 changed files with 11 additions and 1 deletions
|
|
@ -273,8 +273,18 @@ export class CitationDialogSearchHandler {
|
|||
|
||||
async _getReaderOpenItems() {
|
||||
if (this.isCitingNotes) return [];
|
||||
let tabs = [];
|
||||
let win = Zotero.getMainWindow();
|
||||
let tabs = win.Zotero_Tabs.getState();
|
||||
// If the main window is open, use it to get open tabs
|
||||
if (win) {
|
||||
tabs = win.Zotero_Tabs.getState();
|
||||
}
|
||||
// If the main window is closed, try to get tabs from the last saved session
|
||||
else {
|
||||
let mainWindowLastState = Zotero.Session.state.windows.find(w => w.type === 'pane');
|
||||
if (!mainWindowLastState) return [];
|
||||
tabs = mainWindowLastState.tabs;
|
||||
}
|
||||
let itemIDs = tabs.filter(t => t.type === 'reader').sort((a, b) => {
|
||||
// Sort selected tab first
|
||||
if (a.selected) return -1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue