Compare commits

..

No commits in common. "b9190e58f851aa1c3b31b3883427a54e80b0bad7" and "80d5555804c5e682e3abebc21effa57d6f95be7c" have entirely different histories.

5 changed files with 32 additions and 128 deletions

View file

@ -1,7 +1,6 @@
RUNTIME ?= docker RUNTIME ?= docker
BUILD_DIR ?= ./dist/ BUILD_DIR ?= ./dist/
OUTFILE_ZIP ?= ./akkoma-fe.zip OUTFILE_ZIP ?= ./akkoma-fe.zip
NODE_ENV ?= production
.PHONY: all .PHONY: all
all: build-docker build-fe package all: build-docker build-fe package
@ -18,7 +17,7 @@ else
rm -rf $(BUILD_DIR) rm -rf $(BUILD_DIR)
mkdir $(BUILD_DIR) mkdir $(BUILD_DIR)
endif endif
$(RUNTIME) run -e NODE_ENV=$(NODE_ENV) -v ${PWD}/dist/:/app/dist/:Z akkoma-fe-builder build $(RUNTIME) run -v ${PWD}/dist/:/app/dist/:Z akkoma-fe-builder build
.PHONY: package .PHONY: package
package: package:

View file

@ -27,20 +27,16 @@ const Search = {
], ],
data () { data () {
return { return {
loadedInitially: false, loaded: false,
loading: false, loading: false,
searchTerm: this.query || '', searchTerm: this.query || '',
mediaSearchSupported: false,
userIds: [], userIds: [],
statuses: [], statuses: [],
media: [],
hashtags: [], hashtags: [],
currenResultTab: 'statuses', currenResultTab: 'statuses',
statusesOffset: 0, statusesOffset: 0,
lastStatusFetchCount: 0, lastStatusFetchCount: 0,
mediaOffset: 0,
lastMediaFetchCount: 0,
lastQuery: '' lastQuery: ''
} }
}, },
@ -54,13 +50,6 @@ const Search = {
return this.statuses.filter(status => return this.statuses.filter(status =>
allStatusesObject[status.id] && !allStatusesObject[status.id].deleted allStatusesObject[status.id] && !allStatusesObject[status.id].deleted
) )
},
visibleMedia () {
const allStatusesObject = this.$store.state.statuses.allStatusesObject
return this.media.filter(status =>
allStatusesObject[status.id] && !allStatusesObject[status.id].deleted
)
} }
}, },
mounted () { mounted () {
@ -83,92 +72,61 @@ const Search = {
return return
} }
const isNewSearch = this.lastQuery !== query
this.loading = true this.loading = true
this.$refs.searchInput.blur() this.$refs.searchInput.blur()
if (isNewSearch) { if (this.lastQuery !== query) {
this.userIds = [] this.userIds = []
this.hashtags = [] this.hashtags = []
this.statuses = [] this.statuses = []
this.media = []
this.statusesOffset = 0 this.statusesOffset = 0
this.lastStatusFetchCount = 0 this.lastStatusFetchCount = 0
this.mediaOffset = 0
this.lastMediaFetchCount = 0
} }
let searchOffset this.$store.dispatch('search', { q: query, resolve: true, offset: this.statusesOffset, 'type': searchType })
if (searchType === 'statuses') {
searchOffset = this.statusesOffset
} else if (searchType === 'media') {
searchOffset = this.mediaOffset
}
this.$store.dispatch('search', {
q: query,
resolve: true,
offset: searchOffset,
'type': searchType,
})
.then(data => { .then(data => {
this.loading = false this.loading = false
let oldStasusesLength = this.statuses.length let oldLength = this.statuses.length
let oldMediaLength = this.media.length
// Always append to old results. If new results are empty, this doesn't change anything // Always append to old results. If new results are empty, this doesn't change anything
this.userIds = this.userIds.concat(map(data.accounts, 'id')) this.userIds = this.userIds.concat(map(data.accounts, 'id'))
this.statuses = uniqBy(this.statuses.concat(data.statuses), 'id') this.statuses = uniqBy(this.statuses.concat(data.statuses), 'id')
if ('media' in data) {
this.mediaSearchSupported = true
this.media = uniqBy(this.media.concat(data.media), 'id')
}
this.hashtags = this.hashtags.concat(data.hashtags) this.hashtags = this.hashtags.concat(data.hashtags)
if (isNewSearch) { this.currenResultTab = this.getActiveTab()
this.currenResultTab = this.getActiveTab() this.loaded = true
}
this.loadedInitially = true
if (!searchType || searchType === 'statuses') { // Offset from whatever we already have
// Offset from whatever we already have this.statusesOffset = this.statuses.length
this.statusesOffset = this.statuses.length // Because the amount of new statuses can actually be zero, compare to old lenght instead
// Because the amount of new statuses can actually be zero, compare to old lenght instead this.lastStatusFetchCount = this.statuses.length - oldLength
this.lastStatusFetchCount = this.statuses.length - oldStasusesLength
}
if (!searchType || searchType === 'media') {
this.mediaOffset = this.media.length
this.lastMediaFetchCount = this.media.length - oldMediaLength
}
this.lastQuery = query this.lastQuery = query
}) })
}, },
resultCount (tabName) { resultCount (tabName) {
const length = this[tabName].length const length = this[tabName].length
return (
if (length === 0 || !this.loadedInitially) { length === 0
return '' ? ''
} : ` (${
length + (
if ( tabName === "visibleStatuses" &&
(tabName === 'visibleStatuses' && this.lastStatusFetchCount !== 0) || this.lastStatusFetchCount !== 0 &&
(tabName === 'visibleMedia' && this.lastMediaFetchCount !== 0) !this.loading &&
) { this.loaded
return ` (${length}+)` ? '+'
} : ''
)
return ` (${length})` })`
)
}, },
onResultTabSwitch (key) { onResultTabSwitch (key) {
this.currenResultTab = key this.currenResultTab = key
this.loading = false
}, },
getActiveTab () { getActiveTab () {
if (this.visibleStatuses.length > 0) { if (this.visibleStatuses.length > 0) {
return 'statuses' return 'statuses'
} else if (this.visibleMedia.length > 0) {
return 'media'
} else if (this.users.length > 0) { } else if (this.users.length > 0) {
return 'people' return 'people'
} else if (this.hashtags.length > 0) { } else if (this.hashtags.length > 0) {

View file

@ -24,13 +24,7 @@
</button> </button>
</div> </div>
<div <div
v-if=" v-if="loading && statusesOffset == 0"
loading &&
visibleStatuses.length === 0 &&
visibleMedia.length === 0 &&
users.length === 0 &&
hashtags.length === 0
"
class="text-center loading-icon" class="text-center loading-icon"
> >
<FAIcon <FAIcon
@ -39,7 +33,7 @@
size="lg" size="lg"
/> />
</div> </div>
<div v-else-if="loadedInitially"> <div v-else-if="loaded">
<div class="search-nav-heading"> <div class="search-nav-heading">
<tab-switcher <tab-switcher
ref="tabSwitcher" ref="tabSwitcher"
@ -50,11 +44,6 @@
key="statuses" key="statuses"
:label="$t('user_card.statuses') + resultCount('visibleStatuses')" :label="$t('user_card.statuses') + resultCount('visibleStatuses')"
/> />
<span
v-if="mediaSearchSupported"
key="media"
:label="$t('user_card.media') + resultCount('visibleMedia')"
/>
<span <span
key="people" key="people"
:label="$t('search.people') + resultCount('users')" :label="$t('search.people') + resultCount('users')"
@ -79,7 +68,7 @@
:no-heading="false" :no-heading="false"
/> />
<button <button
v-if="!loading && loadedInitially && lastStatusFetchCount > 0" v-if="!loading && loaded && lastStatusFetchCount > 0"
class="more-statuses-button button-unstyled -link -fullwidth" class="more-statuses-button button-unstyled -link -fullwidth"
@click.prevent="search(searchTerm, 'statuses')" @click.prevent="search(searchTerm, 'statuses')"
> >
@ -98,7 +87,7 @@
/> />
</div> </div>
<div <div
v-if="(visibleStatuses.length === 0 || lastStatusFetchCount === 0) && !loading && loadedInitially" v-if="(visibleStatuses.length === 0 || lastStatusFetchCount === 0) && !loading && loaded"
class="search-result-heading" class="search-result-heading"
> >
<h4> <h4>
@ -106,48 +95,9 @@
</h4> </h4>
</div> </div>
</div> </div>
<div v-if="currenResultTab === 'media'">
<Status
v-for="media in visibleMedia"
:key="media.id"
:collapsable="false"
:expandable="false"
:compact="false"
class="search-result"
:statusoid="media"
:no-heading="false"
/>
<button
v-if="!loading && loadedInitially && lastMediaFetchCount > 0"
class="more-statuses-button button-unstyled -link -fullwidth"
@click.prevent="search(searchTerm, 'media')"
>
<div class="new-status-notification text-center">
{{ $t('search.load_more') }}
</div>
</button>
<div
v-else-if="loading && mediaOffset > 0"
class="text-center loading-icon"
>
<FAIcon
icon="circle-notch"
spin
size="lg"
/>
</div>
<div
v-if="(visibleMedia.length === 0 || lastMediaFetchCount === 0) && !loading && loadedInitially"
class="search-result-heading"
>
<h4>
{{ visibleMedia.length === 0 ? $t('search.no_results') : $t('search.no_more_results') }}
</h4>
</div>
</div>
<div v-else-if="currenResultTab === 'people'"> <div v-else-if="currenResultTab === 'people'">
<div <div
v-if="users.length === 0 && !loading && loadedInitially" v-if="users.length === 0 && !loading && loaded"
class="search-result-heading" class="search-result-heading"
> >
<h4>{{ $t('search.no_results') }}</h4> <h4>{{ $t('search.no_results') }}</h4>
@ -161,7 +111,7 @@
</div> </div>
<div v-else-if="currenResultTab === 'hashtags'"> <div v-else-if="currenResultTab === 'hashtags'">
<div <div
v-if="hashtags.length === 0 && !loading && loadedInitially" v-if="hashtags.length === 0 && !loading && loaded"
class="search-result-heading" class="search-result-heading"
> >
<h4>{{ $t('search.no_results') }}</h4> <h4>{{ $t('search.no_results') }}</h4>

View file

@ -445,7 +445,7 @@
"search": { "search": {
"hashtags": "ハッシュタグ", "hashtags": "ハッシュタグ",
"no_results": "見つかりませんでした", "no_results": "見つかりませんでした",
"people": "ユーザー", "people": "人々",
"people_talking": "{count}人が話しています", "people_talking": "{count}人が話しています",
"person_talking": "{count}人が話しています", "person_talking": "{count}人が話しています",
"no_more_results": "すべて表示しました", "no_more_results": "すべて表示しました",

View file

@ -1424,9 +1424,6 @@ const search2 = ({ credentials, q, resolve, limit, offset, following, type }) =>
.then((data) => { .then((data) => {
data.accounts = data.accounts.slice(0, limit).map(u => parseUser(u)) data.accounts = data.accounts.slice(0, limit).map(u => parseUser(u))
data.statuses = data.statuses.slice(0, limit).map(s => parseStatus(s)) data.statuses = data.statuses.slice(0, limit).map(s => parseStatus(s))
if ('media' in data) {
data.media = data.media.slice(0, limit).map(s => parseStatus(s))
}
return data return data
}) })
} }