@ottttto/dsh-scheduled-send 0.3.7 → 0.3.9
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/dsh.plugin.json +1 -1
- package/lib/client.js +8 -2
- package/package.json +1 -1
- package/src/client-core.js +7 -1
- package/src/client-view.js +1 -1
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "@ottttto/dsh-scheduled-send",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"description": "定时发送:到点以你的身份把消息作为正常用户气泡发进当前会话,无人值守、会话隔离、断电补发。Scheduled send for DSH — fires as a normal user bubble into the bound conversation, unattended, per-session isolated, restart-safe.",
|
|
6
6
|
"engines": {
|
package/lib/client.js
CHANGED
|
@@ -239,13 +239,19 @@ function createScheduledClientState({ fetchState, postSchedule, cancelSchedule,
|
|
|
239
239
|
},
|
|
240
240
|
|
|
241
241
|
/** Cancel a pending task: DELETE on the host + drop locally. */
|
|
242
|
+
/** Cross-instance optimistic removal by id (no fetch). */
|
|
243
|
+
removeTask(id) {
|
|
244
|
+
tasks = tasks.filter((t) => t.id !== id);
|
|
245
|
+
recentAdds.delete(id);
|
|
246
|
+
},
|
|
247
|
+
|
|
242
248
|
async cancelTask(id) {
|
|
243
249
|
// optimistic: drop locally FIRST so the row disappears instantly; the
|
|
244
250
|
// DELETE then persists it. onChanged lets the sibling instance (dock ↔
|
|
245
251
|
// sidebar panel) refresh immediately instead of waiting for its poll.
|
|
246
252
|
tasks = tasks.filter((t) => t.id !== id);
|
|
247
253
|
recentAdds.delete(id);
|
|
248
|
-
if (typeof this.onChanged === 'function') this.onChanged();
|
|
254
|
+
if (typeof this.onChanged === 'function') this.onChanged(id);
|
|
249
255
|
if (cancelSchedule) await cancelSchedule(id);
|
|
250
256
|
},
|
|
251
257
|
|
|
@@ -687,7 +693,7 @@ function createClientPluginBody(React) {
|
|
|
687
693
|
const res = await doFetch(stateRoutePath, { headers: { accept: "application/json" } });
|
|
688
694
|
// cross-instance sync: a cancel/create in either surface refreshes the
|
|
689
695
|
// other immediately (no 4s poll lag)
|
|
690
|
-
core.onChanged = () => { void panelCore.refresh(); };
|
|
696
|
+
core.onChanged = (id) => { if (id) panelCore.removeTask(id); void panelCore.refresh(); };
|
|
691
697
|
panelCore.onChanged = () => { void core.refresh(); };
|
|
692
698
|
if (!res.ok) throw new Error("state HTTP " + res.status);
|
|
693
699
|
return res.json();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ottttto/dsh-scheduled-send",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "DSH plugin: scheduled sending (⏰ composer button, dock list of pending tasks, sidebar 定时任务 panel with cross-session cancel, due-time delivery as a normal user bubble)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/client-core.js
CHANGED
|
@@ -230,13 +230,19 @@ export function createScheduledClientState({ fetchState, postSchedule, cancelSch
|
|
|
230
230
|
},
|
|
231
231
|
|
|
232
232
|
/** Cancel a pending task: DELETE on the host + drop locally. */
|
|
233
|
+
/** Cross-instance optimistic removal by id (no fetch). */
|
|
234
|
+
removeTask(id) {
|
|
235
|
+
tasks = tasks.filter((t) => t.id !== id);
|
|
236
|
+
recentAdds.delete(id);
|
|
237
|
+
},
|
|
238
|
+
|
|
233
239
|
async cancelTask(id) {
|
|
234
240
|
// optimistic: drop locally FIRST so the row disappears instantly; the
|
|
235
241
|
// DELETE then persists it. onChanged lets the sibling instance (dock ↔
|
|
236
242
|
// sidebar panel) refresh immediately instead of waiting for its poll.
|
|
237
243
|
tasks = tasks.filter((t) => t.id !== id);
|
|
238
244
|
recentAdds.delete(id);
|
|
239
|
-
if (typeof this.onChanged === 'function') this.onChanged();
|
|
245
|
+
if (typeof this.onChanged === 'function') this.onChanged(id);
|
|
240
246
|
if (cancelSchedule) await cancelSchedule(id);
|
|
241
247
|
},
|
|
242
248
|
|
package/src/client-view.js
CHANGED
|
@@ -416,7 +416,7 @@ function createClientPluginBody(React) {
|
|
|
416
416
|
const res = await doFetch(stateRoutePath, { headers: { accept: "application/json" } });
|
|
417
417
|
// cross-instance sync: a cancel/create in either surface refreshes the
|
|
418
418
|
// other immediately (no 4s poll lag)
|
|
419
|
-
core.onChanged = () => { void panelCore.refresh(); };
|
|
419
|
+
core.onChanged = (id) => { if (id) panelCore.removeTask(id); void panelCore.refresh(); };
|
|
420
420
|
panelCore.onChanged = () => { void core.refresh(); };
|
|
421
421
|
if (!res.ok) throw new Error("state HTTP " + res.status);
|
|
422
422
|
return res.json();
|