silverbulletmd / silverbullet

The hackable notebook
https://silverbullet.md
MIT License
2.04k stars 141 forks source link

Event `task:stateChange` isn't fired for "external" tasks #788

Open sirlancelot opened 4 months ago

sirlancelot commented 4 months ago

On a page make some tasks:

- [ ] task 1 #shopping
- [ ] task 2 #shopping
- [ ] task 3 #shopping

On a different page, fetch those tasks:

External tasks below:

`` `template
{{#each {task where tags = "shopping"}}}
- [{{state}}] [[{{ref}}]] {{name}}
{{/each}}
`` `

When completing the task on the different page, a related "task:stateChange" event is not fired.

zefhemel commented 4 months ago

But then even is triggered when you actually complete those tasks on that other page, right? What is your use case for having the event also be triggered on pages where these tasks are merely queried?

henrikx commented 4 months ago

But then even is triggered when you actually complete those tasks on that other page, right? What is your use case for having the event also be triggered on pages where these tasks are merely queried?

But they aren't merely queried. The tasks can be completed from within the query.

sirlancelot commented 3 months ago

The event doesn't seem to fire at all when checking off a task from within a query.

I realize it may be difficult to do what I want to do, but on my daily note page I have a query showing all tasks due that day, and I want to be able to mark it complete and have the event append ✅ {{today}} to the source task.

zefhemel commented 3 months ago

Ah, when you toggle the box in the query. Ok right. I think I can make that happen.

argus-core commented 3 months ago

Possibly unrelated, but the remote toggle example on https://silverbullet.md/Plugs/Tasks (under "Rendering") doesn't work for me either.

zefhemel commented 3 months ago

@argus-core right, yeah that's a bit misleading there. It doesn't work because silverbullet.md is running in read-only mode. I should remove that example probably.