Skip to content

Commit 5a4a1f2

Browse files
committed
fix(tasks): 任务写回补发 notes 域变更事件
1 parent 8fe28d3 commit 5a4a1f2

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎app/src-tauri/src/commands_tasks.rs‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,33 @@ pub fn refine_unrefined_core(db: &Db, row_id: i64) -> Result<String, String> {
168168
Ok(format!("已提炼为任务行:{}", payload))
169169
}
170170

171+
/// 写正文成功后的 notes 域广播(v0.20.5:行动裁决=笔记正文行状态变更,
172+
/// 笔记页列表/右栏需被动刷新——任务命令此前零广播,前端靠 Overlay
173+
/// onChanged 回调;行动中心独立成页后该通道删除,补发为唯一被动刷新源)。
174+
/// 广播收敛于 IPC 包装层(core 层无 AppHandle;先例同 batch_weekly_resolve)。
175+
fn emit_notes_changed_on_ok(app: &tauri::AppHandle, r: Result<String, String>) -> Result<String, String> {
176+
if r.is_ok() {
177+
crate::notify::emit_changed(app, crate::notify::DataDomain::Notes);
178+
}
179+
r
180+
}
181+
171182
/// ✓ 完成(IPC)。
172183
#[tauri::command]
173184
pub fn task_complete(state: State<'_, AppState>, row_id: i64) -> Result<String, String> {
174-
complete_task_core(&state.db, row_id)
185+
emit_notes_changed_on_ok(&state.app, complete_task_core(&state.db, row_id))
175186
}
176187

177188
/// ✗ 放弃(IPC;reason 可空)。
178189
#[tauri::command]
179190
pub fn task_abandon(state: State<'_, AppState>, row_id: i64, reason: Option<String>) -> Result<String, String> {
180-
abandon_task_core(&state.db, row_id, reason.as_deref().unwrap_or(""))
191+
emit_notes_changed_on_ok(&state.app, abandon_task_core(&state.db, row_id, reason.as_deref().unwrap_or("")))
181192
}
182193

183194
/// 提炼(IPC)。
184195
#[tauri::command]
185196
pub fn task_refine_unrefined(state: State<'_, AppState>, row_id: i64) -> Result<String, String> {
186-
refine_unrefined_core(&state.db, row_id)
197+
emit_notes_changed_on_ok(&state.app, refine_unrefined_core(&state.db, row_id))
187198
}
188199

189200
/// 📅 改期(只落索引列;date=None 清除=归入「搁置」)。

0 commit comments

Comments
 (0)