D&R stop messing with status state, fix #291

This commit is contained in:
Nicolas Constant 2020-05-28 23:56:42 -04:00
parent 8000f51aaa
commit 0ee30eba76
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 36 additions and 18 deletions

View File

@ -41,6 +41,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
faClock = faClock;
autoSuggestUserActionsStream = new EventEmitter<AutosuggestUserActionEnum>();
private isRedrafting: boolean;
private _title: string;
set title(value: string) {
@ -54,7 +55,11 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
private _status: string = '';
@Input('status')
set status(value: string) {
if (this.isRedrafting) {
this.statusStateService.setStatusContent(value, null);
} else {
this.statusStateService.setStatusContent(value, this.statusReplyingToWrapper);
}
this.countStatusChar(value);
this.detectAutosuggestion(value);
this._status = value;
@ -80,6 +85,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
@Input('redraftedStatus')
set redraftedStatus(value: StatusWrapper) {
if (value) {
this.isRedrafting = true;
this.statusLoaded = false;
if (value.status && value.status.media_attachments) {
@ -103,7 +109,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
var dom = parser.parseFromString(content, 'text/html')
this.status = dom.body.textContent;
this.statusStateService.setStatusContent(this.status, this.statusReplyingToWrapper);
// this.statusStateService.setStatusContent(this.status, this.statusReplyingToWrapper);
this.setVisibilityFromStatus(value.status);
this.title = value.status.spoiler_text;
@ -193,10 +199,13 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
public viewContainerRef: ViewContainerRef) {
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
this.status = this.statusStateService.getStatusContent(this.statusReplyingToWrapper);
}
ngOnInit() {
if (!this.isRedrafting) {
this.status = this.statusStateService.getStatusContent(this.statusReplyingToWrapper);
}
this.accountSub = this.accounts$.subscribe((accounts: AccountInfo[]) => {
this.accountChanged(accounts);
});
@ -209,10 +218,11 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.statusReplyingTo = this.statusReplyingToWrapper.status;
}
let state = this.statusStateService.getStatusContent(this.statusReplyingToWrapper);
if (state && state !== '') {
this.status = state;
} else {
// let state = this.statusStateService.getStatusContent(this.statusReplyingToWrapper);
// if (state && state !== '') {
// this.status = state;
// } else {
if(!this.status || this.status === '') {
const uniqueMentions = this.getMentions(this.statusReplyingTo, this.statusReplyingToWrapper.provider);
for (const mention of uniqueMentions) {
this.status += `@${mention} `;
@ -233,6 +243,10 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
}
ngOnDestroy() {
if(this.isRedrafting){
this.statusStateService.resetStatusContent(null);
}
this.accountSub.unsubscribe();
}
@ -563,7 +577,11 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.scheduledStatusService.statusAdded(acc);
}
if(this.isRedrafting){
this.statusStateService.resetStatusContent(null);
} else {
this.statusStateService.resetStatusContent(this.statusReplyingToWrapper);
}
})
.catch((err: HttpErrorResponse) => {
this.notificationService.notifyHttpError(err, acc);