Fix id of Items, saving
This commit is contained in:
@ -49,9 +49,9 @@ struct TextFileContentView: View {
|
||||
|
||||
private func reload() {
|
||||
fileContent = file.textContent()
|
||||
loadedFile = file.id
|
||||
loadedFile = file.identifier
|
||||
loadedFileDate = file.modifiedDate
|
||||
print("Loaded content of file \(file.id)")
|
||||
print("Loaded content of file \(file.identifier)")
|
||||
}
|
||||
|
||||
private func save() {
|
||||
@ -59,25 +59,25 @@ struct TextFileContentView: View {
|
||||
print("[ERROR] Text File View: No file loaded to save")
|
||||
return
|
||||
}
|
||||
guard loadedFile == file.id else {
|
||||
guard loadedFile == file.identifier else {
|
||||
print("[ERROR] Text File View: Not saving since file changed")
|
||||
reload()
|
||||
return
|
||||
}
|
||||
guard loadedFileDate == file.modifiedDate else {
|
||||
print("Text File View: Not saving changed file \(file.id)")
|
||||
print("Text File View: Not saving changed file \(file.identifier)")
|
||||
reload()
|
||||
return
|
||||
}
|
||||
guard fileContent != "" else {
|
||||
print("Text File View: Not saving empty file \(file.id)")
|
||||
print("Text File View: Not saving empty file \(file.identifier)")
|
||||
return
|
||||
}
|
||||
guard file.save(textContent: fileContent) else {
|
||||
print("[ERROR] Text File View: Failed to save file \(file.id)")
|
||||
print("[ERROR] Text File View: Failed to save file \(file.identifier)")
|
||||
return
|
||||
}
|
||||
loadedFileDate = file.modifiedDate
|
||||
print("Text File View: Saved file \(file.id)")
|
||||
print("Text File View: Saved file \(file.identifier)")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user