mirror of
https://github.com/misskey-dev/misskey
synced 2024-12-02 00:38:31 +09:00
Improve hashtag suggestion
This commit is contained in:
parent
7316352ff5
commit
afcf2fddb1
@ -144,6 +144,10 @@ export default Vue.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (this.type == 'hashtag') {
|
} else if (this.type == 'hashtag') {
|
||||||
|
if (this.q == null || this.q == '') {
|
||||||
|
this.hashtags = JSON.parse(localStorage.getItem('hashtags') || '[]');
|
||||||
|
this.fetching = false;
|
||||||
|
} else {
|
||||||
const cacheKey = 'autocomplete:hashtag:' + this.q;
|
const cacheKey = 'autocomplete:hashtag:' + this.q;
|
||||||
const cache = sessionStorage.getItem(cacheKey);
|
const cache = sessionStorage.getItem(cacheKey);
|
||||||
if (cache) {
|
if (cache) {
|
||||||
@ -162,6 +166,7 @@ export default Vue.extend({
|
|||||||
sessionStorage.setItem(cacheKey, JSON.stringify(hashtags));
|
sessionStorage.setItem(cacheKey, JSON.stringify(hashtags));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (this.type == 'emoji') {
|
} else if (this.type == 'emoji') {
|
||||||
const matched = [];
|
const matched = [];
|
||||||
emjdb.some(x => {
|
emjdb.some(x => {
|
||||||
|
@ -79,7 +79,10 @@ class Autocomplete {
|
|||||||
hashtagIndex == -1 ? Infinity : hashtagIndex,
|
hashtagIndex == -1 ? Infinity : hashtagIndex,
|
||||||
emojiIndex == -1 ? Infinity : emojiIndex);
|
emojiIndex == -1 ? Infinity : emojiIndex);
|
||||||
|
|
||||||
if (start == Infinity) return;
|
if (start == Infinity) {
|
||||||
|
this.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const isMention = mentionIndex == start;
|
const isMention = mentionIndex == start;
|
||||||
const isHashtag = hashtagIndex == start;
|
const isHashtag = hashtagIndex == start;
|
||||||
@ -97,7 +100,7 @@ class Autocomplete {
|
|||||||
|
|
||||||
if (isHashtag || opened == false) {
|
if (isHashtag || opened == false) {
|
||||||
const hashtag = text.substr(hashtagIndex + 1);
|
const hashtag = text.substr(hashtagIndex + 1);
|
||||||
if (hashtag != '' && !hashtag.includes(' ') && !hashtag.includes('\n')) {
|
if (!hashtag.includes(' ') && !hashtag.includes('\n')) {
|
||||||
this.open('hashtag', hashtag);
|
this.open('hashtag', hashtag);
|
||||||
opened = true;
|
opened = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user