From 38d0750dd3c493e1d89b2b9b5c5f8bf0b07c425f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 19 Aug 2023 05:04:40 -0400 Subject: [PATCH] Don't include parent title in tab title for secondary attachments As suggested in https://github.com/zotero/zotero/issues/2731#issuecomment-1201382522 --- chrome/content/zotero/xpcom/reader.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index a88c204f1b..cc935e2684 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -548,13 +548,17 @@ class ReaderInstance { readerTitle = item.attachmentFilename; } else if (parentItem) { + let attachment = await parentItem.getBestAttachment(); + let isPrimaryAttachment = attachment && attachment.id == item.id; + let parts = []; // Windows displays bidi control characters as placeholders in window titles, so strip them // See https://github.com/mozilla-services/screenshots/issues/4863 let unformatted = Zotero.isWin; let creator = parentItem.getField('firstCreator', unformatted); let year = parentItem.getField('year'); - let title = parentItem.getDisplayTitle(); + // Only include parent title if primary attachment + let title = isPrimaryAttachment ? parentItem.getDisplayTitle() : false; // If creator is missing fall back to titleCreatorYear if (type === 'creatorYearTitle' && creator) { parts = [creator, year, title]; @@ -567,9 +571,8 @@ class ReaderInstance { parts = [title, creator, year]; } - // If not primary attachment, add attachment title - let attachment = await parentItem.getBestAttachment(); - if (!attachment || attachment.id != item.id) { + // If not primary attachment, show attachment title first + if (!isPrimaryAttachment) { parts.unshift(item.getDisplayTitle()); }