Skip to content

Commit

Permalink
Add a preference controlling whether to detach the scheduling popup
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jikamens committed Sep 2, 2024
1 parent 143a557 commit db9f1b4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 38 deletions.
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": ""
Expand Down
69 changes: 32 additions & 37 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions ui/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@
<span class="option-label">__MSG_SubfolderPreference__</span>
<input type="text" id="subfolderName" class="preference">
</label>
<label>
<input type="checkbox" id="detachedPopup" class="preferences"/>
<span class="option-label">__MSG_detachedPopupPreference__</span>
</label>
</section>

<section>
Expand Down
3 changes: 2 additions & 1 deletion utils/defaultPrefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"storeInSubfolder": ["boolean", false],
"subfolderName": ["string", ""],
"compactDrafts": ["boolean", false],
"autoUpdateDraftsFolders": ["boolean", false]
"autoUpdateDraftsFolders": ["boolean", false],
"detachedPopup": ["boolean", true]
}

0 comments on commit db9f1b4

Please sign in to comment.