Skip to content

Commit

Permalink
user-listをexpandするまでfetchしないように
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Dec 5, 2021
1 parent fa982f9 commit 7c1541f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/client/app/common/views/components/user-list.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<ui-container :body-togglable="true" :expanded="expanded">
<ui-container :body-togglable="true" @toggle="onToggle" :expanded="expanded">
<template #header><slot></slot></template>

<mk-error v-if="!fetching && !inited" @retry="init()"/>
Expand Down Expand Up @@ -56,6 +56,7 @@ export default Vue.extend({
data() {
return {
initialized: false,
fetching: true,
fetchingMoreUsers: false,
us: [],
Expand All @@ -65,11 +66,12 @@ export default Vue.extend({
},
created() {
this.init();
if (this.expanded) this.init();
},
methods: {
init() {
this.initialized = true;
this.fetching = true;
this.makePromise().then(x => {
if (Array.isArray(x)) {
Expand All @@ -94,6 +96,10 @@ export default Vue.extend({
}, e => {
this.fetchingMoreUsers = false;
});
},
onToggle(show: boolean) {
if (show && !this.initialized) this.init();
}
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/client/app/mobile/views/components/ui-container.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="ukygtjoj" :class="{ naked, inNakedDeckColumn, hideHeader: !showHeader }">
<header v-if="showHeader" @click="() => showBody = !showBody">
<header v-if="showHeader" @click="toggleContent(!showBody)">
<div class="title"><slot name="header"></slot></div>
<slot name="func"></slot>
<button v-if="bodyTogglable">
Expand Down Expand Up @@ -49,6 +49,7 @@ export default Vue.extend({
toggleContent(show: boolean) {
if (!this.bodyTogglable) return;
this.showBody = show;
this.$emit('toggle', show);
}
}
});
Expand Down

0 comments on commit 7c1541f

Please sign in to comment.