From 2162ef20b0d00a098c9968ca6c141bccd5efb29f Mon Sep 17 00:00:00 2001 From: eal Date: Tue, 19 Sep 2017 22:43:20 +0300 Subject: Add emoji completion. --- src/components/post_status_form/post_status_form.js | 20 ++++++++++++++++++-- src/components/post_status_form/post_status_form.vue | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src/components') diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 86bf2fa7..6fc84407 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -50,17 +50,30 @@ const PostStatusForm = { }, computed: { candidates () { - if (this.textAtCaret.charAt(0) === '@') { + const firstchar = this.textAtCaret.charAt(0) + if (firstchar === '@') { const matchedUsers = filter(this.users, (user) => (String(user.name + user.screen_name)).match(this.textAtCaret.slice(1))) if (matchedUsers.length <= 0) { return false } // eslint-disable-next-line camelcase return map(take(matchedUsers, 5), ({screen_name, name, profile_image_url_original}) => ({ - screen_name: screen_name, + // eslint-disable-next-line camelcase + screen_name: `@${screen_name}`, name: name, img: profile_image_url_original })) + } else if (firstchar === ':') { + const matchedEmoji = filter(this.emoji, (emoji) => emoji.shortcode.match(this.textAtCaret.slice(1))) + if (matchedEmoji.length <= 0) { + return false + } + return map(take(matchedEmoji, 5), ({shortcode, image_url}) => ({ + // eslint-disable-next-line camelcase + screen_name: `:${shortcode}:`, + name: '', + img: image_url + })) } else { return false } @@ -74,6 +87,9 @@ const PostStatusForm = { }, users () { return this.$store.state.users.users + }, + emoji () { + return this.$store.state.config.emoji || [] } }, methods: { diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index b46fbf3a..5a6e02e5 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -6,10 +6,10 @@
-
+
- @{{candidate.screen_name}} + {{candidate.screen_name}} {{candidate.name}}
-- cgit v1.2.3-70-g09d2 From 70d66c48ad6db4e8e3d2142001cdf8ed5344a9d4 Mon Sep 17 00:00:00 2001 From: eal Date: Tue, 19 Sep 2017 22:50:08 +0300 Subject: Fix image url. --- src/components/post_status_form/post_status_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components') diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 6fc84407..6d89b051 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -72,7 +72,7 @@ const PostStatusForm = { // eslint-disable-next-line camelcase screen_name: `:${shortcode}:`, name: '', - img: image_url + img: url })) } else { return false -- cgit v1.2.3-70-g09d2 From f4b1319eff7562ff71181a75f967de6ec52337c2 Mon Sep 17 00:00:00 2001 From: eal Date: Tue, 19 Sep 2017 22:54:54 +0300 Subject: Actually fix image url. --- src/components/post_status_form/post_status_form.js | 2 +- src/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/components') diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 6d89b051..2e0aafd0 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -72,7 +72,7 @@ const PostStatusForm = { // eslint-disable-next-line camelcase screen_name: `:${shortcode}:`, name: '', - img: url + img: image-url })) } else { return false diff --git a/src/main.js b/src/main.js index a13569d6..2ab548a6 100644 --- a/src/main.js +++ b/src/main.js @@ -108,7 +108,7 @@ window.fetch('/static/emoji.txt') .then((csv) => { const emoji = csv.split('\n').map((row) => { const values = row.split(', ') - return { shortcode: values[0], url: values[1] } + return { shortcode: values[0], image-url: values[1] } }) store.dispatch('setOption', { name: 'emoji', value: emoji }) }) -- cgit v1.2.3-70-g09d2 From 447ec911766a9c5b6d5512a9e054fdbbe39df92a Mon Sep 17 00:00:00 2001 From: eal Date: Tue, 19 Sep 2017 22:58:15 +0300 Subject: Actually actually fix image url. --- src/components/post_status_form/post_status_form.js | 2 +- src/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/components') diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 2e0aafd0..6fc84407 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -72,7 +72,7 @@ const PostStatusForm = { // eslint-disable-next-line camelcase screen_name: `:${shortcode}:`, name: '', - img: image-url + img: image_url })) } else { return false diff --git a/src/main.js b/src/main.js index 2ab548a6..bac4d0f7 100644 --- a/src/main.js +++ b/src/main.js @@ -108,7 +108,7 @@ window.fetch('/static/emoji.txt') .then((csv) => { const emoji = csv.split('\n').map((row) => { const values = row.split(', ') - return { shortcode: values[0], image-url: values[1] } + return { shortcode: values[0], image_url: values[1] } }) store.dispatch('setOption', { name: 'emoji', value: emoji }) }) -- cgit v1.2.3-70-g09d2