Fix reblog with visibility not working

This commit is contained in:
Shadowfacts 2023-06-26 21:41:43 -07:00
parent bd162afdcc
commit 1de586f907
1 changed files with 4 additions and 5 deletions

View File

@ -17,7 +17,6 @@ class ReblogService {
private let status: StatusMO private let status: StatusMO
var hapticFeedback = true var hapticFeedback = true
var visibility: Visibility? = nil
var requireConfirmation = Preferences.shared.confirmBeforeReblog var requireConfirmation = Preferences.shared.confirmBeforeReblog
init(status: StatusMO, mastodonController: MastodonController, presenter: any TuskerNavigationDelegate) { init(status: StatusMO, mastodonController: MastodonController, presenter: any TuskerNavigationDelegate) {
@ -31,7 +30,7 @@ class ReblogService {
requireConfirmation { requireConfirmation {
presentConfirmationAlert() presentConfirmationAlert()
} else { } else {
await doToggleReblog() await doToggleReblog(visibility: nil)
} }
} }
@ -48,7 +47,7 @@ class ReblogService {
return CustomAlertController.MenuAction(title: "Reblog as \(visibility.displayName)", subtitle: visibility.subtitle, image: UIImage(systemName: visibility.unfilledImageName)) { return CustomAlertController.MenuAction(title: "Reblog as \(visibility.displayName)", subtitle: visibility.subtitle, image: UIImage(systemName: visibility.unfilledImageName)) {
// deliberately retain a strong reference to self // deliberately retain a strong reference to self
Task { Task {
await self.doToggleReblog() await self.doToggleReblog(visibility: visibility)
} }
} }
} }
@ -63,7 +62,7 @@ class ReblogService {
CustomAlertController.Action(title: "Reblog", image: image, style: .default, handler: { CustomAlertController.Action(title: "Reblog", image: image, style: .default, handler: {
// deliberately retain a strong reference to self // deliberately retain a strong reference to self
Task { Task {
await self.doToggleReblog() await self.doToggleReblog(visibility: nil)
} }
}) })
]) ])
@ -76,7 +75,7 @@ class ReblogService {
presenter.present(alert, animated: true) presenter.present(alert, animated: true)
} }
private func doToggleReblog() async { private func doToggleReblog(visibility: Visibility?) async {
let oldValue = status.reblogged let oldValue = status.reblogged
status.reblogged.toggle() status.reblogged.toggle()
mastodonController.persistentContainer.statusSubject.send(status.id) mastodonController.persistentContainer.statusSubject.send(status.id)