mirror of
https://github.com/Extended-Thunder/send-later.git
synced 2025-12-11 20:37:48 +01:00
Set prettier line width to 79 to make code look better in Emacs
This commit is contained in:
@@ -1 +1 @@
|
||||
{}
|
||||
{ "printWidth": 79 }
|
||||
|
||||
@@ -127,7 +127,9 @@ const SendLater = {
|
||||
SLStatic.debug(`Pre-send check initiated at ${now}`);
|
||||
let check = await messenger.SL3U.GenericPreSendCheck();
|
||||
if (!check) {
|
||||
SLStatic.warn(`Canceled via pre-send checks (check initiated at ${now})`);
|
||||
SLStatic.warn(
|
||||
`Canceled via pre-send checks (check initiated at ${now})`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
// let windowId = await messenger.tabs.get(tabId).then(
|
||||
@@ -1123,10 +1125,12 @@ const SendLater = {
|
||||
|
||||
// Check if original message has x-send-later headers
|
||||
if (originalMsgPart.headers.hasOwnProperty("x-send-later-at")) {
|
||||
let { preferences, scheduleCache } = await messenger.storage.local.get({
|
||||
preferences: {},
|
||||
scheduleCache: {},
|
||||
});
|
||||
let { preferences, scheduleCache } = await messenger.storage.local.get(
|
||||
{
|
||||
preferences: {},
|
||||
scheduleCache: {},
|
||||
},
|
||||
);
|
||||
|
||||
// Re-save message (drops x-send-later headers by default
|
||||
// because they are not loaded when editing as draft).
|
||||
@@ -1233,7 +1237,9 @@ const SendLater = {
|
||||
} else if (SendLater.prefCache.sendDoesDelay) {
|
||||
// Schedule with delay.
|
||||
const sendDelay = SendLater.prefCache.sendDelay;
|
||||
SLStatic.info(`Scheduling Send Later ${sendDelay} minutes from now.`);
|
||||
SLStatic.info(
|
||||
`Scheduling Send Later ${sendDelay} minutes from now.`,
|
||||
);
|
||||
let curTab = await SLTools.getActiveComposeTab();
|
||||
if (curTab) {
|
||||
await SendLater.scheduleSendLater(curTab.id, { delay: sendDelay });
|
||||
@@ -1241,7 +1247,9 @@ const SendLater = {
|
||||
} else {
|
||||
let curTab = await SLTools.getActiveComposeTab();
|
||||
if (curTab) {
|
||||
await messenger.compose.sendMessage(curTab.id, { mode: "sendNow" });
|
||||
await messenger.compose.sendMessage(curTab.id, {
|
||||
mode: "sendNow",
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1376,9 +1384,8 @@ const SendLater = {
|
||||
}
|
||||
case "getScheduleText": {
|
||||
try {
|
||||
const dispMsgHdr = await messenger.messageDisplay.getDisplayedMessage(
|
||||
message.tabId,
|
||||
);
|
||||
const dispMsgHdr =
|
||||
await messenger.messageDisplay.getDisplayedMessage(message.tabId);
|
||||
const fullMsg = await messenger.messages.getFull(dispMsgHdr.id);
|
||||
|
||||
const preferences = await SLTools.getPrefs();
|
||||
@@ -1578,7 +1585,10 @@ const SendLater = {
|
||||
for (let hdrName in msgParts.headers) {
|
||||
hdrs[hdrName] = msgParts.headers[hdrName][0];
|
||||
}
|
||||
const { cellText } = SLStatic.customHdrToScheduleInfo(hdrs, instanceUUID);
|
||||
const { cellText } = SLStatic.customHdrToScheduleInfo(
|
||||
hdrs,
|
||||
instanceUUID,
|
||||
);
|
||||
if (preferences.showHeader === true && cellText !== "") {
|
||||
await messenger.headerView
|
||||
.addCustomHdrRow(tab.windowId, headerName, cellText)
|
||||
@@ -1586,7 +1596,10 @@ const SendLater = {
|
||||
SLStatic.error("headerView.addCustomHdrRow", ex);
|
||||
});
|
||||
} else {
|
||||
await messenger.headerView.removeCustomHdrRow(tab.windowId, headerName);
|
||||
await messenger.headerView.removeCustomHdrRow(
|
||||
tab.windowId,
|
||||
headerName,
|
||||
);
|
||||
}
|
||||
|
||||
let msg = await messenger.messages.getFull(hdr.id);
|
||||
@@ -1650,7 +1663,9 @@ const SendLater = {
|
||||
`${messenger.i18n.getMessage("extensionName")} ` +
|
||||
`[${messenger.i18n.getMessage("DisabledMessage")}]`,
|
||||
});
|
||||
await SLStatic.nofail(messenger.browserAction.setBadgeText, { text: null });
|
||||
await SLStatic.nofail(messenger.browserAction.setBadgeText, {
|
||||
text: null,
|
||||
});
|
||||
await SLStatic.nofail(messenger.composeAction.disable);
|
||||
await SLStatic.nofail(messenger.messageDisplayAction.disable);
|
||||
await SLStatic.nofail(messenger.messageDisplayAction.setPopup, {
|
||||
@@ -1752,7 +1767,11 @@ async function mainLoop() {
|
||||
nActive,
|
||||
Promise.all([enablePromise, titlePromise]),
|
||||
);
|
||||
await SendLater.setQuitNotificationsEnabled(true, preferences, nActive);
|
||||
await SendLater.setQuitNotificationsEnabled(
|
||||
true,
|
||||
preferences,
|
||||
nActive,
|
||||
);
|
||||
|
||||
SendLater.previousLoop = new Date();
|
||||
SendLater.loopTimeout = setDeferred(
|
||||
@@ -1760,12 +1779,18 @@ async function mainLoop() {
|
||||
60000 * interval,
|
||||
mainLoop,
|
||||
);
|
||||
SLStatic.debug(`Next main loop iteration in ${60 * interval} seconds.`);
|
||||
SLStatic.debug(
|
||||
`Next main loop iteration in ${60 * interval} seconds.`,
|
||||
);
|
||||
} catch (err) {
|
||||
SLStatic.error(err);
|
||||
let nActive = await SLTools.countActiveScheduledMessages();
|
||||
await SendLater.updateStatusIndicator(nActive);
|
||||
await SendLater.setQuitNotificationsEnabled(true, preferences, nActive);
|
||||
await SendLater.setQuitNotificationsEnabled(
|
||||
true,
|
||||
preferences,
|
||||
nActive,
|
||||
);
|
||||
|
||||
SendLater.previousLoop = new Date();
|
||||
SendLater.loopTimeout = setDeferred("mainLoop", 60000, mainLoop);
|
||||
|
||||
@@ -64,7 +64,10 @@ var quitter = class extends ExtensionCommon.ExtensionAPI {
|
||||
QuitObservers.requested,
|
||||
"quit-application-requested",
|
||||
);
|
||||
Services.obs.addObserver(QuitObservers.granted, "quit-application-granted");
|
||||
Services.obs.addObserver(
|
||||
QuitObservers.granted,
|
||||
"quit-application-granted",
|
||||
);
|
||||
|
||||
return {
|
||||
quitter: {
|
||||
|
||||
@@ -317,7 +317,9 @@ const SendLaterFunctions = {
|
||||
SendLaterVars.sendingUnsentMessages = false;
|
||||
if (SendLaterVars.needToSendUnsentMessages) {
|
||||
if (Utils.isOffline) {
|
||||
SendLaterFunctions.warn("Deferring sendUnsentMessages while offline");
|
||||
SendLaterFunctions.warn(
|
||||
"Deferring sendUnsentMessages while offline",
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
const msgSendLater = Components.classes[
|
||||
|
||||
@@ -490,11 +490,11 @@ exports.init = function () {
|
||||
return result === expected || `Expected "${expected}", got "${result}"`;
|
||||
}
|
||||
|
||||
SLTests.AddTest("Test relativeDateFormat '1 hour ago'", compareRelativeTime, [
|
||||
new Date(Date.now() - 3600 * 1000),
|
||||
null,
|
||||
"1 hour ago",
|
||||
]);
|
||||
SLTests.AddTest(
|
||||
"Test relativeDateFormat '1 hour ago'",
|
||||
compareRelativeTime,
|
||||
[new Date(Date.now() - 3600 * 1000), null, "1 hour ago"],
|
||||
);
|
||||
|
||||
SLTests.AddTest(
|
||||
"Test relativeDateFormat '1 hour from now'",
|
||||
|
||||
@@ -130,9 +130,12 @@ exports.init = function () {
|
||||
SLTests.AddTest(
|
||||
"MimeTests 05-HTML+embedded-image.eml",
|
||||
(hdrstring, newvalue) => {
|
||||
const original = fs.readFileSync("test/data/05-HTML+embedded-image.eml", {
|
||||
encoding: "utf-8",
|
||||
});
|
||||
const original = fs.readFileSync(
|
||||
"test/data/05-HTML+embedded-image.eml",
|
||||
{
|
||||
encoding: "utf-8",
|
||||
},
|
||||
);
|
||||
const expected = fs.readFileSync(
|
||||
"test/data/05-HTML+embedded-image.eml.out",
|
||||
{ encoding: "utf-8" },
|
||||
|
||||
@@ -25,7 +25,8 @@ if (typeof browser === "undefined" || typeof browserMocking === "boolean") {
|
||||
// asynchronously load translations.
|
||||
function waitAndTranslate() {
|
||||
if (
|
||||
browser.i18n.getMessage("advancedOptionsTitle") === "advancedOptionsTitle"
|
||||
browser.i18n.getMessage("advancedOptionsTitle") ===
|
||||
"advancedOptionsTitle"
|
||||
) {
|
||||
setTimeout(waitAndTranslate, 10);
|
||||
} else {
|
||||
|
||||
@@ -140,7 +140,10 @@ const SLOptions = {
|
||||
) {
|
||||
gracePeriodUnits.value = "gracePeriodDays";
|
||||
gracePeriodTime.value = gracePeriodTimeValue / (60 * 24);
|
||||
} else if (gracePeriodTimeValue > 60 && gracePeriodTimeValue % 60 === 0) {
|
||||
} else if (
|
||||
gracePeriodTimeValue > 60 &&
|
||||
gracePeriodTimeValue % 60 === 0
|
||||
) {
|
||||
gracePeriodUnits.value = "gracePeriodHours";
|
||||
gracePeriodTime.value = gracePeriodTimeValue / 60;
|
||||
} else {
|
||||
@@ -522,24 +525,26 @@ const SLOptions = {
|
||||
.getElementById("funcEditReset")
|
||||
.addEventListener("click", resetFunctionInput);
|
||||
|
||||
document.getElementById("funcEditSave").addEventListener("click", (evt) => {
|
||||
const funcName = document.getElementById("functionName").value;
|
||||
const funcContent = document.getElementById(
|
||||
"functionEditorContent",
|
||||
).value;
|
||||
const funcHelp = document.getElementById("functionHelpText").value;
|
||||
SLOptions.saveUserFunction(funcName, funcContent, funcHelp).then(
|
||||
(success) => {
|
||||
if (success) {
|
||||
SLOptions.addFuncOption(funcName, true);
|
||||
SLOptions.showCheckMark(evt.target, "green");
|
||||
} else {
|
||||
document.getElementById("functionName").select();
|
||||
SLOptions.showXMark(evt.target, "red");
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
document
|
||||
.getElementById("funcEditSave")
|
||||
.addEventListener("click", (evt) => {
|
||||
const funcName = document.getElementById("functionName").value;
|
||||
const funcContent = document.getElementById(
|
||||
"functionEditorContent",
|
||||
).value;
|
||||
const funcHelp = document.getElementById("functionHelpText").value;
|
||||
SLOptions.saveUserFunction(funcName, funcContent, funcHelp).then(
|
||||
(success) => {
|
||||
if (success) {
|
||||
SLOptions.addFuncOption(funcName, true);
|
||||
SLOptions.showCheckMark(evt.target, "green");
|
||||
} else {
|
||||
document.getElementById("functionName").select();
|
||||
SLOptions.showXMark(evt.target, "red");
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
const resetAdvConfigEditor = async () => {
|
||||
SLStatic.debug("Refreshing advanced config editor contents");
|
||||
@@ -639,7 +644,9 @@ const SLOptions = {
|
||||
document.getElementById(`ufunc-accel-ctrl-${funcName}`).remove();
|
||||
document.getElementById(`ufunc-accel-shift-${funcName}`).remove();
|
||||
for (let i = 1; i < 4; i++)
|
||||
document.getElementById(`ufunc-shortcut-${i}-${funcName}`).remove();
|
||||
document
|
||||
.getElementById(`ufunc-shortcut-${i}-${funcName}`)
|
||||
.remove();
|
||||
} catch (ex) {
|
||||
SLStatic.error("Unable to remove function selector element", ex);
|
||||
}
|
||||
@@ -658,7 +665,9 @@ const SLOptions = {
|
||||
.addEventListener("click", (evt) => {
|
||||
const funcNameSelect = document.getElementById("functionNames");
|
||||
const funcName = funcNameSelect.value;
|
||||
if ([...SLOptions.builtinFuncs, "newFunctionName"].includes(funcName)) {
|
||||
if (
|
||||
[...SLOptions.builtinFuncs, "newFunctionName"].includes(funcName)
|
||||
) {
|
||||
SLStatic.error("Trying to delete builtin user func.");
|
||||
return;
|
||||
} else {
|
||||
@@ -714,7 +723,9 @@ const SLOptions = {
|
||||
outputCell.appendChild(mkSpan(error));
|
||||
} else {
|
||||
const nextStr = SLStatic.parseableDateTimeFormat(sendAt);
|
||||
outputCell.appendChild(mkBlock(mkSpan("next:", true), mkSpan(nextStr)));
|
||||
outputCell.appendChild(
|
||||
mkBlock(mkSpan("next:", true), mkSpan(nextStr)),
|
||||
);
|
||||
outputCell.appendChild(
|
||||
mkBlock(mkSpan("nextspec:", true), mkSpan(nextspec || "none")),
|
||||
);
|
||||
|
||||
28
ui/popup.js
28
ui/popup.js
@@ -15,7 +15,9 @@ const SLPopup = {
|
||||
} else {
|
||||
let cancelOnReply = schedule.recur.cancelOnReply ? "yes" : "no";
|
||||
return [
|
||||
`x-send-later-at: ${SLStatic.parseableDateTimeFormat(schedule.sendAt)}`,
|
||||
`x-send-later-at: ${SLStatic.parseableDateTimeFormat(
|
||||
schedule.sendAt,
|
||||
)}`,
|
||||
`x-send-later-recur: ${SLStatic.unparseRecurSpec(schedule.recur)}`,
|
||||
`x-send-later-args: ${schedule.recur.args}`,
|
||||
`x-send-later-cancel-on-reply: ${cancelOnReply}`,
|
||||
@@ -88,10 +90,9 @@ const SLPopup = {
|
||||
inputs.groups = {};
|
||||
domArray.forEach((el) => {
|
||||
if (el.type === "radio" && el.name && !inputs.radio[el.name]) {
|
||||
inputs.radio[el.name] = [...document.getElementsByName(el.name)].reduce(
|
||||
(def, elem) => (elem.checked ? elem.value : def),
|
||||
undefined,
|
||||
);
|
||||
inputs.radio[el.name] = [
|
||||
...document.getElementsByName(el.name),
|
||||
].reduce((def, elem) => (elem.checked ? elem.value : def), undefined);
|
||||
}
|
||||
if (el.type === "checkbox" && el.name && !inputs.groups[el.name]) {
|
||||
inputs.groups[el.name] = [
|
||||
@@ -166,7 +167,10 @@ const SLPopup = {
|
||||
const sendAtTime = inputs["send-time"];
|
||||
let sendAt, schedule;
|
||||
|
||||
if (/\d\d\d\d.\d\d.\d\d/.test(sendAtDate) && /\d\d.\d\d/.test(sendAtTime)) {
|
||||
if (
|
||||
/\d\d\d\d.\d\d.\d\d/.test(sendAtDate) &&
|
||||
/\d\d.\d\d/.test(sendAtTime)
|
||||
) {
|
||||
sendAt = SLStatic.parseDateTime(sendAtDate, sendAtTime);
|
||||
}
|
||||
|
||||
@@ -232,7 +236,9 @@ const SLPopup = {
|
||||
case "function":
|
||||
break;
|
||||
default:
|
||||
SLStatic.error(`unrecognized recurrence type <${schedule.recur.type}>`);
|
||||
SLStatic.error(
|
||||
`unrecognized recurrence type <${schedule.recur.type}>`,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -446,7 +452,9 @@ const SLPopup = {
|
||||
const funcHelpDiv = document.getElementById("funcHelpDiv");
|
||||
funcHelpDiv.textContent = helpTxt;
|
||||
} else {
|
||||
SLStatic.warn(`Cannot set help text. Unrecognized function: ${funcName}`);
|
||||
SLStatic.warn(
|
||||
`Cannot set help text. Unrecognized function: ${funcName}`,
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -833,7 +841,9 @@ const SLPopup = {
|
||||
}
|
||||
})();
|
||||
(() => {
|
||||
const label = browser.i18n.getMessage("sendlater.prompt.sendlater.label");
|
||||
const label = browser.i18n.getMessage(
|
||||
"sendlater.prompt.sendlater.label",
|
||||
);
|
||||
const accessKey = browser.i18n.getMessage(
|
||||
"sendlater.prompt.sendlater.accesskey",
|
||||
);
|
||||
|
||||
@@ -859,7 +859,9 @@ var SLStatic = {
|
||||
|
||||
let scheduleText;
|
||||
if (recur !== undefined && !sendAt && recur.type === "function") {
|
||||
scheduleText = this.i18n.getMessage("sendwithfunction", [recur.function]);
|
||||
scheduleText = this.i18n.getMessage("sendwithfunction", [
|
||||
recur.function,
|
||||
]);
|
||||
} else {
|
||||
scheduleText = SLStatic.shortHumanDateTimeFormat(sendAt);
|
||||
}
|
||||
@@ -1467,7 +1469,13 @@ var SLStatic = {
|
||||
// 4) If this is a one-off schedule and the assigned day is not valid, then we
|
||||
// want to go to the beginning of the allowed time range on the next valid
|
||||
// day.
|
||||
adjustDateForRestrictions(sendAt, start_time, end_time, days, soonest_valid) {
|
||||
adjustDateForRestrictions(
|
||||
sendAt,
|
||||
start_time,
|
||||
end_time,
|
||||
days,
|
||||
soonest_valid,
|
||||
) {
|
||||
// Copy argument variable to avoid modifying the original
|
||||
// (Is this really necessary?)
|
||||
sendAt = new Date(sendAt.getTime());
|
||||
|
||||
@@ -190,7 +190,9 @@ var SLTools = {
|
||||
})
|
||||
.then((allWindows) => {
|
||||
// Current compose windows
|
||||
const ccWins = allWindows.filter((cWindow) => cWindow.focused === true);
|
||||
const ccWins = allWindows.filter(
|
||||
(cWindow) => cWindow.focused === true,
|
||||
);
|
||||
if (ccWins.length === 1) {
|
||||
const ccTabs = ccWins[0].tabs.filter((tab) => tab.active === true);
|
||||
if (ccTabs.length !== 1) {
|
||||
|
||||
Reference in New Issue
Block a user