Show error message if searching is not available

This commit is contained in:
Aya Morisawa 2018-07-19 08:24:03 +09:00
parent 7e27e2757f
commit e03ec67b5c
2 changed files with 28 additions and 6 deletions

View file

@ -6,6 +6,7 @@
<div :class="$style.loading" v-if="fetching">
<mk-ellipsis-icon/>
</div>
<p :class="$style.notAvailable" v-if="!fetching && notAvailable">検索機能を利用することができません</p>
<p :class="$style.empty" v-if="!fetching && empty">%fa:search%{{ q }}に関する投稿は見つかりませんでした</p>
<mk-notes ref="timeline" :class="$style.notes" :more="existMore ? more : null"/>
</mk-ui>
@ -24,7 +25,8 @@ export default Vue.extend({
moreFetching: false,
existMore: false,
offset: 0,
empty: false
empty: false,
notAvailable: false
};
},
watch: {
@ -71,7 +73,11 @@ export default Vue.extend({
res(notes);
this.fetching = false;
Progress.done();
}, rej);
}, (e: string) => {
this.fetching = false;
Progress.done();
if (e === 'searching not available') this.notAvailable = true;
});
}));
},
more() {
@ -130,4 +136,18 @@ export default Vue.extend({
font-size 3em
color #ccc
.notAvailable
display block
margin 0 auto
padding 32px
max-width 400px
text-align center
color #999
> [data-fa]
display block
margin-bottom 16px
font-size 3em
color #ccc
</style>

View file

@ -18,6 +18,8 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
const [limit = 10, limitErr] = $.num.optional.range(1, 30).get(params.limit);
if (limitErr) return rej('invalid limit param');
if (es == null) return rej('searching not available');
es.search({
index: 'misskey',
type: 'note',