Improve page content saving
This commit is contained in:
parent
b6d2dd936b
commit
3df6717734
@ -7,6 +7,7 @@ enum PageContentSaveStatus {
|
||||
case failedToSave
|
||||
case needsSave
|
||||
case notLoaded
|
||||
case isSaving
|
||||
|
||||
var symbol: SFSymbol {
|
||||
switch self {
|
||||
@ -14,7 +15,7 @@ enum PageContentSaveStatus {
|
||||
return .questionmarkSquareDashed
|
||||
case .isSaved:
|
||||
return .checkmarkCircleFill
|
||||
case .needsSave:
|
||||
case .needsSave, .isSaving:
|
||||
return .hourglassCircleFill
|
||||
case .failedToSave:
|
||||
return .exclamationmarkTriangleFill
|
||||
@ -25,7 +26,7 @@ enum PageContentSaveStatus {
|
||||
switch self {
|
||||
case .isSaved, .notLoaded:
|
||||
return .green
|
||||
case .needsSave:
|
||||
case .needsSave, .isSaving:
|
||||
return .yellow
|
||||
case .failedToSave:
|
||||
return .red
|
||||
@ -92,6 +93,7 @@ struct LocalizedPageContentView: View {
|
||||
return
|
||||
}
|
||||
saveState = .needsSave
|
||||
lastModification = .now
|
||||
|
||||
// Wait a few seconds for a save, to allow additional changes
|
||||
// Reduces the number of saves
|
||||
@ -121,7 +123,7 @@ struct LocalizedPageContentView: View {
|
||||
|
||||
private func saveContentIfNeeded(isFinalSave: Bool = false) {
|
||||
switch saveState {
|
||||
case .isSaved, .notLoaded:
|
||||
case .isSaved, .notLoaded, .isSaving:
|
||||
return
|
||||
default:
|
||||
break
|
||||
@ -137,6 +139,7 @@ struct LocalizedPageContentView: View {
|
||||
}
|
||||
print("Saving content after 30 seconds of modifications")
|
||||
}
|
||||
saveState = .isSaving
|
||||
saveUnconditionally()
|
||||
}
|
||||
|
||||
@ -157,7 +160,9 @@ struct LocalizedPageContentView: View {
|
||||
saveState = .failedToSave
|
||||
return
|
||||
}
|
||||
|
||||
saveState = .isSaved
|
||||
lastSave = .now
|
||||
checkContent()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user