forked from shadowfacts/Tusker
Fix faving/reblogging statuses by tapping buttons
This commit is contained in:
parent
51a03553a9
commit
44cfd44651
|
@ -149,9 +149,10 @@ class ConversationMainStatusTableViewCell: UITableViewCell, PreferencesAdaptive
|
||||||
|
|
||||||
let request = (favorited ? Status.favourite : Status.unfavourite)(realStatus)
|
let request = (favorited ? Status.favourite : Status.unfavourite)(realStatus)
|
||||||
MastodonController.client.run(request) { response in
|
MastodonController.client.run(request) { response in
|
||||||
self.favorited = realStatus.favourited ?? false
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if case .success = response {
|
if case let .success(newStatus, _) = response {
|
||||||
|
self.favorited = newStatus.favourited ?? false
|
||||||
|
MastodonCache.add(status: newStatus)
|
||||||
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||||
} else {
|
} else {
|
||||||
print("Couldn't favorite status \(realStatus.id)")
|
print("Couldn't favorite status \(realStatus.id)")
|
||||||
|
@ -172,9 +173,10 @@ class ConversationMainStatusTableViewCell: UITableViewCell, PreferencesAdaptive
|
||||||
|
|
||||||
let request = (reblogged ? Status.reblog : Status.unreblog)(realStatus)
|
let request = (reblogged ? Status.reblog : Status.unreblog)(realStatus)
|
||||||
MastodonController.client.run(request) { response in
|
MastodonController.client.run(request) { response in
|
||||||
self.reblogged = realStatus.reblogged ?? false
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if case .success = response {
|
if case let .success(newStatus, _) = response {
|
||||||
|
self.reblogged = newStatus.reblogged ?? false
|
||||||
|
MastodonCache.add(status: newStatus)
|
||||||
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||||
} else {
|
} else {
|
||||||
print("Couldn't reblog status \(realStatus.id)")
|
print("Couldn't reblog status \(realStatus.id)")
|
||||||
|
|
|
@ -175,9 +175,9 @@ class StatusTableViewCell: UITableViewCell, PreferencesAdaptive {
|
||||||
let request = (favorited ? Status.favourite : Status.unfavourite)(realStatus)
|
let request = (favorited ? Status.favourite : Status.unfavourite)(realStatus)
|
||||||
MastodonController.client.run(request) { response in
|
MastodonController.client.run(request) { response in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.favorited = realStatus.favourited ?? false
|
if case let .success(newStatus, _) = response {
|
||||||
if case .success = response {
|
self.favorited = newStatus.favourited ?? false
|
||||||
self.favorited = realStatus.favourited ?? false
|
MastodonCache.add(status: newStatus)
|
||||||
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||||
} else {
|
} else {
|
||||||
self.favorited = oldValue
|
self.favorited = oldValue
|
||||||
|
@ -199,10 +199,10 @@ class StatusTableViewCell: UITableViewCell, PreferencesAdaptive {
|
||||||
let realStatus: Status = status.reblog ?? status
|
let realStatus: Status = status.reblog ?? status
|
||||||
let request = (reblogged ? Status.reblog : Status.unreblog)(realStatus)
|
let request = (reblogged ? Status.reblog : Status.unreblog)(realStatus)
|
||||||
MastodonController.client.run(request) { response in
|
MastodonController.client.run(request) { response in
|
||||||
self.reblogged = realStatus.reblogged ?? false
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if case .success = response {
|
if case let .success(newStatus, _) = response {
|
||||||
self.reblogged = realStatus.reblogged ?? false
|
self.reblogged = newStatus.reblogged ?? false
|
||||||
|
MastodonCache.add(status: newStatus)
|
||||||
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||||
} else {
|
} else {
|
||||||
self.reblogged = oldValue
|
self.reblogged = oldValue
|
||||||
|
|
Loading…
Reference in New Issue