diff --git a/src/renderer/components/TimelineSpace.vue b/src/renderer/components/TimelineSpace.vue index 1abcbde4..4e854acd 100644 --- a/src/renderer/components/TimelineSpace.vue +++ b/src/renderer/components/TimelineSpace.vue @@ -120,6 +120,7 @@ export default { }) }) this.$store.dispatch('TimelineSpace/startLocalStreaming', account) + this.$store.dispatch('TimelineSpace/fetchEmojis', account) }, handleDrop (e) { e.preventDefault() diff --git a/src/renderer/components/TimelineSpace/Modals/NewToot/Status.vue b/src/renderer/components/TimelineSpace/Modals/NewToot/Status.vue index bb0f1eea..78609401 100644 --- a/src/renderer/components/TimelineSpace/Modals/NewToot/Status.vue +++ b/src/renderer/components/TimelineSpace/Modals/NewToot/Status.vue @@ -22,7 +22,7 @@ @shortkey="insertItem(item)" @mouseover="highlightedIndex = index" :class="{'highlighted': highlightedIndex === index}"> - {{ item }} + {{ item.name }} @@ -50,17 +50,13 @@ export default { highlightedIndex: 0, startIndex: null, matchWord: null, - filteredSuggestion: [], - emojis: [ - ':python:', - ':slack:', - ':nodejs' - ] + filteredSuggestion: [] } }, computed: { ...mapState({ - filteredAccounts: state => state.TimelineSpace.Modals.NewToot.Status.filteredAccounts + filteredAccounts: state => state.TimelineSpace.Modals.NewToot.Status.filteredAccounts, + emojis: state => state.TimelineSpace.emojis }), status: { get: function () { @@ -126,7 +122,7 @@ export default { this.closeSuggest() return false } - const filtered = this.emojis.filter(emoji => emoji.includes(word)) + const filtered = this.emojis.filter(emoji => emoji.name.includes(word)) if (filtered.length > 0) { this.openSuggest = true this.startIndex = start @@ -155,7 +151,7 @@ export default { } }, insertItem (item) { - const str = `${this.status.slice(0, this.startIndex)}${item} ${this.status.slice(this.startIndex + this.matchWord.length)}` + const str = `${this.status.slice(0, this.startIndex - 1)}${item.name} ${this.status.slice(this.startIndex + this.matchWord.length)}` this.status = str this.closeSuggest() }, diff --git a/src/renderer/store/TimelineSpace.js b/src/renderer/store/TimelineSpace.js index aa8510d3..e8f24a43 100644 --- a/src/renderer/store/TimelineSpace.js +++ b/src/renderer/store/TimelineSpace.js @@ -1,4 +1,5 @@ import { ipcRenderer } from 'electron' +import Mastodon from 'megalodon' import SideMenu from './TimelineSpace/SideMenu' import HeaderMenu from './TimelineSpace/HeaderMenu' import Modals from './TimelineSpace/Modals' @@ -19,7 +20,8 @@ const TimelineSpace = { _id: '', username: '' }, - loading: false + loading: false, + emojis: [] }, mutations: { updateAccount (state, account) { @@ -27,6 +29,14 @@ const TimelineSpace = { }, changeLoading (state, value) { state.loading = value + }, + updateEmojis (state, emojis) { + state.emojis = emojis.map((e) => { + return { + name: `:${e.shortcode}:`, + image: e.url + } + }) } }, actions: { @@ -151,6 +161,11 @@ const TimelineSpace = { }, async clearUnread ({ dispatch }) { dispatch('TimelineSpace/SideMenu/clearUnread', {}, { root: true }) + }, + async fetchEmojis ({ commit }, account) { + const data = await Mastodon.get('/custom_emojis', {}, account.baseURL + '/api/v1') + commit('updateEmojis', data) + return data } } } diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.js b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.js index 48183cdf..2f34081e 100644 --- a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.js +++ b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.js @@ -7,7 +7,12 @@ const Status = { }, mutations: { updateFilteredAccounts (state, accounts) { - state.filteredAccounts = accounts.map(a => a.acct) + state.filteredAccounts = accounts.map((a) => { + return { + name: `@${a.acct}`, + image: null + } + }) }, clearFilteredAccounts (state) { state.filteredAccounts = []