Support for searching local posts/users only
This commit is contained in:
parent
8398670530
commit
c578846b98
8 changed files with 43 additions and 15 deletions
|
@ -283,6 +283,7 @@ const getNodeInfo = async ({ store }) => {
|
|||
store.dispatch('setInstanceOption', { name: 'translationEnabled', value: features.includes('akkoma:machine_translation') })
|
||||
store.dispatch('setInstanceOption', { name: 'searchTypeMediaEnabled', value: features.includes('bnakkoma:search_type_media') })
|
||||
store.dispatch('setInstanceOption', { name: 'searchOptionFollowingEnabled', value: features.includes('bnakkoma:search_option_following') })
|
||||
store.dispatch('setInstanceOption', { name: 'searchOptionLocalEnabled', value: features.includes('bnakkoma:search_option_local') })
|
||||
store.dispatch('setInstanceOption', { name: 'opensearchProtocolSupported', value: features.includes('bnakkoma:opensearch_protocol') })
|
||||
|
||||
const uploadLimits = metadata.uploadLimits
|
||||
|
|
|
@ -68,16 +68,9 @@ const Search = {
|
|||
allStatusesObject[status.id] && !allStatusesObject[status.id].deleted
|
||||
)
|
||||
},
|
||||
isLoggedIn () {
|
||||
return !!this.$store.state.users.currentUser
|
||||
},
|
||||
canSearchMediaPosts () {
|
||||
return this.$store.state.instance.searchTypeMediaEnabled === true
|
||||
},
|
||||
canSearchFollowing () {
|
||||
return this.isLoggedIn &&
|
||||
this.$store.state.instance.searchOptionFollowingEnabled === true
|
||||
},
|
||||
hasAtLeastOneResult () {
|
||||
return allSearchTypes
|
||||
.some((searchType) => this.getVisibleLength(searchType) > 0)
|
||||
|
@ -165,7 +158,8 @@ const Search = {
|
|||
offset: searchOffset,
|
||||
'type': searchType,
|
||||
following:
|
||||
'followingOnly' in this.filter && this.filter.followingOnly
|
||||
'followingOnly' in this.filter && this.filter.followingOnly,
|
||||
local: 'localOnly' in this.filter && this.filter.localOnly
|
||||
})
|
||||
|
||||
// Always append to old results. If new results are empty, this doesn't change anything
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
{{ $t('nav.search') }}
|
||||
</div>
|
||||
<SearchFilters
|
||||
v-show="canSearchFollowing"
|
||||
v-model="filter"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<Popover
|
||||
v-if="showFilters"
|
||||
trigger="click"
|
||||
class="SearchFilters"
|
||||
placement="bottom"
|
||||
|
@ -8,6 +9,7 @@
|
|||
<template #content>
|
||||
<div class="dropdown-menu">
|
||||
<button
|
||||
v-if="canSearchFollowing"
|
||||
class="button-default dropdown-item"
|
||||
@click="toggleFilter('followingOnly')"
|
||||
>
|
||||
|
@ -16,6 +18,16 @@
|
|||
:class="{ 'menu-checkbox-checked': currentFilter.followingOnly }"
|
||||
/>{{ $t('lists.following_only') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canSearchLocal"
|
||||
class="button-default dropdown-item"
|
||||
@click="toggleFilter('localOnly')"
|
||||
>
|
||||
<span
|
||||
class="menu-checkbox"
|
||||
:class="{ 'menu-checkbox-checked': currentFilter.localOnly }"
|
||||
/>{{ $t('search.local_only') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<template #trigger>
|
||||
|
@ -46,10 +58,26 @@ export default {
|
|||
data () {
|
||||
return {
|
||||
currentFilter: {
|
||||
followingOnly: false
|
||||
followingOnly: false,
|
||||
localOnly: false
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
showFilters () {
|
||||
return this.canSearchFollowing || this.canSearchLocal
|
||||
},
|
||||
isLoggedIn () {
|
||||
return !!this.$store.state.users.currentUser
|
||||
},
|
||||
canSearchFollowing () {
|
||||
return this.isLoggedIn &&
|
||||
this.$store.state.instance.searchOptionFollowingEnabled
|
||||
},
|
||||
canSearchLocal () {
|
||||
return this.$store.state.instance.searchOptionLocalEnabled
|
||||
},
|
||||
},
|
||||
created () {
|
||||
for (const filterName of Object.entries(this.currentFilter)) {
|
||||
if (this.modelValue && filterName in this.modelValue) {
|
||||
|
|
|
@ -450,7 +450,8 @@
|
|||
"people_talking": "{count} people talking",
|
||||
"person_talking": "{count} person talking",
|
||||
"no_more_results": "No more results",
|
||||
"load_more": "Load more results"
|
||||
"load_more": "Load more results",
|
||||
"local_only": "Limit to Local"
|
||||
},
|
||||
"selectable_list": {
|
||||
"select_all": "Select all"
|
||||
|
|
|
@ -449,7 +449,8 @@
|
|||
"people_talking": "{count}人が話しています",
|
||||
"person_talking": "{count}人が話しています",
|
||||
"no_more_results": "すべて表示しました",
|
||||
"load_more": "さらに表示"
|
||||
"load_more": "さらに表示",
|
||||
"local_only": "ローカルのユーザーのみ"
|
||||
},
|
||||
"selectable_list": {
|
||||
"select_all": "すべて選択"
|
||||
|
|
|
@ -766,8 +766,8 @@ const statuses = {
|
|||
rootState.api.backendInteractor.fetchRebloggedByUsers({ id })
|
||||
.then(rebloggedByUsers => commit('addRepeats', { id, rebloggedByUsers, currentUser: rootState.users.currentUser }))
|
||||
},
|
||||
search ({ rootState, dispatch }, { q, resolve, limit, offset, following, type }) {
|
||||
return rootState.api.backendInteractor.search2({ q, resolve, limit, offset, following, type })
|
||||
search ({ rootState, dispatch }, { q, resolve, limit, offset, following, local, type }) {
|
||||
return rootState.api.backendInteractor.search2({ q, resolve, limit, offset, following, local, type })
|
||||
.then((data) => {
|
||||
dispatch('addNewUsers', data.accounts)
|
||||
dispatch('addNewStatuses', { statuses: data.statuses })
|
||||
|
|
|
@ -1380,7 +1380,7 @@ const searchUsers = ({ credentials, query }) => {
|
|||
.then((data) => data.map(parseUser))
|
||||
}
|
||||
|
||||
const search2 = ({ credentials, q, resolve, limit, offset, following, type }) => {
|
||||
const search2 = ({ credentials, q, resolve, limit, offset, following, local, type }) => {
|
||||
let url = MASTODON_SEARCH_2
|
||||
let params = []
|
||||
|
||||
|
@ -1404,6 +1404,10 @@ const search2 = ({ credentials, q, resolve, limit, offset, following, type }) =>
|
|||
params.push(['following', true])
|
||||
}
|
||||
|
||||
if (local) {
|
||||
params.push(['local', true])
|
||||
}
|
||||
|
||||
if (type) {
|
||||
params.push(['type', type])
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue