v1.0.39: fix button flash by making setRunningEntry synchronous
Remove await from running-state updates so onWillAppear cannot fire between the optimistic setState(1) and the API call completing, eliminating the green→blue→green flash on button press.
This commit is contained in:
@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
|
||||
}
|
||||
|
||||
// src/plugin.ts
|
||||
var CURRENT_VERSION = "1.0.38";
|
||||
var CURRENT_VERSION = "1.0.39";
|
||||
var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild";
|
||||
var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
||||
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
|
||||
@@ -6535,11 +6535,10 @@ async function loadRunningState() {
|
||||
memRunningEntryId = stored.runningEntryId ?? null;
|
||||
memRunningActionId = stored.runningActionId ?? null;
|
||||
}
|
||||
async function setRunningEntry(entryId, actionId) {
|
||||
function setRunningEntry(entryId, actionId) {
|
||||
memRunningEntryId = entryId;
|
||||
memRunningActionId = actionId;
|
||||
const stored = await plugin_default.settings.getGlobalSettings();
|
||||
await plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId });
|
||||
plugin_default.settings.getGlobalSettings().then((stored) => plugin_default.settings.setGlobalSettings({ ...stored, runningEntryId: entryId, runningActionId: actionId })).catch((err) => plugin_default.logger.error("Failed to persist running state:", err));
|
||||
}
|
||||
async function sendProjectsToPI(tokenOverride) {
|
||||
try {
|
||||
@@ -6614,13 +6613,15 @@ var TimerToggle = class extends SingletonAction {
|
||||
try {
|
||||
if (isRunning) {
|
||||
await stopTimer(global.notionToken, memRunningEntryId);
|
||||
await setRunningEntry(null, null);
|
||||
setRunningEntry(null, null);
|
||||
await Promise.all([ev.action.setState(0), ev.action.setTitle(title)]);
|
||||
} else {
|
||||
if (memRunningEntryId) {
|
||||
await stopTimer(global.notionToken, memRunningEntryId);
|
||||
}
|
||||
const entryId = await startTimer(global.notionToken, global.timingDbId, projectId, projectName, global.userId);
|
||||
await setRunningEntry(entryId, ev.action.id);
|
||||
setRunningEntry(entryId, ev.action.id);
|
||||
await Promise.all([ev.action.setState(1), ev.action.setTitle(`\u23F1 ${title}`)]);
|
||||
}
|
||||
} catch (err) {
|
||||
await Promise.all([
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
Κ¤<06>C¤•Sί¤
|
||||
Φ®Έ}•~P}ηΜ<>Z;·ΆxΤη{,¦NYPπu4#ΑΚ„jα§ΎWCκΈ©σΔ«Έ<0E>d
|
||||
в<╥!Ъ░xR√з└СRё;=▀LI"я╓╢HuэF├ы▐Ос─╒┘ sb▌Y╛{йH│╤Н.JщNЦь1╔l
|
||||
@@ -2,7 +2,7 @@
|
||||
"Author": "Pete Marfleet",
|
||||
"Description": "Toggle Notion time tracking for a project with a single button press.",
|
||||
"Name": "Notion Timer",
|
||||
"Version": "1.0.38",
|
||||
"Version": "1.0.39",
|
||||
"SDKVersion": 2,
|
||||
"Software": { "MinimumVersion": "5.0" },
|
||||
"OS": [{ "Platform": "mac", "MinimumVersion": "10.11" }],
|
||||
|
||||
Reference in New Issue
Block a user