Skip to content
Open
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
9 changes: 5 additions & 4 deletions wsd-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wsd-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"js-cookie": "^3.0.5",
"jsdom": "^26.0.0",
"lodash": "^4.17.21",
"lucide-react": "^0.436.0",
"lucide-react": "^0.448.0",
"marked": "^15.0.7",
"next": "15.3.0",
"next-pwa": "^5.6.0",
Expand Down
8 changes: 8 additions & 0 deletions wsd-frontend/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ export class WSDAPI {
return await this.client.DELETE('/v0/posts/{id}/', { params: { path: { id } } })
}

public async hidePost(id: string) {
return await this.client.POST('/v0/posts/{id}/hide/', { params: { path: { id } } })
}

public async unHidePost(id: string) {
return await this.client.POST('/v0/posts/{id}/unhide/', { params: { path: { id } } })
}

public async upvotePost(id: string) {
return await this.client.POST('/v0/posts/{id}/upvote/', { params: { path: { id } } })
}
Expand Down
114 changes: 114 additions & 0 deletions wsd-frontend/src/api/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,26 @@ export interface paths {
patch?: never
trace?: never
}
'/v0/posts/{id}/hide/': {
parameters: {
query?: never
header?: never
path?: never
cookie?: never
}
get?: never
put?: never
/**
* Hide Post
* @description Mark a post as hidden. Only the post creator or superusers can hide posts.
*/
post: operations['posts_hide_create']
delete?: never
options?: never
head?: never
patch?: never
trace?: never
}
'/v0/posts/{id}/unbookmark/': {
parameters: {
query?: never
Expand All @@ -376,6 +396,26 @@ export interface paths {
patch?: never
trace?: never
}
'/v0/posts/{id}/unhide/': {
parameters: {
query?: never
header?: never
path?: never
cookie?: never
}
get?: never
put?: never
/**
* Unhide Post
* @description Mark a removed post as not hidden. Only superusers can unhide posts.
*/
post: operations['posts_unhide_create']
delete?: never
options?: never
head?: never
patch?: never
trace?: never
}
'/v0/posts/{id}/unvote/': {
parameters: {
query?: never
Expand Down Expand Up @@ -907,6 +947,8 @@ export interface components {
readonly positive_vote_count: number | null
readonly negative_vote_count: number | null
readonly comment_count: number | null
/** @description Whether this post has been hidden. */
readonly is_hidden: boolean
}
/** @description Serializes the nested field, doesn't turn the serializer into read-only automatically(should it?) but it is
* read only.
Expand Down Expand Up @@ -1090,6 +1132,7 @@ export interface components {
readonly positive_vote_count: string[]
readonly negative_vote_count: string[]
readonly comment_count: string[]
readonly is_hidden: string[]
readonly non_field_errors: string[]
}
/** @description Serializes the nested field, doesn't turn the serializer into read-only automatically(should it?) but it is
Expand Down Expand Up @@ -2212,6 +2255,7 @@ export interface operations {
created_at__lt?: string
created_at__lte?: string
include?: 'category' | 'tags' | 'tags,category' | 'tags,user' | 'tags,user,category' | 'user' | 'user,category'
is_hidden?: boolean
is_nsfw?: boolean
is_original?: boolean
is_repost?: boolean
Expand Down Expand Up @@ -2475,6 +2519,41 @@ export interface operations {
}
}
}
posts_hide_create: {
parameters: {
query?: never
header?: never
path: {
/** @description A UUID string identifying this Post. */
id: string
}
cookie?: never
}
requestBody?: never
responses: {
/** @description No response body */
204: {
headers: {
[name: string]: unknown
}
content?: never
}
/** @description No response body */
401: {
headers: {
[name: string]: unknown
}
content?: never
}
/** @description No response body */
403: {
headers: {
[name: string]: unknown
}
content?: never
}
}
}
posts_unbookmark_create: {
parameters: {
query?: never
Expand Down Expand Up @@ -2503,6 +2582,41 @@ export interface operations {
}
}
}
posts_unhide_create: {
parameters: {
query?: never
header?: never
path: {
/** @description A UUID string identifying this Post. */
id: string
}
cookie?: never
}
requestBody?: never
responses: {
/** @description No response body */
204: {
headers: {
[name: string]: unknown
}
content?: never
}
/** @description No response body */
401: {
headers: {
[name: string]: unknown
}
content?: never
}
/** @description No response body */
403: {
headers: {
[name: string]: unknown
}
content?: never
}
}
}
posts_unvote_create: {
parameters: {
query?: never
Expand Down
68 changes: 68 additions & 0 deletions wsd-frontend/src/api/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,10 @@ paths:
- user,category
explode: false
style: form
- in: query
name: is_hidden
schema:
type: boolean
- in: query
name: is_nsfw
schema:
Expand Down Expand Up @@ -1415,6 +1419,33 @@ paths:
description: No response body
'401':
description: No response body
/v0/posts/{id}/hide/:
post:
operationId: posts_hide_create
description: Mark a post as hidden. Only the post creator or superusers can
hide posts.
summary: Hide Post
parameters:
- in: path
name: id
schema:
type: string
format: uuid
description: A UUID string identifying this Post.
required: true
tags:
- posts
security:
- tokenAuth: []
- basicAuth: []
- cookieAuth: []
responses:
'204':
description: No response body
'401':
description: No response body
'403':
description: No response body
/v0/posts/{id}/unbookmark/:
post:
operationId: posts_unbookmark_create
Expand All @@ -1439,6 +1470,32 @@ paths:
description: No response body
'401':
description: No response body
/v0/posts/{id}/unhide/:
post:
operationId: posts_unhide_create
description: Mark a removed post as not hidden. Only superusers can unhide posts.
summary: Unhide Post
parameters:
- in: path
name: id
schema:
type: string
format: uuid
description: A UUID string identifying this Post.
required: true
tags:
- posts
security:
- tokenAuth: []
- basicAuth: []
- cookieAuth: []
responses:
'204':
description: No response body
'401':
description: No response body
'403':
description: No response body
/v0/posts/{id}/unvote/:
post:
operationId: posts_unvote_create
Expand Down Expand Up @@ -2397,13 +2454,18 @@ components:
type: integer
readOnly: true
nullable: true
is_hidden:
type: boolean
readOnly: true
description: Whether this post has been hidden.
required:
- bookmarked
- comment_count
- created_at
- id
- image
- initial
- is_hidden
- is_repost
- negative_vote_count
- positive_vote_count
Expand Down Expand Up @@ -2788,6 +2850,11 @@ components:
items:
type: string
readOnly: true
is_hidden:
type: array
items:
type: string
readOnly: true
non_field_errors:
type: array
items:
Expand All @@ -2801,6 +2868,7 @@ components:
- id
- image
- initial
- is_hidden
- is_nsfw
- is_original
- is_repost
Expand Down
12 changes: 10 additions & 2 deletions wsd-frontend/src/app/(app)/posts/[hex]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export default async function PostPage(props: {
const searchParams = await props.searchParams
const params = await props.params
const wsd = getWSDAPI()
const isAuthenticated = await wsd.isAuthenticated()
const currentUser = await wsd.getCurrentUser()
const isAuthenticated = !_.isUndefined(currentUser)
const postId = suppress<string, undefined>([InvalidHEXError], () => hexToUUIDv4(params.hex))

const orderingLabels = {
Expand Down Expand Up @@ -77,7 +78,14 @@ export default async function PostPage(props: {
return (
<div className="flex flex-col gap-2 items-center lg:w-5/6 w-full">
<div className="w-full min-h-[130vh]">
<Meme post={post_} withRepostData withTags fullScreen isAuthenticated={isAuthenticated} />
<Meme
post={post_}
withRepostData
withTags
fullScreen
isAuthenticated={isAuthenticated}
currentUser={currentUser}
/>
<Separator className="max-sm:w-[calc(100%-8px)] w-full max-w-full" />
{wsd.hasResults(comments) && (
<Overlay breakpoint="md">
Expand Down
6 changes: 5 additions & 1 deletion wsd-frontend/src/app/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import _ from 'lodash'

import BackToTopButton from '@/components/wsd/BackToTopButton/client'
import Memes from '@/components/wsd/Memes'

Expand All @@ -8,7 +10,8 @@ import { getWSDAPI } from '@/lib/serverHooks'
export default async function Home(props: { searchParams?: Promise<APIQuery<'/v0/posts/'>> }) {
const searchParams = await props.searchParams
const wsd = getWSDAPI()
const isAuthenticated = await wsd.isAuthenticated()
const currentUser = await wsd.getCurrentUser()
const isAuthenticated = !_.isUndefined(currentUser)
const postQuery = {
...searchParams,
page_size: config.ux.defaultPostPerPage,
Expand All @@ -23,6 +26,7 @@ export default async function Home(props: { searchParams?: Promise<APIQuery<'/v0
initialPosts={data?.results || []}
hasMorePages={Boolean(data?.total_pages && data.total_pages > 1)}
isAuthenticated={isAuthenticated}
currentUser={currentUser}
/>
<BackToTopButton />
</>
Expand Down
Loading