fix: reblog and favorite count update delay issue
This commit is contained in:
parent
931197e51c
commit
04dbe9ebc9
|
@ -30,6 +30,14 @@ extension APIService {
|
|||
let targetStatusID = targetStatus.id
|
||||
_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)
|
||||
|
||||
}
|
||||
|
|
|
@ -29,13 +29,18 @@ extension APIService {
|
|||
let targetStatusID = targetStatus.id
|
||||
_targetStatusID = targetStatusID
|
||||
|
||||
let reblogsCount: NSNumber
|
||||
switch reblogKind {
|
||||
case .reblog:
|
||||
targetStatus.update(reblogged: true, by: mastodonUser)
|
||||
reblogsCount = NSNumber(value: targetStatus.reblogsCount.intValue + 1)
|
||||
case .undoReblog:
|
||||
targetStatus.update(reblogged: false, by: mastodonUser)
|
||||
reblogsCount = NSNumber(value: max(0, targetStatus.reblogsCount.intValue - 1))
|
||||
}
|
||||
|
||||
targetStatus.update(reblogsCount: reblogsCount)
|
||||
|
||||
}
|
||||
.tryMap { result in
|
||||
switch result {
|
||||
|
|
Loading…
Reference in New Issue