@bobfrankston/rmfmail 1.2.10 → 1.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/app.js CHANGED
@@ -3088,15 +3088,29 @@ onWsEvent((event) => {
3088
3088
  banner.style.background = "oklch(0.52 0.14 150)";
3089
3089
  // Stash the update banner contents so updateFailed can restore
3090
3090
  // it (offering a retry) instead of leaving "Updating..." pinned.
3091
- const restoreHtml = `${APP_NAME} ${event.latest} available (you have ${event.current}) <button id="btn-do-update" style="background:none;border:1px solid #fff;color:#fff;padding:0.15em 0.5em;border-radius:3px;cursor:pointer;margin-left:0.5em">Update now</button>`;
3091
+ // `local:true` means a newer build is ALREADY installed on disk
3092
+ // (npmglobalize finished) — we just need to restart onto it, no
3093
+ // npm install. That path is network-free and does a clean
3094
+ // daemon handoff (the fresh daemon kills this one). The remote
3095
+ // path (a published version not yet installed) still runs
3096
+ // performUpdate (npm install + restart).
3097
+ const isLocal = !!event.local;
3098
+ const verb = isLocal ? "installed" : "available";
3099
+ const label = isLocal ? "Restart to apply" : "Update now";
3100
+ const restoreHtml = `${APP_NAME} ${event.latest} ${verb} (you have ${event.current}) — <button id="btn-do-update" style="background:none;border:1px solid #fff;color:#fff;padding:0.15em 0.5em;border-radius:3px;cursor:pointer;margin-left:0.5em">${label}</button>`;
3092
3101
  window.__mailxUpdateBannerHtml = restoreHtml;
3093
3102
  text.innerHTML = restoreHtml;
3094
3103
  document.getElementById("btn-do-update")?.addEventListener("click", () => {
3095
- text.textContent = "Updating... mailx will restart when done";
3096
- // performUpdate runs npm install then restarts the service
3097
3104
  const ipc = window.mailxapi || window.opener?.mailxapi;
3098
- if (ipc?.performUpdate)
3099
- ipc.performUpdate();
3105
+ if (isLocal && ipc?.restartDaemon) {
3106
+ text.textContent = "Restarting onto the new version...";
3107
+ ipc.restartDaemon();
3108
+ }
3109
+ else {
3110
+ text.textContent = "Updating... mailx will restart when done";
3111
+ if (ipc?.performUpdate)
3112
+ ipc.performUpdate();
3113
+ }
3100
3114
  });
3101
3115
  }
3102
3116
  break;