From db9f1b478fb424b259de864501a17b53545f3147 Mon Sep 17 00:00:00 2001 From: Jonathan Kamens Date: Sun, 1 Sep 2024 20:34:26 -0400 Subject: [PATCH] Add a preference controlling whether to detach the scheduling popup Add a preference controlling whether the scheduling popup should be detached from the compose window. Right now, the default value of this preference is true, i.e., the previous behavior is preserved, because [Thunderbird bug 1916112][bug1916112] means that at least for some people the popup window will be blank when it is attached to the compose window, so we're not ready to restore that behavior yet. [bug1916112]: https://bugzilla.mozilla.org/show_bug.cgi?id=1916112 --- _locales/en/messages.json | 4 +++ background.js | 69 ++++++++++++++++++--------------------- ui/options.html | 4 +++ utils/defaultPrefs.json | 3 +- 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index facaeb82..f3484c77 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -717,6 +717,10 @@ "message": "Store scheduled messages in subfolder called:", "description": "In preferences tab, preceded by a checkbox and followed by a text input" }, + "detachedPopupPreference": { + "message": "Detach scheduling popup from compose window", + "description": "In preferences tab, preceded by a checkbox" + }, "ScheduledMessagesWarningQuitRequested": { "message": "There are messages scheduled to be sent. Send Later can only send messages when $1 is running. Are you sure you want to exit?", "description": "" diff --git a/background.js b/background.js index 47bcbd5c..9eb47ccb 100644 --- a/background.js +++ b/background.js @@ -1691,18 +1691,15 @@ const SendLater = { window = await messenger.windows.get(window.id, { populate: true }); SLStatic.info("Opened new window", window); - // We are always using the detached pop-up now because of - // https://github.com/Extended-Thunder/send-later/issues/663, - // so we don't need to do this. - // await SLStatic.tb115(false, async () => { - // // Ensure that the composeAction button is visible, - // // otherwise the popup action will silently fail. - // try { - // await messenger.SL3U.forceToolbarVisible(window.id); - // } catch (ex) { - // SLStatic.error("SL3U.forceToolbarVisible", ex); - // } - // }); + await SLStatic.tb115(false, async () => { + // Ensure that the composeAction button is visible, + // otherwise the popup action will silently fail. + try { + await messenger.SL3U.forceToolbarVisible(window.id); + } catch (ex) { + SLStatic.error("SL3U.forceToolbarVisible", ex); + } + }); // Bind listeners to overlay components like File>Send, // Send Later, and keycodes like Ctrl+enter, etc. @@ -1829,31 +1826,29 @@ const SendLater = { } } - // Always use the detached popup, because of - // https://github.com/Extended-Thunder/send-later/issues/663. - await detachedPopup(); - // await SLStatic.tb115( - // async () => { - // // The onClicked event on the compose action button doesn't fire if a - // // pop-up is configured, so we have to set and open the popup here and - // // then immediately unset the popup so that we can catch the key binding - // // if the user clicks again with a modifier. - // messenger.composeAction.setPopup({ popup: "ui/popup.html" }); - // try { - // if (!(await messenger.composeAction.openPopup())) { - // SLStatic.info( - // "composeAction pop-up failed to open, trying standalone", - // ); - // return await detachedPopup(); - // } - // } finally { - // messenger.composeAction.setPopup({ popup: null }); - // } - // }, - // async () => { - // return await detachedPopup(); - // }, - // ); + await SLStatic.tb128( + async () => { + if (SendLater.prefCache.detachedPopup) return await detachedPopup(); + // The onClicked event on the compose action button doesn't fire if a + // pop-up is configured, so we have to set and open the popup here and + // then immediately unset the popup so that we can catch the key binding + // if the user clicks again with a modifier. + messenger.composeAction.setPopup({ popup: "ui/popup.html" }); + try { + if (!(await messenger.composeAction.openPopup())) { + SLStatic.info( + "composeAction pop-up failed to open, trying standalone", + ); + await detachedPopup(); + } + } finally { + messenger.composeAction.setPopup({ popup: null }); + } + }, + async () => { + await detachedPopup(); + }, + ); }, // Custom events that are attached to user actions within diff --git a/ui/options.html b/ui/options.html index f2214ce9..055372cb 100644 --- a/ui/options.html +++ b/ui/options.html @@ -193,6 +193,10 @@ __MSG_SubfolderPreference__ +
diff --git a/utils/defaultPrefs.json b/utils/defaultPrefs.json index 22642021..fe9871ab 100644 --- a/utils/defaultPrefs.json +++ b/utils/defaultPrefs.json @@ -55,5 +55,6 @@ "storeInSubfolder": ["boolean", false], "subfolderName": ["string", ""], "compactDrafts": ["boolean", false], - "autoUpdateDraftsFolders": ["boolean", false] + "autoUpdateDraftsFolders": ["boolean", false], + "detachedPopup": ["boolean", true] }