Skip to content

Commit 0c9cf67

Browse files
committed
feat: use normal pagination in mobile view threads posted in
1 parent bf7bc65 commit 0c9cf67

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

src/views/ThreadsPostedIn.vue

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,33 @@
6464
</tbody>
6565
</table>
6666
</div>
67-
<div class="sidebar">
67+
<div class="sidebar" v-if="threadData?.count > threadData?.limit">
6868
<div class="sidebar-block" v-if="threadData?.threads">
6969
<pagination :page="threadData.page" :limit="threadData.limit" :count="threadData.count"></pagination>
7070
</div>
71+
<div class="pagination-wrap">
72+
<simple-pagination
73+
v-model="currentPage"
74+
:pages="pages"
75+
:range-size="1"
76+
@update:modelValue="pageResults"
77+
/>
78+
</div>
7179
</div>
7280
</template>
7381

7482
<script>
7583
import Pagination from '@/components/layout/Pagination.vue'
7684
import humanDate from '@/composables/filters/humanDate'
77-
import { reactive, toRefs } from 'vue'
85+
import { reactive, computed, toRefs } from 'vue'
86+
import { useRouter, useRoute } from 'vue-router'
7887
import { threadsApi } from '@/api'
7988
import { localStoragePrefs } from '@/composables/stores/prefs'
89+
import SimplePagination from '@/components/layout/SimplePagination.vue'
8090
8191
export default {
8292
name: 'ThreadsPostedIn',
83-
components: { Pagination },
93+
components: { Pagination, SimplePagination },
8494
beforeRouteEnter(to, from, next) {
8595
const params = {
8696
limit: localStoragePrefs().data.threads_per_page,
@@ -96,13 +106,26 @@ export default {
96106
threadsApi.postedIn(params).then(data => this.threadData = data )
97107
},
98108
setup() {
109+
const pageResults = page => {
110+
console.log(page)
111+
let query = { ...$route.query, page: page }
112+
if (query.page === 1 || !query.page) delete query.page
113+
if ($route.query.page !== v.currentPage)
114+
$router.replace({ name: $route.name, params: $route.params, query: query })
115+
}
116+
117+
const $route = useRoute()
118+
const $router = useRouter()
119+
99120
/* View Data */
100121
const v = reactive({
122+
currentPage: Number($route.query.page) || 1,
123+
pages: computed(() => Math.ceil(v.threadData?.count / v.threadData?.limit)),
101124
defaultAvatar: window.default_avatar,
102125
defaultAvatarShape: window.default_avatar_shape,
103126
threadData: null
104127
})
105-
return { ...toRefs(v), humanDate }
128+
return { ...toRefs(v), pageResults, humanDate }
106129
}
107130
}
108131
</script>
@@ -117,5 +140,20 @@ export default {
117140
position: sticky;
118141
top: $header-offset;
119142
}
143+
.pagination-wrap { display: none; }
144+
@include break-mobile-sm {
145+
border-top: 1px solid $border-color;
146+
position: fixed;
147+
bottom: 0;
148+
right: 0;
149+
left: 0;
150+
background: $base-background-color;
151+
padding: 0.75rem;
152+
z-index: 1000;
153+
margin: 0 auto;
154+
width: 100vw;
155+
.sidebar-block { display: none; }
156+
.pagination-wrap { display: block; }
157+
}
120158
}
121159
</style>

0 commit comments

Comments
 (0)