Skip to content

Commit

Permalink
4.10.1 emergency patch
Browse files Browse the repository at this point in the history
- added silent update feature
  • Loading branch information
RealRaven2000 committed Jan 27, 2025
1 parent 9ec59d5 commit 41527b9
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 31 deletions.
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ powershell -Command "(gc -en UTF8 manifest.json) -replace 'pre%oldRev%', 'pre%sm
echo %smartTemplateRev% > revision.txt
move smartTemplate-*.xpi "..\..\..\Test Versions\4.10\"
powershell -Command "Start-Sleep -m 270"
rename smartTemplateWeb.zip smartTemplate-fx-4.10pre%smartTemplateRev%.xpi
rename smartTemplateWeb.zip smartTemplate-fx-4.10.1pre%smartTemplateRev%.xpi
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"manifest_version": 2,
"name": "SmartTemplates",
"description": "__MSG_extensionDescription__",
"version": "4.10",
"version": "4.10.1",
"default_locale": "en",
"developer": {
"name": "Axel Grude (author)",
Expand Down
7 changes: 7 additions & 0 deletions release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

The full change log with screen shots <a href="https://smarttemplates.quickfolders.org/version.html#4.10">can be found here</a>

<b>Maintenance Version 4.10.1</b>
<ul>
<li> Fixed regression in 4.10: automatic forwarding with FiltaQuilla fails <a href="https://github.com/RealRaven2000/SmartTemplates/issues/354">[issue 354]</a></li>
</ul>

<b>Enhancements</b>
<ul>
<li> Added features to insert unquoted email and remove styles using `%quotePlaceHolder(nostyles)%` <a href="https://github.com/RealRaven2000/SmartTemplates/issues/331">[issue 331]</a></li>
Expand All @@ -22,10 +27,12 @@

For deeper programming using inline script, several major improvements were implemented. For information on how to enable scripting and use it please refer to <a href="https://smarttemplates.quickfolders.org/premium.html#javascript">this documentation section</a>.

<ul>
<li> Fixed problems with `messageRaw()` function in Sandboxed script <a href="https://github.com/RealRaven2000/SmartTemplates/issues/347">[issue 347]</a></li>
<li> Support "composite" ST variables in sandboxed script (e.g. `header.set`) via underscores (`header_set`) <a href="https://github.com/RealRaven2000/SmartTemplates/issues/349">[issue 349]</a></li>
<li> Support multiple parameters in sandboxed script (e.g. `%from(name,uppercase)%` ) <a href="https://github.com/RealRaven2000/SmartTemplates/issues/350">[issue 350]</a></li>
<li> Simplified using reserved parameter such as `firstname`, `lastname` etc. these can be used directly as parameter by prefixing with a "$" character. Previously these had to be wrapped in double quotes. </li>
</ul>

For example:

Expand Down
11 changes: 8 additions & 3 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
The full change log with screen shots [can be found here](https://smarttemplates.quickfolders.org/version.html#4.10)

**Enhancements**
**Maintenance verfsion 4.10.1**
<ul>
<li> Fixed regression in 4.10: automatic forwarding with FiltaQuilla fails [issue #354]</li>
</ul>

**Enhancements - 4.10**

* Added features to insert unquoted email and remove styles using `%quotePlaceHolder(nostyles)%` [issue #331]
* Improved Capitalization for double-barrelled names (such as Tyler-Smith) [issue #343]
* `%header.set(from)%` triggers unnecessary warning. [issue #352]
* new `%dateformat.received()%` to retrieve date of original mail [issue #353]


**Bug Fixes**
**Bug Fixes - 4.10**

* Fixed: Common account settings for account were not stored [issue #340]
* Fixed problems with `messageRaw()` function in Sandboxed script [issue #347]
* Fixed: `%header.set(subject,clipboard)%` and `%matchTextFromBody(..,toclipboard)%` fail at commas [issue #344]
* Fixed: `*selection*` truncates content in text nodes [issue #351]


**Sandboxed Script**
**Sandboxed Script - 4.10**

For deeper programming using inline script, several major improvements were implemented. For information on how to enable scripting and use it please refer to <a href="https://smarttemplates.quickfolders.org/premium.html#javascript">this documentation section</a>.

Expand Down
2 changes: 1 addition & 1 deletion revision.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
95
8
81 changes: 56 additions & 25 deletions st-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,16 @@ async function createHeaderMenu() {

}

// Helper function to check if a version matches a pattern
function versionMatches(version, pattern) {
const regex = new RegExp(`^${pattern.replace(/\*/g, "\\d+")}$`);
return regex.test(version);
}

function versionGreater(v1, v2) {
return compareVersions(v1, v2) > 0;
}

//
async function updateMruMenu(Context) {
// default is 10 but can be raised in Pro
Expand Down Expand Up @@ -969,31 +979,52 @@ async function updateSubMenus(messages, tab) {
// see below
case "update":
{
setTimeout(
async function() {
let ver = await messenger.LegacyPrefs.getPref("extensions.smartTemplate4.version","0");
const manifest = await messenger.runtime.getManifest();
// get pure version number / remove pre123 indicator
let installedVersion = manifest.version.replace(/pre.*/,"");
if (isDebug) console.log(`SmartTemplates Update: old=${ver} new=${installedVersion}`);
// compare versions to support beta builds
// we probably need to manage prerelease installs with a separate flag!
if (compareVersions(installedVersion,ver)>0) {
if (isDebug) console.log("Setting hasNews flag!");
messenger.LegacyPrefs.setPref("extensions.smartTemplate4.hasNews", true);
}
if (ver != installedVersion ) {
if (isDebug) console.log("Storing new version number " + manifest.version);
// STORE VERSION CODE!
// prefs.setMyStringPref("version", pureVersion); // store sanitized version! (no more alert on pre-Releases + betas!)
messenger.LegacyPrefs.setPref("extensions.smartTemplate4.version", installedVersion);
}

messenger.NotifyTools.notifyExperiment({event: "updateNewsLabels"});
messenger.NotifyTools.notifyExperiment({event: "firstRun"});
},
200
);

(async () => {
// compare versions to support beta builds
// we probably need to manage prerelease installs with a separate flag!
// Define a Map of silent update rules with wildcards
const silentUpdateMap = new Map([
["4.10", ["4.10.1"]], // Silent updates for [issue 354]
]);

// Function to check if an update is silent
function isSilentUpdate(fromVersion, toVersion) {
const patterns = silentUpdateMap.get(fromVersion);
if (!patterns) return false; // No silent updates defined for this `fromVersion`

// Check if `toVersion` matches any pattern in the list
return patterns.some((pattern) => versionMatches(toVersion, pattern));
}

const origVer = await messenger.LegacyPrefs.getPref(
"extensions.smartTemplate4.version",
"0"
);
const manifest = await messenger.runtime.getManifest();
// get pure version number / remove pre123 indicator
let installedVersion = manifest.version.replace(/pre.*/, "").replace(/\.$/, "");
if (isDebug) {
console.log(`SmartTemplates Update: old=${origVer} new=${installedVersion}`);
}

const isUpgrade = versionGreater(installedVersion, origVer),
isSilent = isSilentUpdate(origVer, installedVersion);

if (isUpgrade && !isSilent) {
if (isDebug) console.log("Setting hasNews flag!");
messenger.LegacyPrefs.setPref("extensions.smartTemplate4.hasNews", true);
}
if (origVer != installedVersion) {
if (isDebug) console.log("Storing new version number " + manifest.version);
// STORE VERSION CODE!
// prefs.setMyStringPref("version", pureVersion); // store sanitized version! (no more alert on pre-Releases + betas!)
messenger.LegacyPrefs.setPref("extensions.smartTemplate4.version", installedVersion);
}

messenger.NotifyTools.notifyExperiment({ event: "updateNewsLabels" });
messenger.NotifyTools.notifyExperiment({ event: "firstRun" });
})();

// TypeError: currentLicense is undefined
if (isDebug) console.log("2. update() case");
Expand Down

0 comments on commit 41527b9

Please sign in to comment.