Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Fix loading state for block editor (#1046)
Browse files Browse the repository at this point in the history
Minor cleanup following #1043

- Remove loading state from related. We don't need it.
- Mark loading state `notFound` if editor fails to load
- Mark loading state in succeedLoadEditor, not in setEditor

Part of #214
  • Loading branch information
gordonbrander authored Dec 22, 2023
1 parent 43d24db commit 68ba8d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import Foundation
extension BlockEditor {
/// A collection of related notes
struct RelatedModel: Hashable {
/// Is related loading?
var loadingState = LoadingState.loading
var related: [EntryStub] = []
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,9 @@ extension BlockEditor.Model: ModelProtocol {
) -> Update {
let address = state.address?.description ?? "nil"
logger.warning("Failed to load detail for \(address). Error: \(error)")
return Update(state: state)
var model = state
model.loadingState = .notFound
return Update(state: model)
}

/// Set editor state, replacing whatever was previously there.
Expand All @@ -759,8 +761,6 @@ extension BlockEditor.Model: ModelProtocol {
environment: Environment
) -> Update {
var model = state
// Finished loading. We have the data.
model.loadingState = .loaded
model.setSaveState(detail.saveState)
model.address = detail.entry.address
model.created = detail.entry.contents.created
Expand Down

0 comments on commit 68ba8d4

Please sign in to comment.