Skip to content

Commit

Permalink
ページング扱いの時は自動読み込みしない
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Apr 30, 2019
1 parent f7082ee commit cfff940
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion locales/en-US.yml
Expand Up @@ -24,7 +24,8 @@ common:
application-authorization: "Application authorizations"
close: "Close"
do-not-copy-paste: "Please do not enter or paste the code here. Account may be compromised."
go-first: "Go first page"
newest: "Newest"
next-page: "Next page"
load-more: "Read more"
enter-password: "Enter your password"
2fa: "Two-factor authentication"
Expand Down
3 changes: 2 additions & 1 deletion locales/ja-JP.yml
Expand Up @@ -25,7 +25,8 @@ common:
application-authorization: "アプリの連携"
close: "閉じる"
do-not-copy-paste: "ここにコードを入力したり張り付けたりしないでください。アカウントが不正利用される可能性があります。"
go-first: "最初のページへ"
newest: "最新"
next-page: "次のページ"
load-more: "もっと読み込む"
enter-password: "パスワードを入力してください"
2fa: "二段階認証"
Expand Down
16 changes: 11 additions & 5 deletions src/client/app/mobile/views/components/notes.vue
Expand Up @@ -11,7 +11,7 @@
</div>

<header v-if="paged">
<button @click="reload">{{ $t('@.go-first') }}</button>
<button @click="reload">{{ $t('@.newest') }}</button>
</header>

<!-- トランジションを有効にするとなぜかメモリリークする -->
Expand All @@ -27,8 +27,9 @@

<footer v-if="cursor != null">
<button @click="more" :disabled="moreFetching" :style="{ cursor: moreFetching ? 'wait' : 'pointer' }">
<template v-if="!moreFetching">{{ $t('@.load-more') }}</template>
<template v-if="moreFetching"><fa icon="spinner" pulse fixed-width/></template>
<template v-else-if="hasNextPage">{{ $t('@.next-page') }}</template>
<template v-else>{{ $t('@.load-more') }}</template>
</button>
</footer>
</div>
Expand Down Expand Up @@ -71,7 +72,11 @@ export default Vue.extend({
note._datetext = this.$t('@.month-and-day').replace('{month}', month.toString()).replace('{day}', date.toString());
return note;
});
}
},
hasNextPage(): boolean {
return this.cursor != null && this.notes.length >= displayLimit * 2;
},
},
watch: {
Expand Down Expand Up @@ -134,7 +139,7 @@ export default Vue.extend({
this.moreFetching = true;
this.makePromise(this.cursor).then(x => {
// 改ページ
if (this.notes.length >= displayLimit * 2) {
if (this.hasNextPage) {
this.paged = true;
this.notes = x.notes;
this.queue = [];
Expand Down Expand Up @@ -190,13 +195,14 @@ export default Vue.extend({
}
if (this.$store.state.settings.fetchOnScroll !== false) {
if (this.hasNextPage) return;
// 親要素が display none だったら弾く
// https://github.com/syuilo/misskey/issues/1569
// http://d.hatena.ne.jp/favril/20091105/1257403319
if (this.$el.offsetHeight == 0) return;
const current = window.scrollY + window.innerHeight;
if (current > document.body.offsetHeight - 32) this.more();
if (current > document.body.offsetHeight - 8) this.more();
}
}
}
Expand Down

0 comments on commit cfff940

Please sign in to comment.