fix status new state overrinding current state

This commit is contained in:
Nicolas Constant 2020-03-13 21:02:37 -04:00
parent a41a46168a
commit fe9cb7fea1
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 17 additions and 10 deletions

View File

@ -77,7 +77,7 @@ export class ActionBarComponent implements OnInit, OnDestroy {
this.displayedStatus = this.statusWrapper.status;
const account = this.statusWrapper.provider;
if(this.displayedStatus.reblog){
if (this.displayedStatus.reblog) {
this.displayedStatus = this.displayedStatus.reblog;
}
@ -97,9 +97,16 @@ export class ActionBarComponent implements OnInit, OnDestroy {
this.statusStateSub = this.statusStateService.stateNotification.subscribe((state: StatusState) => {
if (state && state.statusId === this.displayedStatus.url) {
this.favoriteStatePerAccountId[state.accountId] = state.isFavorited;
this.bootedStatePerAccountId[state.accountId] = state.isRebloged;
this.bookmarkStatePerAccountId[state.accountId] = state.isBookmarked;
if (state.isFavorited) {
this.favoriteStatePerAccountId[state.accountId] = state.isFavorited;
}
if (state.isRebloged) {
this.bootedStatePerAccountId[state.accountId] = state.isRebloged;
}
if (state.isBookmarked) {
this.bookmarkStatePerAccountId[state.accountId] = state.isBookmarked;
}
this.checkIfFavorited();
this.checkIfBoosted();
@ -145,13 +152,13 @@ export class ActionBarComponent implements OnInit, OnDestroy {
if (status.sensitive || status.spoiler_text) {
this.isContentWarningActive = true;
}
this.checkIfBookmarksAreAvailable(this.selectedAccounts[0]);
this.checkIfFavorited();
this.checkIfBoosted();
this.checkIfBookmarked();
}
showContent(): boolean {
this.isContentWarningActive = false;
@ -320,7 +327,7 @@ export class ActionBarComponent implements OnInit, OnDestroy {
private checkIfBookmarksAreAvailable(account: AccountInfo) {
this.toolsService.getInstanceInfo(account)
.then((instance: InstanceInfo) => {
if(instance.major >= 3 && instance.minor >= 1){
if (instance.major >= 3 && instance.minor >= 1) {
this.isBookmarksAvailable = true;
} else {
this.isBookmarksAvailable = false;

View File

@ -29,7 +29,7 @@ export class StatusesStateService {
this.cachedStatusStates[statusId] = {};
if (!this.cachedStatusStates[statusId][accountId]) {
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, isFavorited, false, false);
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, isFavorited, null, null);
} else {
this.cachedStatusStates[statusId][accountId].isFavorited = isFavorited;
}
@ -42,7 +42,7 @@ export class StatusesStateService {
this.cachedStatusStates[statusId] = {};
if (!this.cachedStatusStates[statusId][accountId]) {
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, false, isRebloged, false);
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, null, isRebloged, null);
} else {
this.cachedStatusStates[statusId][accountId].isRebloged = isRebloged;
}
@ -55,7 +55,7 @@ export class StatusesStateService {
this.cachedStatusStates[statusId] = {};
if (!this.cachedStatusStates[statusId][accountId]) {
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, false, false, isBookmarked);
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, null, null, isBookmarked);
} else {
this.cachedStatusStates[statusId][accountId].isBookmarked = isBookmarked;
}