Ver código fonte

Bugfix: post not refreshed when updated from server (#246)

pull/250/head
Angelo Stavrow 1 ano atrás
committed by GitHub
pai
commit
79b4301988
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados ID da chave GPG: 4AEE18F83AFDEB23
6 arquivos alterados com 20 adições e 2 exclusões
  1. +1
    -0
      CHANGELOG.md
  2. +2
    -0
      Shared/Extensions/WriteFreelyModel+API.swift
  3. +7
    -0
      Shared/Extensions/WriteFreelyModel+APIHandlers.swift
  4. +4
    -0
      Shared/PostEditor/PostEditorModel.swift
  5. +4
    -0
      Shared/PostEditor/PostEditorStatusToolbarView.swift
  6. +2
    -2
      WriteFreely-MultiPlatform.xcodeproj/project.pbxproj

+ 1
- 0
CHANGELOG.md Ver arquivo

@@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [Mac] Fixed a bug where alerts weren't presented for login errors.
- [Mac] Fixed some build warnings in the project.
- [Mac] Bumped WriteFreely package to v0.3.6 to handle decoding of fractional seconds in dates.
- [Mac] Fixed a bug that prevented a remotely-edited post from updating until you navigated away and back.

## [1.0.15-ios] - 2022-01-15



+ 2
- 0
Shared/Extensions/WriteFreelyModel+API.swift Ver arquivo

@@ -142,7 +142,9 @@ extension WriteFreelyModel {
}
// We're starting the network request.
DispatchQueue.main.async {
#if os(iOS)
self.selectedPost = post
#endif
self.isProcessingRequest = true
}
loggedInClient.getPost(byId: postId, completion: updateFromServerHandler)


+ 7
- 0
Shared/Extensions/WriteFreelyModel+APIHandlers.swift Ver arquivo

@@ -221,11 +221,18 @@ extension WriteFreelyModel {
// See: https://github.com/writeas/writefreely-swift/issues/20
do {
let fetchedPost = try result.get()
#if os(iOS)
guard let cachedPost = self.selectedPost else { return }
#else
guard let cachedPost = self.editor.postToUpdate else { return }
#endif
importData(from: fetchedPost, into: cachedPost)
cachedPost.hasNewerRemoteCopy = false
DispatchQueue.main.async {
LocalStorageManager.standard.saveContext()
#if os(macOS)
self.selectedPost = cachedPost
#endif
}
} catch {
self.currentError = AppError.genericError(error.localizedDescription)


+ 4
- 0
Shared/PostEditor/PostEditorModel.swift Ver arquivo

@@ -12,6 +12,10 @@ struct PostEditorModel {
@AppStorage(WFDefaults.selectedCollectionURL, store: UserDefaults.shared) var selectedCollectionURL: URL?
@AppStorage(WFDefaults.lastDraftURL, store: UserDefaults.shared) var lastDraftURL: URL?

#if os(macOS)
var postToUpdate: WFAPost?
#endif

func saveLastDraft(_ post: WFAPost) {
self.lastDraftURL = post.status != PostStatus.published.rawValue ? post.objectID.uriRepresentation() : nil
}


+ 4
- 0
Shared/PostEditor/PostEditorStatusToolbarView.swift Ver arquivo

@@ -16,7 +16,11 @@ struct PostEditorStatusToolbarView: View {
.font(.callout)
.foregroundColor(.secondary)
Button(action: {
model.editor.postToUpdate = post
model.updateFromServer(post: post)
DispatchQueue.main.async {
model.selectedPost = nil
}
}, label: {
Image(systemName: "square.and.arrow.down")
})


+ 2
- 2
WriteFreely-MultiPlatform.xcodeproj/project.pbxproj Ver arquivo

@@ -1278,7 +1278,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 704;
CURRENT_PROJECT_VERSION = 707;
DEVELOPMENT_TEAM = TPPAB4YBA6;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
@@ -1305,7 +1305,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 704;
CURRENT_PROJECT_VERSION = 707;
DEVELOPMENT_TEAM = TPPAB4YBA6;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;


Carregando…
Cancelar
Salvar