Enable searching toots by link
This commit is contained in:
parent
90865f6ec5
commit
536f88b038
@ -274,7 +274,8 @@
|
|||||||
"search": {
|
"search": {
|
||||||
"search": "Suche",
|
"search": "Suche",
|
||||||
"account": "Konto",
|
"account": "Konto",
|
||||||
"keyword": "stichwort"
|
"keyword": "stichwort",
|
||||||
|
"toot": "Toot"
|
||||||
},
|
},
|
||||||
"lists": {
|
"lists": {
|
||||||
"index": {
|
"index": {
|
||||||
|
@ -295,7 +295,8 @@
|
|||||||
"search": "Search",
|
"search": "Search",
|
||||||
"account": "Account",
|
"account": "Account",
|
||||||
"tag": "Hashtag",
|
"tag": "Hashtag",
|
||||||
"keyword": "keyword"
|
"keyword": "keyword",
|
||||||
|
"toot": "Toot"
|
||||||
},
|
},
|
||||||
"lists": {
|
"lists": {
|
||||||
"index": {
|
"index": {
|
||||||
|
@ -274,7 +274,8 @@
|
|||||||
"search": {
|
"search": {
|
||||||
"search": "Rechercher",
|
"search": "Rechercher",
|
||||||
"account": "Compte",
|
"account": "Compte",
|
||||||
"keyword": "mot clé"
|
"keyword": "mot clé",
|
||||||
|
"toot": "Pouets"
|
||||||
},
|
},
|
||||||
"lists": {
|
"lists": {
|
||||||
"index": {
|
"index": {
|
||||||
|
@ -288,7 +288,8 @@
|
|||||||
"search": "検索",
|
"search": "検索",
|
||||||
"account": "アカウント",
|
"account": "アカウント",
|
||||||
"tag": "ハッシュタグ",
|
"tag": "ハッシュタグ",
|
||||||
"keyword": "キーワード"
|
"keyword": "キーワード",
|
||||||
|
"toot": "トゥート時"
|
||||||
},
|
},
|
||||||
"lists": {
|
"lists": {
|
||||||
"index": {
|
"index": {
|
||||||
|
@ -274,7 +274,8 @@
|
|||||||
"search": {
|
"search": {
|
||||||
"search": "검색",
|
"search": "검색",
|
||||||
"account": "계정",
|
"account": "계정",
|
||||||
"keyword": "키워드"
|
"keyword": "키워드",
|
||||||
|
"toot": "툿"
|
||||||
},
|
},
|
||||||
"lists": {
|
"lists": {
|
||||||
"index": {
|
"index": {
|
||||||
|
@ -274,7 +274,8 @@
|
|||||||
"search": {
|
"search": {
|
||||||
"search": "Szukaj",
|
"search": "Szukaj",
|
||||||
"account": "Konta",
|
"account": "Konta",
|
||||||
"keyword": "Słowo kluczowe"
|
"keyword": "Słowo kluczowe",
|
||||||
|
"toot": "Wpisy"
|
||||||
},
|
},
|
||||||
"lists": {
|
"lists": {
|
||||||
"index": {
|
"index": {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<div class="search-result">
|
<div class="search-result">
|
||||||
<search-account v-if="target==='account'"></search-account>
|
<search-account v-if="target==='account'"></search-account>
|
||||||
<search-tag v-else-if="target==='tag'"></search-tag>
|
<search-tag v-else-if="target==='tag'"></search-tag>
|
||||||
|
<search-toots v-else-if="target==='toot'"></search-toots>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -25,10 +26,11 @@
|
|||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import SearchAccount from './Search/Account'
|
import SearchAccount from './Search/Account'
|
||||||
import SearchTag from './Search/Tag'
|
import SearchTag from './Search/Tag'
|
||||||
|
import SearchToots from './Search/Toots'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'search',
|
name: 'search',
|
||||||
components: { SearchAccount, SearchTag },
|
components: { SearchAccount, SearchTag, SearchToots },
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
target: 'account',
|
target: 'account',
|
||||||
@ -50,6 +52,10 @@ export default {
|
|||||||
{
|
{
|
||||||
target: 'tag',
|
target: 'tag',
|
||||||
label: this.$t('search.tag')
|
label: this.$t('search.tag')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'toot',
|
||||||
|
label: this.$t('search.toot')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -76,6 +82,15 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
break
|
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:
|
default:
|
||||||
break
|
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 Account from './Search/Account'
|
||||||
import Tag from './Search/Tag'
|
import Tag from './Search/Tag'
|
||||||
|
import Toots from './Search/Toots'
|
||||||
|
|
||||||
const Search = {
|
const Search = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
modules: { Account, Tag },
|
modules: { Account, Tag, Toots },
|
||||||
state: {
|
state: {
|
||||||
loading: false
|
loading: false
|
||||||
},
|
},
|
||||||
|
32
src/renderer/store/TimelineSpace/Contents/Search/Toots.js
Normal file
32
src/renderer/store/TimelineSpace/Contents/Search/Toots.js
Normal file
@ -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…
x
Reference in New Issue
Block a user