Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server migration recent threads #54

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const threadsApi = {
unlock: threadId => $http2(`/api/threads/${threadId}/lock`, { data: { locked: false }, method: 'POST'}),
sticky: threadId => $http2(`/api/threads/${threadId}/sticky`, { data: { sticky: true}, method: 'POST'}),
unsticky: threadId => $http2(`/api/threads/${threadId}/sticky`, { data: { sticky: false }, method: 'POST'}),
recent: () => $http2('/api/threads/recent'),
byBoard: params => $http2('/api/threads', { params }),
postedIn: params => $http('/api/threads/posted', { params }),
slugToThreadId: slug => $http2(`/api/threads/${slug}/id`),
Expand Down
4 changes: 2 additions & 2 deletions src/components/threads/RecentThreads.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</div>
</div>
<div class="title">
<router-link :class="{bold: thread.latest}" class="thread-title" :title="decode(thread.title)" :to="{ name: 'Posts', params: { threadSlug: thread.slug } }" onclick="event.stopPropagation()">{{decode(thread.title)}}</router-link>
<router-link :class="{bold: thread.latest}" class="thread-title" :title="decode(thread.title)" :to="{ name: 'Posts', params: { threadSlug: thread.slug }, query: (thread.post.position && thread.post.position > 1 ? { start: thread.post.position } : undefined) }" onclick="event.stopPropagation()">{{decode(thread.title)}}</router-link>
</div>
<div class="user">
in
Expand All @@ -69,7 +69,7 @@ import decode from '@/composables/filters/decode'

export default {
props: ['threads'],
setup() { return { humanDate, decode }}
setup() { return { humanDate, decode } }
}
</script>

Expand Down
10 changes: 9 additions & 1 deletion src/composables/utils/boardUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { localStoragePrefs } from '@/composables/stores/prefs'
import { threadsApi } from '@/api'

const buildLastPostData = data => {
return {
Expand Down Expand Up @@ -70,7 +71,14 @@ export const processBoards = data => {
return Object.assign(board, lastPost)
})
})
return data

// query recent threads and append to board data so no delay
// in recent thread component loading
return threadsApi.recent()
.then(recent => {
data.threads = recent
return data
}).catch(() => data)
}

export const processThreads = data => {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Boards.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="main">
<recent-threads v-if="boardData && boardData.data" :threads="boardData.data.threads"></recent-threads>
<recent-threads v-if="boardData && boardData.data && boardData.data.threads" :threads="boardData.data.threads"></recent-threads>

<div v-if="!loggedIn" class="dashboard-actions">
<a href="" class="button" @click.prevent="showRegister = true">Create an Account</a>
Expand Down