From 18452435860d8c6a9a42840d15951c53a0b9a735 Mon Sep 17 00:00:00 2001 From: silverpill Date: Thu, 7 Jul 2022 20:13:55 +0000 Subject: [PATCH] Add tab bar to profile page --- src/api/common.ts | 2 +- src/api/posts.ts | 7 +++++- src/views/Profile.vue | 53 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/api/common.ts b/src/api/common.ts index 35471fe..c2b943b 100644 --- a/src/api/common.ts +++ b/src/api/common.ts @@ -12,7 +12,7 @@ export const fetcher = { interface RequestInfo extends RequestInit { authToken?: string | null; json?: any; - queryParams?: { [name: string]: string | number | undefined }; + queryParams?: { [name: string]: string | number | boolean | undefined }; } export async function http( diff --git a/src/api/posts.ts b/src/api/posts.ts index 95f691b..7213d72 100644 --- a/src/api/posts.ts +++ b/src/api/posts.ts @@ -117,10 +117,15 @@ export async function getTagTimeline( export async function getProfileTimeline( authToken: string | null, authorId: string, + excludeReplies?: boolean, maxId?: string, ): Promise { const url = `${BACKEND_URL}/api/v1/accounts/${authorId}/statuses` - const queryParams = { max_id: maxId, limit: PAGE_SIZE } + const queryParams = { + exclude_replies: excludeReplies, + max_id: maxId, + limit: PAGE_SIZE, + } const response = await http(url, { method: "GET", queryParams, diff --git a/src/views/Profile.vue b/src/views/Profile.vue index 91e34a5..800711b 100644 --- a/src/views/Profile.vue +++ b/src/views/Profile.vue @@ -138,8 +138,26 @@ +
+ + + +
@@ -228,6 +246,13 @@ export default class ProfileView extends Vue { this.posts = await getProfileTimeline( this.store.authToken, this.profile.id, + true, + ) + } else if (this.tabName === "posts-with-replies") { + this.posts = await getProfileTimeline( + this.store.authToken, + this.profile.id, + false, ) } else if (this.tabName === "followers" && this.isCurrentUser()) { this.followList = await getFollowers( @@ -419,7 +444,12 @@ export default class ProfileView extends Vue { if (!this.profile) { return } - const posts = await getProfileTimeline(this.store.authToken, this.profile.id, maxId) + const posts = await getProfileTimeline( + this.store.authToken, + this.profile.id, + this.tabName !== "posts-with-replies", + maxId, + ) this.posts.push(...posts) } @@ -611,6 +641,25 @@ $avatar-size: 170px; } } +.tab-bar { + align-items: center; + display: flex; + margin-bottom: $block-outer-padding; + + a { + border-radius: $block-border-radius; + padding: $block-inner-padding / 2; + text-align: center; + width: 50%; + + &.active { + background-color: $block-background-color; + font-weight: bold; + } + } +} + +/* profile-list-item */ .profile { margin-bottom: $block-outer-padding; }