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