Refactor how drafts are handled on a coordinator level and add support for them on thread timelines.

This commit is contained in:
Stefan Ceriu
2025-06-13 15:11:20 +03:00
committed by Stefan Ceriu
parent eaf14eaaac
commit 6fc6df9375
6 changed files with 33 additions and 16 deletions
@@ -161,9 +161,22 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
}
}
.store(in: &cancellables)
NotificationCenter.default.publisher(for: UIApplication.willResignActiveNotification).sink { [weak self] _ in
self?.saveDraft()
}
.store(in: &cancellables)
}
// MARK: - Public
func start() {
Task { await loadDraft() }
}
func stop() {
saveDraft()
}
override func process(viewAction: ComposerToolbarViewAction) {
switch viewAction {
@@ -172,6 +185,8 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
hasAppeard = true
wysiwygViewModel.setup()
}
case .composerDisappeared:
saveDraft()
case .sendMessage:
guard !state.sendButtonDisabled else { return }