Fix 401 error when publishing a new weblog entry

The add entry button in the toolbar wasn’t passing the selected address
to the lower layers. As result, Triton was making a network request to
create a new post without the address. In such cases, the API returns an
error, 401.

This commit ensures the address is getting passed down to the lower
layers before making the network request.
This commit is contained in:
Otavio Cordeiro 2025-12-17 21:50:55 +01:00 committed by Otávio
parent 1791cab97f
commit 44f3cc6e64
2 changed files with 15 additions and 5 deletions

View file

@ -24,8 +24,8 @@ struct EditWeblogEntryScene: Scene {
for: EditWeblogEntry.self for: EditWeblogEntry.self
) { $entry in ) { $entry in
makeEditorView( makeEditorView(
body: entry?.body ?? "# Title of your post\n\nThis is the body of your post...", body: entry?.body ?? "",
date: entry?.date ?? Date(), date: entry?.date ?? .init(),
entryID: entry?.entryID, entryID: entry?.entryID,
address: entry?.address ?? "" address: entry?.address ?? ""
) )

View file

@ -78,9 +78,19 @@ struct WeblogApp: View {
} }
@ViewBuilder @ViewBuilder
private func makeAddEntryToolbarItem() -> some View { private func makeAddEntryToolbarItem(
address: SelectedAddress
) -> some View {
Button { Button {
openWindow(id: EditWeblogEntryWindow.id) openWindow(
id: EditWeblogEntryWindow.id,
value: EditWeblogEntry(
address: address,
body: "# Title of your post\n\nThis is the body of your post...",
date: .init(),
entryID: nil
)
)
} label: { } label: {
Image(systemName: "plus") Image(systemName: "plus")
} }
@ -108,7 +118,7 @@ struct WeblogApp: View {
helpText: "Refresh weblog entries", helpText: "Refresh weblog entries",
isDisabled: viewModel.isLoading isDisabled: viewModel.isLoading
) )
makeAddEntryToolbarItem() makeAddEntryToolbarItem(address: address)
} }
} }
} }