This commit fixes an issue where the post view would scroll to the text cursor at seemingly random times. This was done by detaching the save view and its logic, so that we have 3 components: 1. The `PostView` 2. An auto-save view model (which is an Observable object) 3. A separate SwiftUI view for the auto-save indicator The auto-save view model is shared between the `PostView` and the new indicator view to ensure proper signaling and communication across views. However, this view model is only observed by the indicator view, ensuring it updates its own view, while not causing any re-renders on the rest of the `PostView`. This refactor had the side-effect of making the auto-save logic and view more reusable. It is now a separate collection of elements that can be used anywhere else. Beyond the scroll issue, this commit also prevents empty drafts from being saved, by introducing the new save state called `.nothingToSave` Note: No changelog item is needed because the new drafts feature was never publicly released. Changelog-None Closes: https://github.com/damus-io/damus/issues/2826 Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
597 KiB
597 KiB