don't pop autosuggestion on mention

This commit is contained in:
Nicolas Constant 2019-07-26 18:20:39 -04:00
parent 0ae14edba5
commit f7ec1ce0a3
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 10 additions and 5 deletions

View File

@ -59,12 +59,14 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
@Input('redraftedStatus')
set redraftedStatus(value: StatusWrapper) {
if (value) {
this.statusLoaded = false;
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;
this.statusLoaded = true;
if (value.status.in_reply_to_id) {
this.isSending = true;
@ -87,7 +89,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.notificationService.notifyHttpError(err);
})
.then(() => {
this.isSending = false;
this.isSending = false;
});
}
}
@ -99,6 +101,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
isSending: boolean;
mentionTooFarAwayError: boolean;
autosuggestData: string = null;
private statusLoaded: boolean;
@Input() statusReplyingToWrapper: StatusWrapper;
@Output() onClose = new EventEmitter();
@ -121,7 +124,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
private _replyingUserHandle: string;
@Input('replyingUserHandle')
set replyingUserHandle(value: string) {
if (value) {
if (value) {
this._replyingUserHandle = value;
this.initMention();
}
@ -150,7 +153,6 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
}
private loaded: boolean;
ngOnInit() {
this.accountSub = this.accounts$.subscribe((accounts: AccountInfo[]) => {
this.accountChanged(accounts);
@ -176,7 +178,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.initMention();
}
this.loaded = true;
this.statusLoaded = true;
this.focus();
}
@ -201,7 +203,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
}
private detectAutosuggestion(status: string) {
if (!this.loaded) return;
if (!this.statusLoaded) return;
const caretPosition = this.replyElement.nativeElement.selectionStart;
const word = this.getWordByPos(status, caretPosition);
@ -235,6 +237,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
}
private initMention() {
this.statusLoaded = false;
if (!this.selectedAccount) {
this.selectedAccount = this.toolsService.getSelectedAccounts()[0];
}
@ -247,6 +251,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.status = `${this.replyingUserHandle} `;
this.countStatusChar(this.status);
this.statusLoaded = true;
this.focus();
}