summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAcid Chicken (硫酸鶏) <root@acid-chicken.com>2018-07-20 19:23:10 +0900
committerAya Morisawa <AyaMorisawa4869@gmail.com>2018-07-20 21:12:28 +0900
commitbc627fc55c8cba0d9410d1d54c6ccbc9fe822624 (patch)
treed840645854553b5dbe6616d0a31414963009c6e7 /src
parentUpdate bug_report.md (diff)
downloadsharkey-bc627fc55c8cba0d9410d1d54c6ccbc9fe822624.tar.gz
sharkey-bc627fc55c8cba0d9410d1d54c6ccbc9fe822624.tar.bz2
sharkey-bc627fc55c8cba0d9410d1d54c6ccbc9fe822624.zip
タグサジェストが重複しないようにする
Diffstat (limited to 'src')
-rw-r--r--src/client/app/desktop/views/components/post-form.vue5
-rw-r--r--src/client/app/mobile/views/components/post-form.vue5
2 files changed, 4 insertions, 6 deletions
diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue
index 5efa1eacca..aaec36ed37 100644
--- a/src/client/app/desktop/views/components/post-form.vue
+++ b/src/client/app/desktop/views/components/post-form.vue
@@ -382,9 +382,8 @@ export default Vue.extend({
if (this.text && this.text != '') {
const hashtags = parse(this.text).filter(x => x.type == 'hashtag').map(x => x.hashtag);
- let history = JSON.parse(localStorage.getItem('hashtags') || '[]') as string[];
- history = history.filter(x => !hashtags.includes(x));
- localStorage.setItem('hashtags', JSON.stringify(hashtags.concat(history)));
+ const history = JSON.parse(localStorage.getItem('hashtags') || '[]') as string[];
+ localStorage.setItem('hashtags', JSON.stringify(hashtags.concat(history).reduce((a, c) => a.includes(c) ? a : [...a, c], [])));
}
},
diff --git a/src/client/app/mobile/views/components/post-form.vue b/src/client/app/mobile/views/components/post-form.vue
index 05e8b09865..b04a1968dc 100644
--- a/src/client/app/mobile/views/components/post-form.vue
+++ b/src/client/app/mobile/views/components/post-form.vue
@@ -295,9 +295,8 @@ export default Vue.extend({
if (this.text && this.text != '') {
const hashtags = parse(this.text).filter(x => x.type == 'hashtag').map(x => x.hashtag);
- let history = JSON.parse(localStorage.getItem('hashtags') || '[]') as string[];
- history = history.filter(x => !hashtags.includes(x));
- localStorage.setItem('hashtags', JSON.stringify(hashtags.concat(history)));
+ const history = JSON.parse(localStorage.getItem('hashtags') || '[]') as string[];
+ localStorage.setItem('hashtags', JSON.stringify(hashtags.concat(history).reduce((a, c) => a.includes(c) ? a : [...a, c], [])));
}
},