fix autosuggest not opening with emoji
This commit is contained in:
parent
4b0924dd3b
commit
24324ddccb
|
@ -224,18 +224,24 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
private detectAutosuggestion(status: string) {
|
private detectAutosuggestion(status: string) {
|
||||||
if (!this.statusLoaded) return;
|
if (!this.statusLoaded) return;
|
||||||
|
|
||||||
|
if(!status.includes('@') && !status.includes('#')){
|
||||||
|
this.autosuggestData = null;
|
||||||
|
this.hasSuggestions = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const caretPosition = this.replyElement.nativeElement.selectionStart;
|
const caretPosition = this.replyElement.nativeElement.selectionStart;
|
||||||
|
|
||||||
const lastChar = status.substr(caretPosition - 1, 1);
|
const lastChar = status.substr(caretPosition - 1, 1);
|
||||||
const lastCharIsSpace = lastChar === ' ';
|
const lastCharIsSpace = lastChar === ' ';
|
||||||
|
|
||||||
const splitedStatus = status.split(/(\r\n|\n|\r)/);
|
const splitedStatus = status.split(/(\r\n|\n|\r)/);
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
let currentSection = '';
|
let currentSection = '';
|
||||||
for(let x of splitedStatus){
|
for (let x of splitedStatus) {
|
||||||
const sectionLength = [...x].length;
|
const sectionLength = x.length;
|
||||||
if(offset + sectionLength >= caretPosition){
|
if (offset + sectionLength >= caretPosition) {
|
||||||
currentSection = x;
|
currentSection = x;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -248,6 +254,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
this.autosuggestData = word;
|
this.autosuggestData = word;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.autosuggestData = null;
|
this.autosuggestData = null;
|
||||||
this.hasSuggestions = false;
|
this.hasSuggestions = false;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +335,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
this.toolsService.getInstanceInfo(this.selectedAccount)
|
this.toolsService.getInstanceInfo(this.selectedAccount)
|
||||||
.then((instance: InstanceInfo) => {
|
.then((instance: InstanceInfo) => {
|
||||||
if(instance.type === InstanceType.Pixelfed){
|
if (instance.type === InstanceType.Pixelfed) {
|
||||||
this.instanceSupportsPoll = false;
|
this.instanceSupportsPoll = false;
|
||||||
this.instanceSupportsScheduling = false;
|
this.instanceSupportsScheduling = false;
|
||||||
this.pollIsActive = false;
|
this.pollIsActive = false;
|
||||||
|
@ -337,7 +344,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
this.instanceSupportsPoll = true;
|
this.instanceSupportsPoll = true;
|
||||||
this.instanceSupportsScheduling = true;
|
this.instanceSupportsScheduling = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,9 +496,9 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
let scheduledTime = null;
|
let scheduledTime = null;
|
||||||
if(this.scheduleIsActive){
|
if (this.scheduleIsActive) {
|
||||||
scheduledTime = this.statusScheduler.getScheduledDate();
|
scheduledTime = this.statusScheduler.getScheduledDate();
|
||||||
if(!scheduledTime || scheduledTime === '') {
|
if (!scheduledTime || scheduledTime === '') {
|
||||||
this.isSending = false;
|
this.isSending = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +513,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
this.status = '';
|
this.status = '';
|
||||||
this.onClose.emit();
|
this.onClose.emit();
|
||||||
|
|
||||||
if(this.scheduleIsActive){
|
if (this.scheduleIsActive) {
|
||||||
this.scheduledStatusService.statusAdded(acc);
|
this.scheduledStatusService.statusAdded(acc);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue