diff --git a/src/lib/client/base.ts b/src/lib/client/base.ts index 9eb089f0..0765354d 100644 --- a/src/lib/client/base.ts +++ b/src/lib/client/base.ts @@ -2,7 +2,7 @@ import type { ClientType } from './lemmy.svelte' import * as types from './types' export abstract class BaseClient { - static type: ClientType + abstract type: ClientType abstract getSite(): Promise abstract generateTotpSecret(): Promise diff --git a/src/lib/client/lemmy/lemmy.ts b/src/lib/client/lemmy/lemmy.ts index ad6ec6e5..c2dfcfe6 100644 --- a/src/lib/client/lemmy/lemmy.ts +++ b/src/lib/client/lemmy/lemmy.ts @@ -1,9 +1,10 @@ import { LemmyHttp } from 'lemmy-js-client' import type { BaseClient } from '../base' import { fromGetPosts, toListingType } from './rewrite' +import type { ClientType } from '../lemmy.svelte' export class LemmyClient implements BaseClient { - static type = { name: 'lemmy', baseUrl: '/api/v3' } + type: ClientType = { name: 'lemmy', baseUrl: '/api/v3' } #client: LemmyHttp diff --git a/src/lib/client/piefed/piefed.ts b/src/lib/client/piefed/piefed.ts index aa2f2dca..2aa10078 100644 --- a/src/lib/client/piefed/piefed.ts +++ b/src/lib/client/piefed/piefed.ts @@ -1,22 +1,32 @@ import createClient from 'openapi-fetch' import type { BaseClient } from '../base' import { + fromCreateComment, + fromCreatePost, fromGetComments, fromGetPost, fromGetPosts, + fromGetReplies, + fromListCommunities, + fromSearch, + toCommentReplyView, + toCommentSortType, toCommentView, toCommunity, toCommunityView, toLocalSite, toMyUser, toPerson, + toPersonMentionView, toPersonView, toPostView, + toPrivateMessageView, } from './rewrite' import type { paths } from './schema' +import type { ClientType } from '../lemmy.svelte' export class PiefedClient implements BaseClient { - static type = { name: 'piefed', baseUrl: '/api/alpha' } + type: ClientType = { name: 'piefed', baseUrl: '/api/alpha' } #client: ReturnType> @@ -36,7 +46,7 @@ export class PiefedClient implements BaseClient { } async getSite(): ReturnType { - // throw new Error('Unimplemented') + // throw new Error('unimplemented') const response = (await this.#client.GET('/site')).data! @@ -73,9 +83,17 @@ export class PiefedClient implements BaseClient { } async createPost( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.POST('/post', { + body: fromCreatePost(params), + }) + ).data! + + return { + post_view: toPostView(response.post_view), + } } async getPost( params: Parameters[0], @@ -97,20 +115,36 @@ export class PiefedClient implements BaseClient { post_view: toPostView(response.post_view), } } + async editPost( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = (await this.#client.PUT('/post', { body: params })).data! + + return { + post_view: toPostView(response.post_view), + } } async deletePost( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = (await this.#client.POST('/post/delete', { body: params })) + .data! + + return { + post_view: toPostView(response.post_view), + } } + async removePost( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = (await this.#client.POST('/post/remove', { body: params })) + .data! + + return { + post_view: toPostView(response.post_view), + } } async getPosts( @@ -137,95 +171,155 @@ export class PiefedClient implements BaseClient { })) as any } - async generateTotpSecret( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async generateTotpSecret(): ReturnType { + throw new Error('unsupported') } - async listLogins( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async listLogins(): ReturnType { + throw new Error('unsupported') } - async listAllMedia( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async listAllMedia(): ReturnType { + throw new Error('unsupported') } - async updateTotp( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async updateTotp(): ReturnType { + throw new Error('unsupported') } - async getModlog( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async getModlog(): ReturnType { + throw new Error('unsupported') } async search( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.GET('/search', { + params: { + // @ts-expect-error same here what is happening + query: fromSearch(params), + }, + }) + ).data! + + return { + comments: [], + communities: response.communities.map(toCommunityView), + posts: response.posts.map(toPostView), + users: response.users.map(toPersonView), + type_: response.type_, + } } async resolveObject( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.GET('/resolve_object', { + // @ts-expect-error same here what is happening + params: { query: params }, + }) + ).data! + + return { + comment: response.comment ? toCommentView(response.comment) : undefined, + community: response.community + ? toCommunityView(response.community) + : undefined, + post: response.post ? toPostView(response.post) : undefined, + person: response.person ? toPersonView(response.person) : undefined, + } } async createCommunity( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async getCommunity( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.GET('/community', { + params: { + // @ts-expect-error same here what is happening + query: params, + }, + }) + ).data! + + return { + ...response, + community_view: toCommunityView(response.community_view), + moderators: response.moderators.map(i => ({ + community: toCommunity(i.community), + moderator: toPerson(i.moderator), + })), + } } async editCommunity( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async listCommunities( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.GET('/community/list', { + params: { + // @ts-expect-error same here what is happening + query: fromListCommunities(params), + }, + }) + ).data! + + return { + communities: response.communities.map(toCommunityView), + } } async followCommunity( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.POST('/community/follow', { body: params }) + ).data! + + return { + ...response, + community_view: toCommunityView(response.community_view), + } } async blockCommunity( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.POST('/community/block', { body: params }) + ).data! + + return { + ...response, + community_view: toCommunityView(response.community_view), + } } async deleteCommunity( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async hideCommunity( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async removeCommunity( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async banFromCommunity( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async addModToCommunity( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async markPostAsRead( params: Parameters[0], @@ -240,95 +334,128 @@ export class PiefedClient implements BaseClient { async hidePost( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async lockPost( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async featurePost( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } - async listPostLikes( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async listPostLikes(): ReturnType { + throw new Error('unsupported') } async savePost( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = (await this.#client.PUT('/post/save', { body: params })) + .data! + + return { + post_view: toPostView(response.post_view), + } } async createPostReport( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async resolvePostReport( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async listPostReports( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async getSiteMetadata( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } + async createComment( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.POST('/comment', { + body: fromCreateComment(params), + }) + ).data! + + return { + ...response, + comment_view: toCommentView(response.comment_view), + recipient_ids: [], + } } async editComment( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = (await this.#client.PUT('/comment', { body: params })) + .data! + + return { + comment_view: toCommentView(response.comment_view), + recipient_ids: [], + } } async deleteComment( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.POST('/comment/delete', { body: params }) + ).data! + + return { + comment_view: toCommentView(response.comment_view), + recipient_ids: [], + } } async removeComment( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.POST('/comment/remove', { body: params }) + ).data! + + return { + comment_view: toCommentView(response.comment_view), + recipient_ids: [], + } } async markCommentReplyAsRead( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async likeComment( params: Parameters[0], ): ReturnType { // TODO remove any return (await this.#client.POST('/comment/like', { - body: { ...params }, + body: params, })) as any } - async listCommentLikes( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + + async listCommentLikes(): ReturnType { + throw new Error('unsupported') } async saveComment( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async distinguishComment( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async getComments( @@ -347,218 +474,244 @@ export class PiefedClient implements BaseClient { } async getComment( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = + // @ts-expect-error same here what is happening + (await this.#client.GET('/comment', { params: { query: params } })).data! + + return { + ...response, + comment_view: toCommentView(response.comment_view), + recipient_ids: [], + } } async createCommentReport( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async resolveCommentReport( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async listCommentReports( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async getPrivateMessages( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.GET('/private_message/list', { + // @ts-expect-error query params are screwed up + params: { query: params }, + }) + ).data! + + return { + private_messages: response.private_messages.map(toPrivateMessageView), + } } async createPrivateMessage( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async editPrivateMessage( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async deletePrivateMessage( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async markPrivateMessageAsRead( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async createPrivateMessageReport( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async resolvePrivateMessageReport( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async listPrivateMessageReports( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } - async register( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async register(): ReturnType { + throw new Error('unsupported') } async login( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = await this.#client.POST('/user/login', { + body: { username: params.username_or_email, password: params.password }, + })! + + return { + verify_email_sent: false, + registration_created: false, + jwt: response.data?.jwt, + } } async logout( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async getPersonDetails( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async getPersonMentions( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.GET('/user/mentions', { + // @ts-expect-error yet another query param bug + params: { query: { ...params, sort: toCommentSortType(params.sort) } }, + }) + ).data! + + return { + mentions: response.replies.map(toPersonMentionView), + } } async markPersonMentionAsRead( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async getReplies( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = ( + await this.#client.GET('/user/replies', { + // @ts-expect-error same here what is happening + params: { query: fromGetReplies(params) }, + }) + ).data! + + return { + replies: response.replies.map(toCommentReplyView), + } } - async banPerson( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async banPerson(): ReturnType { + // this is for site view not community view + throw new Error('unsupported') } - async getBannedPersons( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async getBannedPersons(): ReturnType { + // this is for site view not community view + throw new Error('unsupported') } async blockPerson( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + const response = (await this.#client.POST('/user/block', { body: params })) + .data! + + return { + ...response, + person_view: toPersonView(response.person_view), + } } - async getCaptcha( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async getCaptcha(): ReturnType { + throw new Error('unsupported') } - async deleteAccount( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async deleteAccount(): ReturnType { + throw new Error('unsupported') } - async passwordReset( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async passwordReset(): ReturnType { + throw new Error('unsupported') } - async passwordChangeAfterReset( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async passwordChangeAfterReset(): ReturnType< + BaseClient['passwordChangeAfterReset'] + > { + throw new Error('unsupported') } - async markAllAsRead( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async markAllAsRead(): ReturnType { + const response = (await this.#client.POST('/user/mark_all_as_read')).data! + + return { + replies: response.replies.map(toCommentReplyView), + } } async saveUserSettings( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + return ( + await this.#client.PUT('/user/save_user_settings', { body: params }) + ).data! } - async changePassword( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async changePassword(): ReturnType { + throw new Error('unsupported') } - async getReportCount( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async getReportCount(): ReturnType { + throw new Error('unsupported') } - async getUnreadCount( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async getUnreadCount(): ReturnType { + return (await this.#client.GET('/user/unread_count')).data! } - async verifyEmail( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async verifyEmail(): ReturnType { + throw new Error('unsupported') } - async addAdmin( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async addAdmin(): ReturnType { + throw new Error('unsupported') } - async getUnreadRegistrationApplicationCount( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async getUnreadRegistrationApplicationCount(): ReturnType< + BaseClient['getUnreadRegistrationApplicationCount'] + > { + throw new Error('unsupported') } - async listRegistrationApplications( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async listRegistrationApplications(): ReturnType< + BaseClient['listRegistrationApplications'] + > { + throw new Error('unsupported') } - async approveRegistrationApplication( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async approveRegistrationApplication(): ReturnType< + BaseClient['approveRegistrationApplication'] + > { + throw new Error('unsupported') } - async getRegistrationApplication( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async getRegistrationApplication(): ReturnType< + BaseClient['getRegistrationApplication'] + > { + throw new Error('unsupported') } - async purgePerson( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async purgePerson(): ReturnType { + throw new Error('unsupported') } - async purgeCommunity( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async purgeCommunity(): ReturnType { + throw new Error('unsupported') } - async purgePost( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async purgePost(): ReturnType { + throw new Error('unsupported') } - async purgeComment( - ...params: Parameters - ): ReturnType { - throw new Error('Unimplemented') + async purgeComment(): ReturnType { + throw new Error('unsupported') } async getFederatedInstances( ...params: Parameters ): ReturnType { - throw new Error('Unimplemented') + throw new Error('unimplemented') } async blockInstance( - ...params: Parameters + params: Parameters[0], ): ReturnType { - throw new Error('Unimplemented') + return (await this.#client.POST('/site/block', { body: { ...params } }))! + .data! } } diff --git a/src/lib/client/piefed/rewrite.ts b/src/lib/client/piefed/rewrite.ts index 312d7f0b..769ca84c 100644 --- a/src/lib/client/piefed/rewrite.ts +++ b/src/lib/client/piefed/rewrite.ts @@ -1,21 +1,29 @@ import type { Comment, + CommentReplyView, CommentSortType, CommentView, Community, CommunityView, + CreateComment, + CreatePost, GetComments, GetPost, GetPosts, + GetReplies, + ListCommunities, LocalSite, MyUserInfo, Person, + PersonMentionView, PersonView, Post, PostView, + PrivateMessageView, + Search, SortType, } from '../types' -import type { components, paths } from './schema' +import type { components } from './schema' export function toPersonView( personView: components['schemas']['PersonView'], @@ -156,6 +164,47 @@ export function toComment(comment: components['schemas']['Comment']): Comment { } } +export function toCommentReplyView( + commentReplyView: components['schemas']['CommentReplyView'], +): CommentReplyView { + return { + ...commentReplyView, + banned_from_community: false, + creator_banned_from_community: false, + comment: toComment(commentReplyView.comment), + creator: toPerson(commentReplyView.creator), + post: toPost(commentReplyView.post), + community: toCommunity(commentReplyView.community), + recipient: toPerson(commentReplyView.recipient), + } +} + +export function toPrivateMessageView( + privateMessageView: components['schemas']['PrivateMessageView'], +): PrivateMessageView { + return { + ...privateMessageView, + creator: toPerson(privateMessageView.creator), + recipient: toPerson(privateMessageView.recipient), + } +} + +export function toPersonMentionView( + personMentionView: components['schemas']['CommentReplyView'], +): PersonMentionView { + return { + ...personMentionView, + person_mention: personMentionView.comment_reply, + creator_banned_from_community: false, + banned_from_community: false, + comment: toComment(personMentionView.comment), + community: toCommunity(personMentionView.community), + post: toPost(personMentionView.post), + creator: toPerson(personMentionView.creator), + recipient: toPerson(personMentionView.recipient), + } +} + // Query calls export function fromGetPosts( getPosts: GetPosts, @@ -179,10 +228,55 @@ export function fromGetComments( export function fromGetPost( getPost: GetPost, ): components['schemas']['GetPost'] { - console.log(getPost) return getPost } +export function fromGetReplies( + getReplies: GetReplies, +): components['schemas']['GetReplies'] { + return { + ...getReplies, + sort: toCommentSortType(getReplies.sort), + } +} + +export function fromSearch(search: Search): components['schemas']['Search'] { + return { + ...(search as Omit & { + type_: 'Communities' | 'Users' | 'Url' | 'Posts' + }), + sort: toSortType(search.sort), + } +} + +export function fromCreatePost( + createPost: CreatePost, +): components['schemas']['CreatePost'] { + return { + ...createPost, + title: createPost.name, + } +} + +export function fromListCommunities( + listCommunities: ListCommunities, +): components['schemas']['ListCommunities'] { + return { + ...listCommunities, + // @ts-expect-error ok so the api tells me something different than the actual dev api tells me to do + sort: toCommunitiesSortType(listCommunities.sort), + } +} + +export function fromCreateComment( + createComment: CreateComment, +): components['schemas']['CreateComment'] { + return { + ...createComment, + body: createComment.content, + } +} + // Misc export function toSortType( sortType?: SortType, @@ -203,3 +297,11 @@ export function toCommentSortType( if (commentSortType == 'Controversial') commentSortType = undefined return commentSortType } + +export function toCommunitiesSortType( + sortType?: SortType, +): 'Top' | 'Hot' | 'New' | undefined { + if (sortType == 'Hot' || sortType == 'New' || sortType == undefined) + return sortType + else return 'Top' +} diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index cc37ded3..814b86b2 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -907,7 +907,9 @@ "couldnt_find_person": "That user doesn't exist.", "couldnt_find_community": "That community doesn't exist.", "not_an_admin": "You are not an admin of this instance.", - "rate_limit_error": "You are performing that action too fast." + "rate_limit_error": "You are performing that action too fast.", + "unimplemented": "That function of your account's instance is not yet supported by Photon.", + "unsupported": "That function is not supported by your account's instance." }, "aria": { "pagination": { diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte index ff3d90e0..cc0acdb4 100644 --- a/src/routes/+error.svelte +++ b/src/routes/+error.svelte @@ -7,7 +7,7 @@ function getError(message: string): { string: string; code: boolean } { try { - return { string: errorMessage(JSON.parse(message)), code: false } + return { string: errorMessage(message), code: false } } catch { return { string: message, code: true } } @@ -18,7 +18,7 @@ class="flex flex-col gap-4 my-auto h-full justify-center max-w-md w-full mx-auto" >

{page.status}

diff --git a/src/routes/search/+page.svelte b/src/routes/search/+page.svelte index fc56f683..c05f60c2 100644 --- a/src/routes/search/+page.svelte +++ b/src/routes/search/+page.svelte @@ -33,6 +33,7 @@ import { expoOut } from 'svelte/easing' import { fly, slide } from 'svelte/transition' import SearchBar from './SearchBar.svelte' + import { client } from '$lib/client/lemmy.svelte' let { data } = $props() @@ -55,6 +56,7 @@
{$t('routes.search.title')} {#snippet extended()} + {@const clientType = client().type.name}
@@ -69,9 +71,13 @@ {$t('filter.type')} {/snippet} - + {#if clientType == 'lemmy'} + + {/if} - + {#if clientType == 'lemmy'} + + {/if} diff --git a/src/routes/search/+page.ts b/src/routes/search/+page.ts index f9ecead9..14720a55 100644 --- a/src/routes/search/+page.ts +++ b/src/routes/search/+page.ts @@ -21,7 +21,9 @@ export async function load({ url, fetch }) { page: page, sort: (sort as SortType) || 'TopAll', listing_type: listing_type, - type_: (type as SearchType) ?? 'All', + type_: + (type as SearchType) ?? + (client().type.name == 'lemmy' ? 'All' : 'Posts'), }) const [posts, comments, users, communities] = [