fix: reblog and favorite count update delay issue
This commit is contained in:
parent
931197e51c
commit
04dbe9ebc9
|
@ -247,7 +247,7 @@ extension StatusProviderFacade {
|
||||||
}
|
}
|
||||||
.map { statusObjectID, favoriteKind -> AnyPublisher<(Status.ID, Mastodon.API.Favorites.FavoriteKind), Error> in
|
.map { statusObjectID, favoriteKind -> AnyPublisher<(Status.ID, Mastodon.API.Favorites.FavoriteKind), Error> in
|
||||||
return context.apiService.favorite(
|
return context.apiService.favorite(
|
||||||
statusObjectID: statusObjectID,
|
statusObjectID: statusObjectID,
|
||||||
mastodonUserObjectID: mastodonUserObjectID,
|
mastodonUserObjectID: mastodonUserObjectID,
|
||||||
favoriteKind: favoriteKind
|
favoriteKind: favoriteKind
|
||||||
)
|
)
|
||||||
|
|
|
@ -30,6 +30,14 @@ extension APIService {
|
||||||
let targetStatusID = targetStatus.id
|
let targetStatusID = targetStatus.id
|
||||||
_targetStatusID = targetStatusID
|
_targetStatusID = targetStatusID
|
||||||
|
|
||||||
|
let favouritesCount: NSNumber
|
||||||
|
switch favoriteKind {
|
||||||
|
case .create:
|
||||||
|
favouritesCount = NSNumber(value: targetStatus.favouritesCount.intValue + 1)
|
||||||
|
case .destroy:
|
||||||
|
favouritesCount = NSNumber(value: max(0, targetStatus.favouritesCount.intValue - 1))
|
||||||
|
}
|
||||||
|
targetStatus.update(favouritesCount: favouritesCount)
|
||||||
targetStatus.update(liked: favoriteKind == .create, by: mastodonUser)
|
targetStatus.update(liked: favoriteKind == .create, by: mastodonUser)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,18 @@ extension APIService {
|
||||||
let targetStatusID = targetStatus.id
|
let targetStatusID = targetStatus.id
|
||||||
_targetStatusID = targetStatusID
|
_targetStatusID = targetStatusID
|
||||||
|
|
||||||
|
let reblogsCount: NSNumber
|
||||||
switch reblogKind {
|
switch reblogKind {
|
||||||
case .reblog:
|
case .reblog:
|
||||||
targetStatus.update(reblogged: true, by: mastodonUser)
|
targetStatus.update(reblogged: true, by: mastodonUser)
|
||||||
|
reblogsCount = NSNumber(value: targetStatus.reblogsCount.intValue + 1)
|
||||||
case .undoReblog:
|
case .undoReblog:
|
||||||
targetStatus.update(reblogged: false, by: mastodonUser)
|
targetStatus.update(reblogged: false, by: mastodonUser)
|
||||||
|
reblogsCount = NSNumber(value: max(0, targetStatus.reblogsCount.intValue - 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
targetStatus.update(reblogsCount: reblogsCount)
|
||||||
|
|
||||||
}
|
}
|
||||||
.tryMap { result in
|
.tryMap { result in
|
||||||
switch result {
|
switch result {
|
||||||
|
|
Loading…
Reference in New Issue