(again)
Can't see a way to make this work. Perhaps changing the message to _No tasks yet_ or _No tasks right now_ would be suitable? @SCdF @garethbowen any thoughts on the message, or on making this actually work?
It's difficult. Dave thought nools might fire an event once the facts had stabalised but I can't find any documentation for this.
We could fudge it with timeouts - eg: wait for replication to finish, wait for nools init to finish, wait another 1 second before showing the none found message. IIRC it doesn't take very long for the first task to be emitted...
I think I was originally looking at the session object: https://github.com/C2FO/nools#firing-the-rules, which says "The match method also returns a promise that is resolved once there are no more rules to activate". However, I'm guessing the promise resolves immediately if there's nothing to do, and the approach would require that we switch from reactive mode to immediate mode (read: use match instead of matchUntilHalt).
splash screen will make this not needed!
This isn't just a first run issue so a splash screen will help but we will still show "no tasks found" even when replication is up to date.
In develop I cannot reproduce this.
When you first boot this is hidden behind a splash screen / loading indicator. When you switch to the tab once everything is loaded it doesn't show up either, it just shows the tasks straight away (relative version of "straight away", obv.)
I _can_ recreate this on current alpha.dev. It doesn't happen every time, as sometimes the first task has already appeared by the time the loader is removed.
@garethbowen please close or schedule before the end of this sprint. See triaging old issues.
As far as we can tell there's no way to know when task processing is complete (async ftl). Given this, I propose we just remove the "no tasks found" message altogether as it's potentially misleading and not really necessary. We can put it back if we work out how to do this properly later.
@sglangevin Are you ok with this workaround?
@garethbowen I think we need _something_ there in place of _No tasks found_, as an empty space will look a bit weird.
@alxndrsn "tasks go here"?
I wonder... if the bottom of the task config emitted a special event called "first-run-complete" would it deterministically be emitted after everything else... I'll have a play.
Ok, it looks like this approach will work - I've got some a proof-of-concept.
@sglangevin Are you ok with all task configurations having this line at the bottom of the GenerateEvents rule?
emit('_complete', { _id: true });
If a configuration is missing that then when there are no tasks it will show a spinner instead of the message. I'm considering writing a migration so existing configs will continue to work.
If it's easier we could make that Utils.complete() so it's harder to stuff up the syntax.
Very nice! One to keep an eye on in future when me upgrade nools.
@garethbowen apologies for the late response here. I would prefer a migration, if that is possible, and the simpler syntax is also preferable. Where did you end up?
The simpler syntax didn't work out but I think I can write a migration.
Ok, that's not a big deal as most task rules are adapted from other task rules as opposed to being written from scratch. A migration would be nice, but if we can't get to it, we can just have tech leads add that line to their task rules, as long as they know exactly where it goes. Since we only have 4 live projects that use task rules it's not a huge amount of work for tech leads.
Code review please @SCdF : https://github.com/medic/medic-webapp/pull/3162 and https://github.com/medic/medic-api/pull/124
This is not required for 2.10.
Acceptance testing:
The migration should update the configuration to have emit('_complete', { _id: true }); near the end of the "app_settings.tasks.rules" configuration. Check that this is the case. Ensure that the tasks list UI loads and the spinner goes away. If your tasks config is fast you may no see the spinner at all, so try a complicated config (like the standard app) or a slow device (like a tecno).
LGTM, one comment about adding a comment to explain a regex, merged.
Is this related to the fix? We used to have some message here.

Yes definitely a regression. Reopening.
Good catch. Fixed in 2.10.0-beta.6