Enable searching toots by link
This commit is contained in:
parent
90865f6ec5
commit
536f88b038
|
@ -274,7 +274,8 @@
|
|||
"search": {
|
||||
"search": "Suche",
|
||||
"account": "Konto",
|
||||
"keyword": "stichwort"
|
||||
"keyword": "stichwort",
|
||||
"toot": "Toot"
|
||||
},
|
||||
"lists": {
|
||||
"index": {
|
||||
|
|
|
@ -295,7 +295,8 @@
|
|||
"search": "Search",
|
||||
"account": "Account",
|
||||
"tag": "Hashtag",
|
||||
"keyword": "keyword"
|
||||
"keyword": "keyword",
|
||||
"toot": "Toot"
|
||||
},
|
||||
"lists": {
|
||||
"index": {
|
||||
|
|
|
@ -274,7 +274,8 @@
|
|||
"search": {
|
||||
"search": "Rechercher",
|
||||
"account": "Compte",
|
||||
"keyword": "mot clé"
|
||||
"keyword": "mot clé",
|
||||
"toot": "Pouets"
|
||||
},
|
||||
"lists": {
|
||||
"index": {
|
||||
|
|
|
@ -288,7 +288,8 @@
|
|||
"search": "検索",
|
||||
"account": "アカウント",
|
||||
"tag": "ハッシュタグ",
|
||||
"keyword": "キーワード"
|
||||
"keyword": "キーワード",
|
||||
"toot": "トゥート時"
|
||||
},
|
||||
"lists": {
|
||||
"index": {
|
||||
|
|
|
@ -274,7 +274,8 @@
|
|||
"search": {
|
||||
"search": "검색",
|
||||
"account": "계정",
|
||||
"keyword": "키워드"
|
||||
"keyword": "키워드",
|
||||
"toot": "툿"
|
||||
},
|
||||
"lists": {
|
||||
"index": {
|
||||
|
|
|
@ -274,7 +274,8 @@
|
|||
"search": {
|
||||
"search": "Szukaj",
|
||||
"account": "Konta",
|
||||
"keyword": "Słowo kluczowe"
|
||||
"keyword": "Słowo kluczowe",
|
||||
"toot": "Wpisy"
|
||||
},
|
||||
"lists": {
|
||||
"index": {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<div class="search-result">
|
||||
<search-account v-if="target==='account'"></search-account>
|
||||
<search-tag v-else-if="target==='tag'"></search-tag>
|
||||
<search-toots v-else-if="target==='toot'"></search-toots>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -25,10 +26,11 @@
|
|||
import { mapState } from 'vuex'
|
||||
import SearchAccount from './Search/Account'
|
||||
import SearchTag from './Search/Tag'
|
||||
import SearchToots from './Search/Toots'
|
||||
|
||||
export default {
|
||||
name: 'search',
|
||||
components: { SearchAccount, SearchTag },
|
||||
components: { SearchAccount, SearchTag, SearchToots },
|
||||
data () {
|
||||
return {
|
||||
target: 'account',
|
||||
|
@ -50,6 +52,10 @@ export default {
|
|||
{
|
||||
target: 'tag',
|
||||
label: this.$t('search.tag')
|
||||
},
|
||||
{
|
||||
target: 'toot',
|
||||
label: this.$t('search.toot')
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -76,6 +82,15 @@ export default {
|
|||
})
|
||||
})
|
||||
break
|
||||
case 'toot':
|
||||
this.$store.dispatch('TimelineSpace/Contents/Search/Toots/search', this.query)
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: this.$t('message.search_error'),
|
||||
type: 'error'
|
||||
})
|
||||
})
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<template>
|
||||
<div id="search_account">
|
||||
<div v-bind:key="message.uri + message.id" v-for="message in results">
|
||||
<toot :message="message"></toot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import Toot from '~/src/renderer/components/molecules/Toot'
|
||||
|
||||
export default {
|
||||
name: 'search-account',
|
||||
components: { Toot },
|
||||
computed: {
|
||||
...mapState({
|
||||
results: state => state.TimelineSpace.Contents.Search.Toots.results
|
||||
})
|
||||
},
|
||||
destroyed () {
|
||||
this.$store.commit('TimelineSpace/Contents/Search/Toots/updateResults', [])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
|
@ -1,9 +1,10 @@
|
|||
import Account from './Search/Account'
|
||||
import Tag from './Search/Tag'
|
||||
import Toots from './Search/Toots'
|
||||
|
||||
const Search = {
|
||||
namespaced: true,
|
||||
modules: { Account, Tag },
|
||||
modules: { Account, Tag, Toots },
|
||||
state: {
|
||||
loading: false
|
||||
},
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import Mastodon from 'megalodon'
|
||||
|
||||
const Toots = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
results: []
|
||||
},
|
||||
mutations: {
|
||||
updateResults (state, results) {
|
||||
state.results = results
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
search ({ state, commit, rootState }, query) {
|
||||
commit('TimelineSpace/Contents/Search/changeLoading', true, { root: true })
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
return client.get('/search', { q: query, resolve: true })
|
||||
.then(res => {
|
||||
commit('updateResults', res.data.statuses)
|
||||
return res.data
|
||||
})
|
||||
.finally(() => {
|
||||
commit('TimelineSpace/Contents/Search/changeLoading', false, { root: true })
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Toots
|
Loading…
Reference in New Issue