I’ve found a better dependency management strategy, inspired by GRDB’s EnvironmentStateObject [github.com] but using Observation (aka iOS 17) in place of Combine. Now I can manage dependencies using ViewModifiers #prosedev
I’ve also rewritten drafts and accounts as Observable objects with dependencies instead of just plain value types. This means each draft can load from disk and manage its own mutable editing state and queue, saving to disk when appropriate.
Debouncing is very tricky with mutable state, even more complicated when using value types. In hindsight, that type of code was misplaced in View logic. Now it’s all hidden and automatic.
Oh, drafts sorting is back and simpler. Works similar to how Files.app does sorting, a selection of values (with an up/down arrow next to the current selection). Re-selecting a value flips the order.