Fix bookmarked state (IOS-176)
This commit is contained in:
parent
45accb29e6
commit
7ad0b15b32
|
@ -13,15 +13,17 @@ import MastodonSDK
|
|||
|
||||
extension DataSourceFacade {
|
||||
public static func responseToStatusBookmarkAction(
|
||||
provider: UIViewController & NeedsDependency & AuthContextProvider,
|
||||
provider: UIViewController & NeedsDependency & AuthContextProvider & DataSourceProvider,
|
||||
status: MastodonStatus
|
||||
) async throws {
|
||||
let selectionFeedbackGenerator = await UISelectionFeedbackGenerator()
|
||||
await selectionFeedbackGenerator.selectionChanged()
|
||||
|
||||
_ = try await provider.context.apiService.bookmark(
|
||||
let updatedStatus = try await provider.context.apiService.bookmark(
|
||||
record: status,
|
||||
authenticationBox: provider.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
).value
|
||||
|
||||
provider.update(status: .fromEntity(updatedStatus))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,12 +52,14 @@ final public class FeedFetchedResultsController {
|
|||
case .some(true):
|
||||
newRecords[i] = .fromStatus({
|
||||
let stat = MastodonStatus.fromEntity(records[i].status!.entity)
|
||||
stat.isSensitiveToggled = status.isSensitiveToggled
|
||||
stat.reblog = .fromEntity(status.entity)
|
||||
return stat
|
||||
}(), kind: record.kind)
|
||||
case .some(false), .none:
|
||||
newRecords[i] = .fromStatus({
|
||||
let stat = MastodonStatus.fromEntity(status.entity)
|
||||
stat.isSensitiveToggled = status.isSensitiveToggled
|
||||
return stat
|
||||
}(), kind: record.kind)
|
||||
}
|
||||
|
|
|
@ -27,7 +27,16 @@ extension StatusView {
|
|||
|
||||
public var context: AppContext?
|
||||
public var authContext: AuthContext?
|
||||
public var originalStatus: MastodonStatus?
|
||||
public var originalStatus: MastodonStatus? {
|
||||
didSet {
|
||||
originalStatus?.$entity
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(receiveValue: { status in
|
||||
self.isBookmark = status.bookmarked == true
|
||||
})
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
}
|
||||
|
||||
// Header
|
||||
@Published public var header: Header = .none
|
||||
|
@ -148,6 +157,7 @@ extension StatusView {
|
|||
isMediaSensitive = false
|
||||
isSensitiveToggled = false
|
||||
isCurrentlyTranslating = false
|
||||
isBookmark = false
|
||||
translation = nil
|
||||
|
||||
activeFilters = []
|
||||
|
|
Loading…
Reference in New Issue