fix redrafting status

This commit is contained in:
Nicolas Constant 2019-07-09 00:20:05 -04:00
parent f3fe5f900b
commit 1956e06121
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 16 additions and 2 deletions

View File

@ -44,7 +44,10 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
@Input('redraftedStatus')
set redraftedStatus(value: StatusWrapper) {
if (value) {
this.status = value.status.content.replace(/<[^>]*>/g, '');
let parser = new DOMParser();
var dom = parser.parseFromString(value.status.content, 'text/html')
this.status = dom.body.textContent;
this.setVisibilityFromStatus(value.status);
this.title = value.status.spoiler_text;
@ -52,7 +55,18 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.isSending = true;
this.mastodonService.getStatus(value.provider, value.status.in_reply_to_id)
.then((status: Status) => {
this.statusReplyingTo = status;
this.statusReplyingToWrapper = new StatusWrapper(status, value.provider);
const mentions = this.getMentions(this.statusReplyingToWrapper.status, this.statusReplyingToWrapper.provider);
for (const mention of mentions) {
const name = `@${mention.split('@')[0]}`;
if(this.status.includes(name)){
this.status = this.status.replace(name, `@${mention}`);
} else {
this.status = `@${mention} ` + this.status;
}
}
})
.catch(err => {
this.notificationService.notifyHttpError(err);