refactor: rewrite client api adapters to be more efficient (#714)

* refactor: switch LemmyClient to a proxy to remove boilerplate methods

* refactor: make piefed adaptor (adapter?) declarative

* refactor: clean up rewrite.ts in Piefed adapter and fix type errors

* refactor: split auth.svelte.ts -> auth/profile.svelte.ts + auth/inbox.svelte.ts

* cleanup: $lib/feature/comment

* cleanup: remove useless 'transforms' src/lib/api/piefed/adapter.ts
This commit is contained in:
xylight authored and GitHub committed 2026-02-08 19:48:16 +00:00
commit 2a5fb886ae
105 files changed
+1136 -1725

No files matched your search

+6 -8
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { DEFAULT_INSTANCE_URL } from '$lib/app/instance.svelte'
import { instanceToURL } from '$lib/app/util.svelte'
import { error } from '@sveltejs/kit'
@@ -80,13 +80,11 @@ export function client({
// but not here, so that if jwt == '', it doesnt put a bearer
const headers = jwt ? { authorization: `Bearer ${jwt}` } : {}
return new (clientType.name == 'piefed' ? PiefedClient : LemmyClient)(
instanceToURL(instanceURL),
{
fetchFunction: (input, init) => customFetch(func, input, init, jwt),
headers: headers,
},
)
const Client = clientType.name == 'piefed' ? PiefedClient : LemmyClient
return new Client(instanceToURL(instanceURL), {
fetchFunction: (input, init) => customFetch(func, input, init, jwt),
headers: headers,
}) as unknown as BaseClient
}
// here for parts where i forgor to switch
+67 -479
View File
@@ -2,12 +2,68 @@ import { LemmyHttp } from 'lemmy-js-client'
import type { BaseClient, ClientType } from '../base'
import { fromGetPosts, toListingType } from './rewrite'
export class LemmyClient implements BaseClient {
type: ClientType = { name: 'lemmy', baseUrl: '/api/v3' }
export const LemmyClientConstants = {
password: { minLength: 8, maxLength: 60 },
}
static constants = { password: { minLength: 8, maxLength: 60 } }
export function createLemmyClient(
baseUrl: string,
args: {
fetchFunction: (input: any, init: any) => Promise<any>
headers: any
},
): BaseClient {
const client = new LemmyHttp(baseUrl, args)
#client: LemmyHttp
const overrides: Partial<BaseClient> = {
type: { name: 'lemmy', baseUrl: '/api/v3' } as ClientType,
async search(params) {
return await client.search({
...params,
listing_type: toListingType(params.listing_type),
} as any)
},
async listCommunities(params) {
return await client.listCommunities({
...params,
type_: toListingType(params.type_),
} as any)
},
async getPosts(params) {
return (await client.getPosts(fromGetPosts(params) as any)) as any
},
async getComments(params) {
return await client.getComments({
...params,
type_: toListingType(params.type_),
} as any)
},
}
return new Proxy(overrides as BaseClient, {
get: (target, prop, receiver) => {
const value = Reflect.get(target, prop, receiver)
if (value !== undefined) {
return value
}
const clientValue = (client as any)[prop]
if (typeof clientValue === 'function') {
return clientValue.bind(client)
}
return clientValue
},
})
}
export class LemmyClient {
static constants = LemmyClientConstants
#proxy: BaseClient
constructor(
baseUrl: string,
@@ -16,481 +72,13 @@ export class LemmyClient implements BaseClient {
headers: any
},
) {
this.#client = new LemmyHttp(baseUrl, args)
}
this.#proxy = createLemmyClient(baseUrl, args)
async getSite(
...params: Parameters<BaseClient['getSite']>
): ReturnType<BaseClient['getSite']> {
return await this.#client.getSite(...params)
}
async generateTotpSecret(
...params: Parameters<BaseClient['generateTotpSecret']>
): ReturnType<BaseClient['generateTotpSecret']> {
return await this.#client.generateTotpSecret(...params)
}
async listLogins(
...params: Parameters<BaseClient['listLogins']>
): ReturnType<BaseClient['listLogins']> {
return await this.#client.listLogins(...params)
}
async listAllMedia(
...params: Parameters<BaseClient['listAllMedia']>
): ReturnType<BaseClient['listAllMedia']> {
return await this.#client.listAllMedia(...params)
}
async updateTotp(
...params: Parameters<BaseClient['updateTotp']>
): ReturnType<BaseClient['updateTotp']> {
return await this.#client.updateTotp(...params)
}
async getModlog(
...params: Parameters<BaseClient['getModlog']>
): ReturnType<BaseClient['getModlog']> {
return await this.#client.getModlog(...params)
}
async search(
params: Parameters<BaseClient['search']>[0],
): ReturnType<BaseClient['search']> {
return await this.#client.search({
...params,
listing_type: toListingType(params.listing_type),
})
}
async resolveObject(
...params: Parameters<BaseClient['resolveObject']>
): ReturnType<BaseClient['resolveObject']> {
return await this.#client.resolveObject(...params)
}
async createCommunity(
...params: Parameters<BaseClient['createCommunity']>
): ReturnType<BaseClient['createCommunity']> {
return await this.#client.createCommunity(...params)
}
async getCommunity(
...params: Parameters<BaseClient['getCommunity']>
): ReturnType<BaseClient['getCommunity']> {
return await this.#client.getCommunity(...params)
}
async editCommunity(
...params: Parameters<BaseClient['editCommunity']>
): ReturnType<BaseClient['editCommunity']> {
return await this.#client.editCommunity(...params)
}
async listCommunities(
params: Parameters<BaseClient['listCommunities']>[0],
): ReturnType<BaseClient['listCommunities']> {
return await this.#client.listCommunities({
...params,
type_: toListingType(params.type_),
})
}
async followCommunity(
...params: Parameters<BaseClient['followCommunity']>
): ReturnType<BaseClient['followCommunity']> {
return await this.#client.followCommunity(...params)
}
async blockCommunity(
...params: Parameters<BaseClient['blockCommunity']>
): ReturnType<BaseClient['blockCommunity']> {
return await this.#client.blockCommunity(...params)
}
async deleteCommunity(
...params: Parameters<BaseClient['deleteCommunity']>
): ReturnType<BaseClient['deleteCommunity']> {
return await this.#client.deleteCommunity(...params)
}
async hideCommunity(
...params: Parameters<BaseClient['hideCommunity']>
): ReturnType<BaseClient['hideCommunity']> {
return await this.#client.hideCommunity(...params)
}
async removeCommunity(
...params: Parameters<BaseClient['removeCommunity']>
): ReturnType<BaseClient['removeCommunity']> {
return await this.#client.removeCommunity(...params)
}
async banFromCommunity(
...params: Parameters<BaseClient['banFromCommunity']>
): ReturnType<BaseClient['banFromCommunity']> {
return await this.#client.banFromCommunity(...params)
}
async addModToCommunity(
...params: Parameters<BaseClient['addModToCommunity']>
): ReturnType<BaseClient['addModToCommunity']> {
return await this.#client.addModToCommunity(...params)
}
async createPost(
...params: Parameters<BaseClient['createPost']>
): ReturnType<BaseClient['createPost']> {
return await this.#client.createPost(...params)
}
async getPost(
...params: Parameters<BaseClient['getPost']>
): ReturnType<BaseClient['getPost']> {
return await this.#client.getPost(...params)
}
async editPost(
...params: Parameters<BaseClient['editPost']>
): ReturnType<BaseClient['editPost']> {
return await this.#client.editPost(...params)
}
async deletePost(
...params: Parameters<BaseClient['deletePost']>
): ReturnType<BaseClient['deletePost']> {
return await this.#client.deletePost(...params)
}
async removePost(
...params: Parameters<BaseClient['removePost']>
): ReturnType<BaseClient['removePost']> {
return await this.#client.removePost(...params)
}
async markPostAsRead(
...params: Parameters<BaseClient['markPostAsRead']>
): ReturnType<BaseClient['markPostAsRead']> {
return await this.#client.markPostAsRead(...params)
}
async hidePost(
...params: Parameters<BaseClient['hidePost']>
): ReturnType<BaseClient['hidePost']> {
return await this.#client.hidePost(...params)
}
async lockPost(
...params: Parameters<BaseClient['lockPost']>
): ReturnType<BaseClient['lockPost']> {
return await this.#client.lockPost(...params)
}
async featurePost(
...params: Parameters<BaseClient['featurePost']>
): ReturnType<BaseClient['featurePost']> {
return await this.#client.featurePost(...params)
}
async getPosts(
params: Parameters<BaseClient['getPosts']>[0],
): ReturnType<BaseClient['getPosts']> {
return await this.#client.getPosts(fromGetPosts(params))
}
async likePost(
...params: Parameters<BaseClient['likePost']>
): ReturnType<BaseClient['likePost']> {
return await this.#client.likePost(...params)
}
async listPostLikes(
...params: Parameters<BaseClient['listPostLikes']>
): ReturnType<BaseClient['listPostLikes']> {
return await this.#client.listPostLikes(...params)
}
async savePost(
...params: Parameters<BaseClient['savePost']>
): ReturnType<BaseClient['savePost']> {
return await this.#client.savePost(...params)
}
async createPostReport(
...params: Parameters<BaseClient['createPostReport']>
): ReturnType<BaseClient['createPostReport']> {
return await this.#client.createPostReport(...params)
}
async resolvePostReport(
...params: Parameters<BaseClient['resolvePostReport']>
): ReturnType<BaseClient['resolvePostReport']> {
return await this.#client.resolvePostReport(...params)
}
async listPostReports(
...params: Parameters<BaseClient['listPostReports']>
): ReturnType<BaseClient['listPostReports']> {
return await this.#client.listPostReports(...params)
}
async getSiteMetadata(
...params: Parameters<BaseClient['getSiteMetadata']>
): ReturnType<BaseClient['getSiteMetadata']> {
return await this.#client.getSiteMetadata(...params)
}
async createComment(
...params: Parameters<BaseClient['createComment']>
): ReturnType<BaseClient['createComment']> {
return await this.#client.createComment(...params)
}
async editComment(
...params: Parameters<BaseClient['editComment']>
): ReturnType<BaseClient['editComment']> {
return await this.#client.editComment(...params)
}
async deleteComment(
...params: Parameters<BaseClient['deleteComment']>
): ReturnType<BaseClient['deleteComment']> {
return await this.#client.deleteComment(...params)
}
async removeComment(
...params: Parameters<BaseClient['removeComment']>
): ReturnType<BaseClient['removeComment']> {
return await this.#client.removeComment(...params)
}
async markCommentReplyAsRead(
...params: Parameters<BaseClient['markCommentReplyAsRead']>
): ReturnType<BaseClient['markCommentReplyAsRead']> {
return await this.#client.markCommentReplyAsRead(...params)
}
async likeComment(
...params: Parameters<BaseClient['likeComment']>
): ReturnType<BaseClient['likeComment']> {
return await this.#client.likeComment(...params)
}
async listCommentLikes(
...params: Parameters<BaseClient['listCommentLikes']>
): ReturnType<BaseClient['listCommentLikes']> {
return await this.#client.listCommentLikes(...params)
}
async saveComment(
...params: Parameters<BaseClient['saveComment']>
): ReturnType<BaseClient['saveComment']> {
return await this.#client.saveComment(...params)
}
async distinguishComment(
...params: Parameters<BaseClient['distinguishComment']>
): ReturnType<BaseClient['distinguishComment']> {
return await this.#client.distinguishComment(...params)
}
async getComments(
params: Parameters<BaseClient['getComments']>[0],
): ReturnType<BaseClient['getComments']> {
return await this.#client.getComments({
...params,
type_: toListingType(params.type_),
})
}
async getComment(
...params: Parameters<BaseClient['getComment']>
): ReturnType<BaseClient['getComment']> {
return await this.#client.getComment(...params)
}
async createCommentReport(
...params: Parameters<BaseClient['createCommentReport']>
): ReturnType<BaseClient['createCommentReport']> {
return await this.#client.createCommentReport(...params)
}
async resolveCommentReport(
...params: Parameters<BaseClient['resolveCommentReport']>
): ReturnType<BaseClient['resolveCommentReport']> {
return await this.#client.resolveCommentReport(...params)
}
async listCommentReports(
...params: Parameters<BaseClient['listCommentReports']>
): ReturnType<BaseClient['listCommentReports']> {
return await this.#client.listCommentReports(...params)
}
async getPrivateMessages(
...params: Parameters<BaseClient['getPrivateMessages']>
): ReturnType<BaseClient['getPrivateMessages']> {
return await this.#client.getPrivateMessages(...params)
}
async createPrivateMessage(
...params: Parameters<BaseClient['createPrivateMessage']>
): ReturnType<BaseClient['createPrivateMessage']> {
return await this.#client.createPrivateMessage(...params)
}
async editPrivateMessage(
...params: Parameters<BaseClient['editPrivateMessage']>
): ReturnType<BaseClient['editPrivateMessage']> {
return await this.#client.editPrivateMessage(...params)
}
async deletePrivateMessage(
...params: Parameters<BaseClient['deletePrivateMessage']>
): ReturnType<BaseClient['deletePrivateMessage']> {
return await this.#client.deletePrivateMessage(...params)
}
async markPrivateMessageAsRead(
...params: Parameters<BaseClient['markPrivateMessageAsRead']>
): ReturnType<BaseClient['markPrivateMessageAsRead']> {
return await this.#client.markPrivateMessageAsRead(...params)
}
async createPrivateMessageReport(
...params: Parameters<BaseClient['createPrivateMessageReport']>
): ReturnType<BaseClient['createPrivateMessageReport']> {
return await this.#client.createPrivateMessageReport(...params)
}
async resolvePrivateMessageReport(
...params: Parameters<BaseClient['resolvePrivateMessageReport']>
): ReturnType<BaseClient['resolvePrivateMessageReport']> {
return await this.#client.resolvePrivateMessageReport(...params)
}
async listPrivateMessageReports(
...params: Parameters<BaseClient['listPrivateMessageReports']>
): ReturnType<BaseClient['listPrivateMessageReports']> {
return await this.#client.listPrivateMessageReports(...params)
}
async register(
...params: Parameters<BaseClient['register']>
): ReturnType<BaseClient['register']> {
return await this.#client.register(...params)
}
async login(
...params: Parameters<BaseClient['login']>
): ReturnType<BaseClient['login']> {
return await this.#client.login(...params)
}
async logout(
...params: Parameters<BaseClient['logout']>
): ReturnType<BaseClient['logout']> {
return await this.#client.logout(...params)
}
async getPersonDetails(
...params: Parameters<BaseClient['getPersonDetails']>
): ReturnType<BaseClient['getPersonDetails']> {
return await this.#client.getPersonDetails(...params)
}
async getPersonMentions(
...params: Parameters<BaseClient['getPersonMentions']>
): ReturnType<BaseClient['getPersonMentions']> {
return await this.#client.getPersonMentions(...params)
}
async markPersonMentionAsRead(
...params: Parameters<BaseClient['markPersonMentionAsRead']>
): ReturnType<BaseClient['markPersonMentionAsRead']> {
return await this.#client.markPersonMentionAsRead(...params)
}
async getReplies(
...params: Parameters<BaseClient['getReplies']>
): ReturnType<BaseClient['getReplies']> {
return await this.#client.getReplies(...params)
}
async banPerson(
...params: Parameters<BaseClient['banPerson']>
): ReturnType<BaseClient['banPerson']> {
return await this.#client.banPerson(...params)
}
async getBannedPersons(
...params: Parameters<BaseClient['getBannedPersons']>
): ReturnType<BaseClient['getBannedPersons']> {
return await this.#client.getBannedPersons(...params)
}
async blockPerson(
...params: Parameters<BaseClient['blockPerson']>
): ReturnType<BaseClient['blockPerson']> {
return await this.#client.blockPerson(...params)
}
async getCaptcha(
...params: Parameters<BaseClient['getCaptcha']>
): ReturnType<BaseClient['getCaptcha']> {
return await this.#client.getCaptcha(...params)
}
async deleteAccount(
...params: Parameters<BaseClient['deleteAccount']>
): ReturnType<BaseClient['deleteAccount']> {
return await this.#client.deleteAccount(...params)
}
async passwordReset(
...params: Parameters<BaseClient['passwordReset']>
): ReturnType<BaseClient['passwordReset']> {
return await this.#client.passwordReset(...params)
}
async passwordChangeAfterReset(
...params: Parameters<BaseClient['passwordChangeAfterReset']>
): ReturnType<BaseClient['passwordChangeAfterReset']> {
return await this.#client.passwordChangeAfterReset(...params)
}
async markAllAsRead(
...params: Parameters<BaseClient['markAllAsRead']>
): ReturnType<BaseClient['markAllAsRead']> {
return await this.#client.markAllAsRead(...params)
}
async saveUserSettings(
...params: Parameters<BaseClient['saveUserSettings']>
): ReturnType<BaseClient['saveUserSettings']> {
return await this.#client.saveUserSettings(...params)
}
async changePassword(
...params: Parameters<BaseClient['changePassword']>
): ReturnType<BaseClient['changePassword']> {
return await this.#client.changePassword(...params)
}
async getReportCount(
...params: Parameters<BaseClient['getReportCount']>
): ReturnType<BaseClient['getReportCount']> {
return await this.#client.getReportCount(...params)
}
async getUnreadCount(
...params: Parameters<BaseClient['getUnreadCount']>
): ReturnType<BaseClient['getUnreadCount']> {
return await this.#client.getUnreadCount(...params)
}
async verifyEmail(
...params: Parameters<BaseClient['verifyEmail']>
): ReturnType<BaseClient['verifyEmail']> {
return await this.#client.verifyEmail(...params)
}
async addAdmin(
...params: Parameters<BaseClient['addAdmin']>
): ReturnType<BaseClient['addAdmin']> {
return await this.#client.addAdmin(...params)
}
async getUnreadRegistrationApplicationCount(
...params: Parameters<BaseClient['getUnreadRegistrationApplicationCount']>
): ReturnType<BaseClient['getUnreadRegistrationApplicationCount']> {
return await this.#client.getUnreadRegistrationApplicationCount(...params)
}
async listRegistrationApplications(
...params: Parameters<BaseClient['listRegistrationApplications']>
): ReturnType<BaseClient['listRegistrationApplications']> {
return await this.#client.listRegistrationApplications(...params)
}
async approveRegistrationApplication(
...params: Parameters<BaseClient['approveRegistrationApplication']>
): ReturnType<BaseClient['approveRegistrationApplication']> {
return await this.#client.approveRegistrationApplication(...params)
}
async getRegistrationApplication(
...params: Parameters<BaseClient['getRegistrationApplication']>
): ReturnType<BaseClient['getRegistrationApplication']> {
return await this.#client.getRegistrationApplication(...params)
}
async purgePerson(
...params: Parameters<BaseClient['purgePerson']>
): ReturnType<BaseClient['purgePerson']> {
return await this.#client.purgePerson(...params)
}
async purgeCommunity(
...params: Parameters<BaseClient['purgeCommunity']>
): ReturnType<BaseClient['purgeCommunity']> {
return await this.#client.purgeCommunity(...params)
}
async purgePost(
...params: Parameters<BaseClient['purgePost']>
): ReturnType<BaseClient['purgePost']> {
return await this.#client.purgePost(...params)
}
async purgeComment(
...params: Parameters<BaseClient['purgeComment']>
): ReturnType<BaseClient['purgeComment']> {
return await this.#client.purgeComment(...params)
}
async getFederatedInstances(
...params: Parameters<BaseClient['getFederatedInstances']>
): ReturnType<BaseClient['getFederatedInstances']> {
return await this.#client.getFederatedInstances(...params)
}
async blockInstance(
...params: Parameters<BaseClient['blockInstance']>
): ReturnType<BaseClient['blockInstance']> {
return await this.#client.blockInstance(...params)
}
async uploadImage(
...params: Parameters<BaseClient['uploadImage']>
): ReturnType<BaseClient['uploadImage']> {
return await this.#client.uploadImage(...params)
}
async editSite(
...params: Parameters<BaseClient['editSite']>
): ReturnType<BaseClient['editSite']> {
return await this.#client.editSite(...params)
}
async deleteImage(
...params: Parameters<BaseClient['deleteImage']>
): ReturnType<BaseClient['deleteImage']> {
return await this.#client.deleteImage(...params)
}
async listMedia(
...params: Parameters<BaseClient['listMedia']>
): ReturnType<BaseClient['listMedia']> {
return await this.#client.listMedia(...params)
return new Proxy(this, {
get: (target, prop) => {
if (prop === 'constructor') return LemmyClient
return (target.#proxy as any)[prop]
},
}) as any
}
}
File diff suppressed because it is too large. Load diff
+65 -85
View File
@@ -1,36 +1,23 @@
import { Search } from 'mono-svelte'
import type {
Comment,
CommentReplyView,
CommentSortType,
CommentView,
Community,
CommunityView,
CreateComment,
CreatePost,
FeedView,
GetComments,
GetPost,
GetPosts,
GetReplies,
ListCommunities,
LocalSite,
MyUserInfo,
Person,
PersonMentionView,
PersonView,
Post,
PostView,
PrivateMessageView,
SortType,
SubscribedType,
TopicView,
} from '../types'
import type { components } from './schema'
import * as base from '../types'
import type { components, paths } from './schema'
type Schema<T extends keyof components['schemas']> = components['schemas'][T]
type PathQuery<P extends keyof paths> = paths[P] extends {
get: { parameters: { query?: infer Q } }
}
? Q
: never
type PathBody<P extends keyof paths> = paths[P] extends {
post: { requestBody: { content: { 'application/json': infer B } } }
}
? B
: never
export function toPersonView(
personView: components['schemas']['PersonView'],
): PersonView {
personView: Schema<'PersonView'>,
): base.PersonView {
return {
counts: personView.counts,
is_admin: personView.is_admin,
@@ -38,7 +25,7 @@ export function toPersonView(
}
}
export function toPerson(person: components['schemas']['Person']): Person {
export function toPerson(person: Schema<'Person'>): base.Person {
return {
...person,
id: person.id,
@@ -47,14 +34,14 @@ export function toPerson(person: components['schemas']['Person']): Person {
}
}
export function toLocalSite(site: components['schemas']['Site']): LocalSite {
export function toLocalSite(site: Schema<'Site'>): base.LocalSite {
if (site) return {}
return {}
}
export function toCommunityView(
communityView: components['schemas']['CommunityView'],
): CommunityView {
communityView: Schema<'CommunityView'>,
): base.CommunityView {
return {
...communityView,
community: toCommunity(communityView.community),
@@ -74,9 +61,7 @@ export function toCommunityView(
}
}
export function toCommunity(
community: components['schemas']['Community'],
): Community {
export function toCommunity(community: Schema<'Community'>): base.Community {
return {
...community,
posting_restricted_to_mods: false,
@@ -84,9 +69,7 @@ export function toCommunity(
}
}
export function toMyUser(
myUser: components['schemas']['MyUserInfo'],
): MyUserInfo {
export function toMyUser(myUser: Schema<'MyUserInfo'>): base.MyUserInfo {
return {
...myUser,
community_blocks: myUser.community_blocks.map((i) => ({
@@ -125,9 +108,7 @@ export function toMyUser(
}
}
export function toPostView(
postView: components['schemas']['PostView'],
): PostView {
export function toPostView(postView: Schema<'PostView'>): base.PostView {
return {
...postView,
creator: toPerson(postView.creator),
@@ -137,7 +118,7 @@ export function toPostView(
}
}
export function toPost(post: components['schemas']['Post']): Post {
export function toPost(post: Schema<'Post'>): base.Post {
return {
...post,
creator_id: -1,
@@ -148,19 +129,19 @@ export function toPost(post: components['schemas']['Post']): Post {
}
export function toCommentView(
commentView: components['schemas']['CommentView'],
): CommentView {
commentView: Schema<'CommentView'>,
): base.CommentView {
return {
...commentView,
comment: toComment(commentView.comment),
creator: toPerson(commentView.creator),
post: toPost(commentView.post),
community: toCommunity(commentView.community),
subscribed: commentView.subscribed as SubscribedType,
subscribed: commentView.subscribed as base.SubscribedType,
}
}
export function toComment(comment: components['schemas']['Comment']): Comment {
export function toComment(comment: Schema<'Comment'>): base.Comment {
return {
...comment,
content: comment.body,
@@ -170,8 +151,8 @@ export function toComment(comment: components['schemas']['Comment']): Comment {
}
export function toCommentReplyView(
commentReplyView: components['schemas']['CommentReplyView'],
): CommentReplyView {
commentReplyView: Schema<'CommentReplyView'>,
): base.CommentReplyView {
return {
...commentReplyView,
banned_from_community: false,
@@ -185,8 +166,8 @@ export function toCommentReplyView(
}
export function toPrivateMessageView(
privateMessageView: components['schemas']['PrivateMessageView'],
): PrivateMessageView {
privateMessageView: Schema<'PrivateMessageView'>,
): base.PrivateMessageView {
return {
...privateMessageView,
creator: toPerson(privateMessageView.creator),
@@ -195,8 +176,8 @@ export function toPrivateMessageView(
}
export function toPersonMentionView(
personMentionView: components['schemas']['CommentReplyView'],
): PersonMentionView {
personMentionView: Schema<'CommentReplyView'>,
): base.PersonMentionView {
return {
...personMentionView,
person_mention: personMentionView.comment_reply,
@@ -210,9 +191,7 @@ export function toPersonMentionView(
}
}
export function toTopicView(
topicView: components['schemas']['TopicView'],
): TopicView {
export function toTopicView(topicView: Schema<'TopicView'>): base.TopicView {
return {
...topicView,
communities: topicView.communities?.map(toCommunity),
@@ -220,9 +199,7 @@ export function toTopicView(
}
}
export function toFeedView(
feedView: components['schemas']['FeedView'],
): FeedView {
export function toFeedView(feedView: Schema<'FeedView'>): base.FeedView {
return {
...feedView,
communities: feedView.communities?.map(toCommunity),
@@ -230,10 +207,9 @@ export function toFeedView(
}
}
// Query calls
export function fromGetPosts(
getPosts: GetPosts,
): components['parameters']['GetPosts'] {
getPosts: base.GetPosts,
): PathQuery<'/api/alpha/post/list'> {
return {
...getPosts,
sort: toSortType(getPosts.sort),
@@ -242,8 +218,8 @@ export function fromGetPosts(
}
export function fromGetComments(
getComments: GetComments,
): components['schemas']['GetComments'] {
getComments: base.GetComments,
): PathQuery<'/api/alpha/comment/list'> {
return {
...getComments,
sort: toCommentSortType(getComments.sort),
@@ -251,23 +227,25 @@ export function fromGetComments(
}
export function fromGetPost(
getPost: GetPost,
): components['schemas']['GetPost'] {
getPost: base.GetPost,
): PathQuery<'/api/alpha/post'> {
return getPost
}
export function fromGetReplies(
getReplies: GetReplies,
): components['schemas']['GetReplies'] {
getReplies: base.GetReplies,
): PathQuery<'/api/alpha/user/replies'> {
return {
...getReplies,
sort: toCommentSortType(getReplies.sort),
}
}
export function fromSearch(search: Search): components['schemas']['Search'] {
export function fromSearch(
search: base.Search,
): PathQuery<'/api/alpha/search'> {
return {
...(search as Omit<Search, 'type_'> & {
...(search as Omit<base.Search, 'type_'> & {
type_: 'Communities' | 'Users' | 'Url' | 'Posts'
}),
sort: toSortType(search.sort),
@@ -275,8 +253,8 @@ export function fromSearch(search: Search): components['schemas']['Search'] {
}
export function fromCreatePost(
createPost: CreatePost,
): components['schemas']['CreatePost'] {
createPost: base.CreatePost,
): PathBody<'/api/alpha/post'> {
return {
...createPost,
title: createPost.name,
@@ -284,27 +262,28 @@ export function fromCreatePost(
}
export function fromListCommunities(
listCommunities: ListCommunities,
): components['schemas']['CommunityRequest'] {
listCommunities: base.ListCommunities,
): PathQuery<'/api/alpha/community/list'> {
return {
...listCommunities,
type_: listCommunities.type_ as 'All',
sort: toCommunitiesSortType(listCommunities.sort),
}
}
export function fromCreateComment(
createComment: CreateComment,
): components['schemas']['CreateComment'] {
createComment: base.CreateComment,
): PathBody<'/api/alpha/comment'> {
return {
...createComment,
body: createComment.content,
}
}
// Misc
export function toSortType(
sortType?: SortType,
): components['schemas']['SortType'] | undefined {
sortType?: base.SortType,
): Schema<'SortType'> | undefined {
if (!sortType) return
if (
sortType == 'Old' ||
sortType == 'MostComments' ||
@@ -312,18 +291,19 @@ export function toSortType(
sortType == 'NewComments'
)
sortType = 'New'
return sortType
if (sortType?.startsWith('Top')) sortType = 'TopAll'
return sortType as Schema<'SortType'>
}
export function toCommentSortType(
commentSortType?: CommentSortType,
): components['schemas']['CommentSortType'] | undefined {
commentSortType?: base.CommentSortType,
): Schema<'CommentSortType'> | undefined {
if (commentSortType == 'Controversial') commentSortType = undefined
return commentSortType
}
export function toCommunitiesSortType(
sortType?: SortType,
sortType?: base.SortType,
): 'Top' | 'Hot' | 'New' | undefined {
if (sortType == 'Hot' || sortType == 'New' || sortType == undefined)
return sortType
+6 -4
View File
@@ -4706,7 +4706,7 @@ export interface components {
* Format: datetime
* @example 2025-06-07T02:29:07.980084Z
*/
published?: string
published: string
title?: string
}
PersonView: {
@@ -5809,7 +5809,7 @@ export interface components {
note: string
}
UserSetNoteResponse: {
person_view?: components['schemas']['PersonView']
person_view: components['schemas']['PersonView']
}
ListCommentsResponse: {
comments: components['schemas']['CommentView'][]
@@ -5873,7 +5873,7 @@ export interface components {
id: number
creator_id: number
comment_id: number
original_comment_text?: string
original_comment_text: string
reason?: string
resolved: boolean
/**
@@ -6057,7 +6057,7 @@ export interface components {
* Format: datetime
* @example 2025-06-07T02:29:07.980084Z
*/
published?: string
published: string
}
PostReportView: {
post_report: components['schemas']['PostReport']
@@ -6215,6 +6215,8 @@ export interface components {
private_message_id: number
reason: string
}
SortType: 'Active' | 'Hot' | 'TopAll' | 'New' | 'Old'
CommentSortType: 'Hot' | 'Top' | 'TopAll' | 'New' | 'Old'
}
responses: {
/** @description Unprocessable Content */
+4 -4
View File
@@ -165,7 +165,7 @@ export interface GetPersonMentionsResponse {
}
export interface GetPost {
id?: PostId
id: PostId
comment_id?: CommentId
}
@@ -190,8 +190,8 @@ export interface GetPosts {
show_read?: boolean
show_nsfw?: boolean
page_cursor?: PaginationCursor
feed_id?: string
topic_id?: string
feed_id?: number
topic_id?: number
}
export interface GetPostsResponse {
@@ -2333,7 +2333,7 @@ export interface UpdateTotpResponse {
}
export interface UploadImage {
image: File | Buffer
image: File
}
export interface UploadImageResponse {
msg: string
+90
View File
@@ -0,0 +1,90 @@
import type { Profile } from './profile.svelte'
interface Notifications {
inbox: number
reports: number
applications: number
}
export class InboxService {
private readonly POLL_INTERVAL = 4 * 60 * 1000
#pollInterval: ReturnType<typeof setInterval> | null = null
#profile: Profile
notifications = $state<Notifications>({
applications: 0,
inbox: 0,
reports: 0,
})
constructor(profile: Profile) {
this.#profile = profile
}
async init(): Promise<void> {
this.cleanup()
this.notifications = await this.checkInbox()
this.#pollInterval = setInterval(async () => {
this.notifications = await this.checkInbox()
}, this.POLL_INTERVAL)
}
cleanup(): void {
if (this.#pollInterval) clearInterval(this.#pollInterval)
this.#pollInterval = null
}
clear(): Notifications {
this.notifications = {
applications: 0,
inbox: 0,
reports: 0,
}
return this.notifications
}
async checkInbox(): Promise<Notifications> {
if (!this.#profile.current.user || !this.#profile.current.jwt)
return this.clear()
const unreadsPromise = this.#profile.client
.getUnreadCount()
.then((res) => res.mentions + res.private_messages + res.replies)
.catch(() => 0)
const reportsPromise = this.#profile.isMod()
? this.#profile.client
.getReportCount({})
.then(
(res) =>
res.comment_reports +
res.post_reports +
(res.private_message_reports ?? 0),
)
.catch(() => 0)
: Promise.resolve(0)
const applicationsPromise = this.#profile.isAdmin
? this.#profile.client
.getUnreadRegistrationApplicationCount()
.then((res) => res.registration_applications)
.catch(() => 0)
: Promise.resolve(0)
const [unreads, reports, applications] = await Promise.all([
unreadsPromise,
reportsPromise,
applicationsPromise,
])
return {
inbox: unreads,
reports: reports,
applications: applications,
}
}
}
+1
View File
@@ -0,0 +1 @@
export { profile, type ProfileInfo } from './profile.svelte'
@@ -5,10 +5,11 @@ import { client, site } from '$lib/api/client.svelte'
import type { Community, GetSiteResponse, MyUserInfo } from '$lib/api/types'
import { publishedToDate } from '$lib/ui/util/date'
import { toast } from 'mono-svelte'
import { errorMessage } from './error'
import { t } from './i18n'
import { DEFAULT_INSTANCE_URL } from './instance.svelte'
import { instanceToURL, moveItem } from './util.svelte'
import { errorMessage } from '../error'
import { t } from '../i18n'
import { DEFAULT_INSTANCE_URL } from '../instance.svelte'
import { instanceToURL, moveItem } from '../util.svelte'
import { InboxService } from './inbox.svelte'
function getFromStorage<T>(key: string): T | undefined {
if (!browser) return
@@ -18,9 +19,12 @@ function getFromStorage<T>(key: string): T | undefined {
return JSON.parse(lc)
}
function setFromStorage(key: string, item: any, stringify: boolean = true) {
function setFromStorage<T>(key: string, item: T, stringify: boolean = true) {
if (!browser) return
return localStorage.setItem(key, stringify ? JSON.stringify(item) : item)
return localStorage.setItem(
key,
stringify ? JSON.stringify(item) : (item as string),
)
}
export interface ProfileInfo {
@@ -44,12 +48,6 @@ interface ProfileData {
profile: number
}
interface Notifications {
inbox: number
reports: number
applications: number
}
const getCookie = (key: string): string | undefined => {
if (!browser) return undefined
@@ -60,7 +58,7 @@ const getCookie = (key: string): string | undefined => {
?.split('=')?.[1]
}
class Profile {
export class Profile {
private static readonly DONATION_CHECK_TIMEOUT = 3 * 1000
private static readonly DONATION_REMINDER_INTERVAL = 375 * 24 * 60 * 60 * 1000
@@ -142,11 +140,10 @@ class Profile {
private donationPoll(delay: number) {
return setTimeout(() => {
if (
profile.current.user?.local_user_view.local_user
.last_donation_notification
this.current.user?.local_user_view.local_user.last_donation_notification
) {
const donationDate = publishedToDate(
profile.current.user?.local_user_view.local_user
this.current.user?.local_user_view.local_user
.last_donation_notification,
)
if (
@@ -161,11 +158,11 @@ class Profile {
// lemmy js client donation dialog is broken
fetch(
`${instanceToURL(profile.current.instance)}/api/v3/user/donation_dialog_shown`,
`${instanceToURL(this.current.instance)}/api/v3/user/donation_dialog_shown`,
{
method: 'POST',
headers: {
authorization: `Bearer ${profile.current.jwt}`,
authorization: `Bearer ${this.current.jwt}`,
},
},
)
@@ -179,7 +176,7 @@ class Profile {
if (this.#current.jwt) {
site.data = undefined
const res = await userFromJwt(
const res = await fetchUserContext(
this.#current.jwt,
this.#current.instance,
this.#current.client,
@@ -199,7 +196,7 @@ class Profile {
site.data = res?.site
this.#current.user = res?.user
if (profile.current.user) {
if (this.current.user) {
this.#current.avatar = res?.user?.local_user_view.person.avatar
this.#current.username = res?.user?.local_user_view.person.name
}
@@ -218,7 +215,7 @@ class Profile {
async add(jwt: string, instance: string, type: ClientType) {
try {
const user = await userFromJwt(jwt, instance, type)
const user = await fetchUserContext(jwt, instance, type)
if (!user?.user) {
throw new Error('No user data received')
}
@@ -265,15 +262,13 @@ class Profile {
}
isMod(community?: Community): boolean {
if (community)
return (
(this.#current.user?.moderates.some(
(i) => i.community.id == community.id,
) ||
(community.local && this.isAdmin)) ??
false
)
else return (this.#current.user?.moderates.length ?? 0) > 0
if (!community) return (this.#current.user?.moderates.length ?? 0) > 0
if (community.local && this.isAdmin) return true
return (
this.#current.user?.moderates.some(
(m) => m.community.id === community.id,
) ?? false
)
}
get isAdmin(): boolean {
@@ -311,93 +306,9 @@ class Profile {
})
}
class InboxService {
private readonly POLL_INTERVAL = 4 * 60 * 1000
#pollInterval: NodeJS.Timeout | null = null
#profile: Profile
notifications = $state<Notifications>({
applications: 0,
inbox: 0,
reports: 0,
})
constructor(profile: Profile) {
this.#profile = profile
}
async init(): Promise<void> {
this.cleanup()
this.notifications = await this.checkInbox()
this.#pollInterval = setInterval(async () => {
this.notifications = await this.checkInbox()
}, this.POLL_INTERVAL)
}
cleanup(): void {
if (this.#pollInterval) clearInterval(this.#pollInterval)
this.#pollInterval = null
}
clear(): Notifications {
this.notifications = {
applications: 0,
inbox: 0,
reports: 0,
}
return this.notifications
}
async checkInbox(): Promise<Notifications> {
if (!this.#profile.current.user || !this.#profile.current.jwt)
return this.clear()
const unreadsPromise = client()
.getUnreadCount()
.then((res) => res.mentions + res.private_messages + res.replies)
.catch(() => 0)
const reportsPromise = this.#profile.isMod()
? client()
.getReportCount({})
.then(
(res) =>
res.comment_reports +
res.post_reports +
(res.private_message_reports ?? 0),
)
.catch(() => 0)
: new Promise<number>((res) => res(0))
const applicationsPromise = this.#profile.isAdmin
? client()
.getUnreadRegistrationApplicationCount()
.then((res) => res.registration_applications)
.catch(() => 0)
: new Promise<number>((res) => res(0))
const [unreads, reports, applications] = await Promise.all([
unreadsPromise,
reportsPromise,
applicationsPromise,
])
return {
inbox: unreads,
reports: reports,
applications: applications,
}
}
}
export const profile = new Profile()
// this is all garbage legacy code, remove later
async function userFromJwt(
async function fetchUserContext(
jwt: string,
instance: string,
type: ClientType,
@@ -429,10 +340,8 @@ async function userFromJwt(
if (!site) return
const myUser = site.my_user
return {
user: myUser,
user: site.my_user,
site: site,
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
import { browser } from '$app/environment'
import { env } from '$env/dynamic/public'
import { profile } from './auth.svelte'
import { profile } from './auth'
class InstanceData {
#instance = $derived(profile.current.instance)
+9 -6
View File
@@ -1,5 +1,6 @@
import { browser } from '$app/environment'
import { goto } from '$app/navigation'
import { env } from '$env/dynamic/public'
import { client } from '$lib/api/client.svelte'
import type { Community, Person } from '$lib/api/types'
import { SvelteURL } from 'svelte/reactivity'
@@ -26,6 +27,7 @@ export const searchParam = (
})
}
// why is this using SvelteURL brother
export const fullCommunityName = (name: string, actorId: string) =>
`${name}@${new SvelteURL(actorId).hostname}`
@@ -33,8 +35,8 @@ export const placeholders = {
get: (type: 'url' | 'post' | 'body' | 'comment') => {
switch (type) {
case 'post':
return Math.random() < 0.01
? 'A C E C* B* G D E E F G F E D C E'
return Math.random() < 0.01 && env.PUBLIC_XYLIGHT_MODE
? 'top 10 reasons why TCP is brilliant and UDP is a spawn of satan'
: t.get('placeholders.title')
case 'body':
return t.get('placeholders.body')
@@ -46,6 +48,8 @@ export const placeholders = {
},
}
// lol this function was made 3 years ago when lil xylight
// was still learning cs
export function moveItem<T>(
array: T[],
currentIndex: number,
@@ -62,10 +66,7 @@ export function moveItem<T>(
const newArray = [...array]
// Remove the item from the current index
const [item] = newArray.splice(currentIndex, 1)
// Insert the item at the new index
newArray.splice(newIndex, 0, item)
return newArray
@@ -139,7 +140,6 @@ export function fuzzySearch(text: string, pattern: string): number {
lastIndex = index
}
// Bonus for matching start of words
if (textLower.startsWith(patternLower)) {
score += 2
} else if (textLower.includes(' ' + patternLower)) {
@@ -167,6 +167,9 @@ export function snapshot<T>(item: T) {
return $state.snapshot(item)
}
// these methods should really not exist
// instead we should use lemmy's url_content_type which
// gives us a mimetype (which is more reliable)
export const isImage = (url: string | undefined) => {
try {
if (!url) return false
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/state'
import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte'
@@ -1,6 +1,6 @@
<script lang="ts">
import type { CommentView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte'
import { Button, Menu, MenuButton } from 'mono-svelte'
+2 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { client, site } from '$lib/api/client.svelte'
import type { CommentResponse } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte'
@@ -68,6 +68,7 @@
content: value,
post_id: postId,
parent_id: parentId,
language_id: language,
})
oncomment?.(response)
+1 -6
View File
@@ -28,11 +28,7 @@
}: Props = $props()
</script>
<div
class={['flex flex-col flex-1 rounded-none list-none', clazz]}
color="none"
padding="none"
>
<div class={['flex flex-col flex-1 rounded-none list-none', clazz]}>
{#if meta}
<div class="flex flex-row justify-between items-center gap-2">
<div class="flex flex-col gap-2">
@@ -68,7 +64,6 @@
</div>
{/if}
<Comment
postId={comment.post.id}
node={{ children: [], comment_view: comment, depth: 1, expanded: true }}
replying={false}
{meta}
@@ -18,8 +18,6 @@
let { nodes = $bindable(), post }: Props = $props()
let childrenPage = 0
async function fetchChildren(parent: CommentNodeI) {
if (
!(
@@ -37,7 +35,6 @@
max_depth: 5,
parent_id: parent.comment_view.comment.id,
type_: 'All',
page: childrenPage,
})
if (newComments.comments.length == 0) {
@@ -52,7 +49,6 @@
newComments.comments,
parent.depth,
)[0].children
childrenPage++
} catch (err) {
console.error(err)
toast({
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { site } from '$lib/api/client.svelte'
import type { Comment } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte'
@@ -1,7 +1,7 @@
<script lang="ts" module>
import { client, getClient } from '$lib/api/client.svelte'
import type { CommunityModeratorView, CommunityView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { client, site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
@@ -6,7 +6,7 @@
CommunityModeratorView,
SubscribedType,
} from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte'
import { fullCommunityName, userLink } from '$lib/app/util.svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { client } from '$lib/api/client.svelte'
import type { CommunityView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { locale, t } from '$lib/app/i18n'
import { fullCommunityName } from '$lib/app/util.svelte'
import CommonItem from '$lib/ui/layout/CommonItem.svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { client } from '$lib/api/client.svelte'
import type { CommunityView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { communityLink } from '$lib/app/util.svelte'
import Avatar from '$lib/ui/generic/Avatar.svelte'
+1 -1
View File
@@ -15,7 +15,7 @@ import type {
SortType,
TopicView,
} from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { recursiveEqual } from '$lib/app/util.svelte'
import { SvelteMap } from 'svelte/reactivity'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/state'
import { PiefedClient } from '$lib/api/piefed/adapter'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { searchParam } from '$lib/app/util.svelte'
import { Option, Select } from 'mono-svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/state'
import { PiefedClient } from '$lib/api/piefed/adapter'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { searchParam } from '$lib/app/util.svelte'
import { Option, Select } from 'mono-svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import type { PrivateMessageView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import Markdown from '$lib/app/markdown/Markdown.svelte'
import UserLink from '../user/UserLink.svelte'
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { type ProfileInfo } from '$lib/app/auth.svelte.js'
import { type ProfileInfo } from '$lib/app/auth'
import Avatar from '$lib/ui/generic/Avatar.svelte'
interface Props {
+1 -1
View File
@@ -11,7 +11,7 @@ import type {
PrivateMessageReportView,
PrivateMessageView,
} from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { writable } from 'svelte/store'
import type { Post } from '../post'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { client } from '$lib/api/client.svelte'
import type { Community, Person } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
@@ -1,6 +1,6 @@
<script lang="ts">
import type { CommentView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { Menu, MenuButton, MenuDivider } from 'mono-svelte'
import type { Snippet } from 'svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { getClient } from '$lib/api/client.svelte'
import type { CommentView, PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import { Menu, MenuButton, MenuDivider, toast } from 'mono-svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { getClient } from '$lib/api/client.svelte'
import type { CommentView, PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
@@ -5,7 +5,7 @@
PostView,
PrivateMessageView,
} from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import type { PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { type View, settings } from '$lib/app/settings.svelte'
import { publishedToDate } from '$lib/ui/util/date'
import type { ClassValue } from 'svelte/elements'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts" module>
import type { Community, Person, SubscribedType } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte'
import { type View, settings } from '$lib/app/settings.svelte'
+1 -1
View File
@@ -18,7 +18,7 @@
<script lang="ts">
import { site } from '$lib/api/client.svelte'
import type { Post } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/state'
import type { PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import { settings, type View } from '$lib/app/settings.svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { PiefedClient } from '$lib/api/piefed/adapter'
import type { PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte'
import { deleteItem, markAsRead } from '$lib/feature/legacy/contentview'
+1 -1
View File
@@ -2,7 +2,7 @@
import { client, site } from '$lib/api/client.svelte'
import { PiefedClient } from '$lib/api/piefed/adapter'
import type { PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
import { env } from '$env/dynamic/public'
import { client } from '$lib/api/client.svelte'
import type { CommentView, PersonView, Post } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import {
canParseUrl,
findClosestNumber,
+1 -1
View File
@@ -2,7 +2,7 @@
import { client } from '$lib/api/client.svelte'
import { PiefedClient } from '$lib/api/piefed/adapter'
import type { Post, PostPoll } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import { CommonList } from '$lib/ui/layout'
+12 -8
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { client } from '$lib/api/client.svelte'
import type { LocalImage, Person } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { instanceToURL } from '$lib/app/util.svelte'
import { showImage } from '$lib/ui/generic/ExpandableImage.svelte'
@@ -42,14 +42,16 @@
<div class="flex flex-col gap-1">
{#snippet img()}
<button
onclick={
() =>
showImage(`${instanceToURL(profile.current.instance)}/pictrs/image/${image.pictrs_alias}`)
}
class="cursor-pointer"
onclick={() =>
showImage(
`${instanceToURL(profile.current.instance)}/pictrs/image/${image.pictrs_alias}`,
)}
class="cursor-pointer"
>
<img
src="{instanceToURL(profile.current.instance)}/pictrs/image/{image.pictrs_alias}"
src="{instanceToURL(
profile.current.instance,
)}/pictrs/image/{image.pictrs_alias}"
width="500"
height="500"
class="aspect-square w-full h-full object-cover rounded-xl"
@@ -70,7 +72,9 @@
/>
<Button
title={$t('routes.profile.media.download')}
href="{instanceToURL(profile.current.instance)}/pictrs/image/{image.pictrs_alias}"
href="{instanceToURL(
profile.current.instance,
)}/pictrs/image/{image.pictrs_alias}"
size="square-md"
class="ml-auto"
icon={ArrowDownTray}
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { page } from '$app/state'
import { profile, type ProfileInfo } from '$lib/app/auth.svelte'
import { profile, type ProfileInfo } from '$lib/app/auth'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import SidebarButton from '$lib/ui/sidebar/SidebarButton.svelte'
import { Icon, QuestionMarkCircle } from 'svelte-hero-icons/dist'
+1 -1
View File
@@ -2,7 +2,7 @@
import { goto } from '$app/navigation'
import { page } from '$app/state'
import { DEFAULT_CLIENT_TYPE } from '$lib/api/base'
import { profile, type ProfileInfo } from '$lib/app/auth.svelte'
import { profile, type ProfileInfo } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import Avatar from '$lib/ui/generic/Avatar.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { getClient } from '$lib/api/client.svelte'
import type { ListingType, Person } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import Avatar from '$lib/ui/generic/Avatar.svelte'
import { MenuButton, Search } from 'mono-svelte'
import { createEventDispatcher } from 'svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
import { client } from '$lib/api/client.svelte'
import type { Community, MyUserInfo } from '$lib/api/types'
import { profile, type ProfileInfo } from '$lib/app/auth.svelte'
import { profile, type ProfileInfo } from '$lib/app/auth'
// TODO obliterate this file
export async function blockUser(block: boolean, id: number) {
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import { uploadImage } from '$lib/app/util.svelte'
-2
View File
@@ -1,5 +1,4 @@
<script lang="ts">
import { invalidateAll } from '$app/navigation'
import { page } from '$app/state'
import TabButton from '$lib/ui/form/TabButton.svelte'
import { SvelteURL } from 'svelte/reactivity'
@@ -70,7 +69,6 @@
)}
{#if style == 'header'}
<a
onclick={() => invalidateAll()}
href={buildUrl(currentRoute, route.href)}
class={['tab-item ', selected && 'tab-selected']}
>
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import { Menu, Spinner } from 'mono-svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { env } from '$env/dynamic/public'
import { site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte'
import { theme } from '$lib/app/theme/theme.svelte'
+1 -1
View File
@@ -2,7 +2,7 @@
import { browser } from '$app/environment'
import { goto } from '$app/navigation'
import { page } from '$app/state'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { theme } from '$lib/app/theme/theme.svelte'
import { fuzzySearch } from '$lib/app/util.svelte'
+1 -4
View File
@@ -1,9 +1,6 @@
import { goto } from '$app/navigation'
import { page } from '$app/state'
import {
profile as currentProfile,
type ProfileInfo,
} from '$lib/app/auth.svelte'
import { profile as currentProfile, type ProfileInfo } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte'
import { theme, type ThemeData } from '$lib/app/theme/theme.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { env } from '$env/dynamic/public'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import { settings } from '$lib/app/settings.svelte'
+1 -3
View File
@@ -24,9 +24,7 @@
}: Props = $props()
let selected = $derived(
page.url.pathname.startsWith(
href ?? 'The power of fluffy boys shines within you.',
) ?? false,
page.url.pathname.startsWith(href ?? '2026-02-08 hey guyz') ?? false,
)
</script>
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { DEFAULT_CLIENT_TYPE } from '$lib/api/base'
import { type ProfileInfo, profile } from '$lib/app/auth.svelte'
import { type ProfileInfo, profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import {
DEFAULT_INSTANCE_URL,
@@ -1,5 +1,5 @@
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { error, redirect } from '@sveltejs/kit'
export const ssr = false
+1 -1
View File
@@ -1,5 +1,5 @@
<script>
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { Tabs } from '$lib/ui/layout'
import { Badge } from 'mono-svelte'
+1 -1
View File
@@ -1,5 +1,5 @@
import { getClient, site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { error } from '@sveltejs/kit'
export async function load({ fetch }) {
@@ -4,7 +4,7 @@
ApproveRegistrationApplication,
RegistrationApplicationView,
} from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import ApplicationDenyModal from '$lib/feature/moderation/ApplicationDenyModal.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { client, site } from '$lib/api/client.svelte'
import type { EditSite } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { client, getClient } from '$lib/api/client.svelte'
import type { Instance } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import Placeholder from '$lib/ui/info/Placeholder.svelte'
+1 -1
View File
@@ -1,5 +1,5 @@
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { ReactiveState } from '$lib/app/util.svelte'
export async function load({ fetch, url }) {
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { getClient } from '$lib/api/client.svelte'
import type { Tagline } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte'
+1 -1
View File
@@ -2,7 +2,7 @@
import { browser } from '$app/environment'
import { navigating, page } from '$app/state'
import { site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { setSessionStorage } from '$lib/app/session'
import CommunityHeader from '$lib/feature/community/CommunityHeader.svelte'
@@ -1,6 +1,6 @@
<script lang="ts">
import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
import { resolveRoute } from '$app/paths'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { redirect } from '@sveltejs/kit'
export async function load({ params, fetch }) {
@@ -3,7 +3,7 @@
import { resolveRoute } from '$app/paths'
import { page } from '$app/state'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import ProfileButton from '$lib/feature/user/ProfileButton.svelte'
@@ -1,4 +1,4 @@
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { redirect } from '@sveltejs/kit'
export async function load({ params }) {
+1 -1
View File
@@ -5,7 +5,7 @@
CommunityView,
SubscribedType,
} from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { toast } from 'mono-svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { Header, Tabs } from '$lib/ui/layout'
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { redirect } from '@sveltejs/kit'
export const load = () => {
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/state'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import Location from '$lib/feature/filter/Location.svelte'
+1 -1
View File
@@ -2,7 +2,7 @@
import { goto } from '$app/navigation'
import { page } from '$app/state'
import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { searchParam } from '$lib/app/util.svelte'
import Fixate from '$lib/ui/generic/Fixate.svelte'
+1 -1
View File
@@ -1,5 +1,5 @@
import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { ReactiveState } from '$lib/app/util.svelte'
import {
generalizeCommentReply,
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte'
import { escapeHtml } from '$lib/app/util.svelte'
+1 -1
View File
@@ -2,7 +2,7 @@
import { goto } from '$app/navigation'
import { resolveRoute } from '$app/paths'
import type { Person, PrivateMessageView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte'
import Avatar from '$lib/ui/generic/Avatar.svelte'
@@ -2,7 +2,7 @@
import { browser } from '$app/environment'
import { client } from '$lib/api/client.svelte'
import type { PrivateMessageResponse } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
+2 -3
View File
@@ -9,7 +9,7 @@
import { client } from '$lib/api/client.svelte'
import { LemmyClient } from '$lib/api/lemmy/adapter'
import { PiefedClient } from '$lib/api/piefed/adapter'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import {
@@ -75,8 +75,7 @@
// leading HTTPS is redundant
form.instance = form.instance.trim().replace(/^https:\/\//, '')
if (!LINKED_INSTANCE_URL)
await checkInstance()
if (!LINKED_INSTANCE_URL) await checkInstance()
const response = await client({
instanceURL: form.instance,
+1 -1
View File
@@ -6,7 +6,7 @@
type ClientType,
DEFAULT_CLIENT_TYPE,
} from '$lib/api/base'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { getClient, validateInstance } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import {
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { error } from '@sveltejs/kit'
export function load() {
+1 -1
View File
@@ -1,5 +1,5 @@
import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { ReactiveState } from '$lib/app/util.svelte'
import { isCommentView, isPostView } from '$lib/feature/legacy/item'
import {
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import CommentItem from '$lib/feature/comment/CommentItem.svelte'
@@ -1,5 +1,5 @@
<script lang="ts">
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import CommunityItem from '$lib/feature/community/CommunityItem.svelte'
import { CommonList, Header } from '$lib/ui/layout'
+1 -1
View File
@@ -2,7 +2,7 @@
import { browser } from '$app/environment'
import { page } from '$app/state'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte'
import { searchParam } from '$lib/app/util.svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { getClient, validateInstance } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import {
+1 -1
View File
@@ -1,5 +1,5 @@
import { resolveRoute } from '$app/paths'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { error, redirect } from '@sveltejs/kit'
export function load({ params }) {
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/state'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte'
import { settings } from '$lib/app/settings.svelte'
@@ -1,10 +1,15 @@
import { resolveRoute } from '$app/paths'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { settings } from '$lib/app/settings.svelte'
import { ReactiveState } from '$lib/app/util.svelte'
import CommunityCard from '$lib/feature/community/CommunityCard.svelte'
import { Feed, feed, feeds, type FeedTypes } from '$lib/feature/feeds/feed.svelte'
import {
Feed,
feed,
feeds,
type FeedTypes,
} from '$lib/feature/feeds/feed.svelte'
import { redirect } from '@sveltejs/kit'
function buildContext(thread?: string) {
@@ -29,10 +34,17 @@ function buildContext(thread?: string) {
async function findInFeed(id: '/' | '/c/[name]' | '/f/[id]', postId: string) {
// this never actually loads anything
if (id == '/') {
return (feeds.get(id) as Feed<FeedTypes['/'][0], FeedTypes['/'][1]>)?.peek()
return (feeds.get(id) as Feed<FeedTypes['/'][0], FeedTypes['/'][1]>)
?.peek()
?.posts.find((i) => i.post.id.toString() == postId)
} else {
return (feeds.get(id) as Feed<FeedTypes['/c/[name]'][0], FeedTypes['/c/[name]'][1]>)?.peek()
return (
feeds.get(id) as Feed<
FeedTypes['/c/[name]'][0],
FeedTypes['/c/[name]'][1]
>
)
?.peek()
?.posts.find((i) => i.post.id.toString() == postId)
}
}
@@ -2,7 +2,7 @@
import { browser } from '$app/environment'
import { page } from '$app/state'
import type { CommentSortType, CommentView, PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte'
import CommentForm from '$lib/feature/comment/CommentForm.svelte'
@@ -3,7 +3,7 @@
import { resolveRoute } from '$app/paths'
import { page } from '$app/state'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import ProfileButton from '$lib/feature/user/ProfileButton.svelte'
@@ -1,4 +1,4 @@
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { redirect } from '@sveltejs/kit'
export async function load({ params }) {
@@ -1,5 +1,5 @@
<script lang="ts">
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { communityLink } from '$lib/app/util.svelte.js'
import ItemList from '$lib/ui/generic/ItemList.svelte'
@@ -1,5 +1,5 @@
<script lang="ts">
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import ItemList from '$lib/ui/generic/ItemList.svelte'
import Placeholder from '$lib/ui/info/Placeholder.svelte'
@@ -1,5 +1,5 @@
<script lang="ts">
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { userLink } from '$lib/app/util.svelte.js'
import ItemList from '$lib/ui/generic/ItemList.svelte'
@@ -1,6 +1,6 @@
<script lang="ts">
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import { Button, TextInput, toast } from 'mono-svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import { Button, removeToast, Switch, TextInput, toast } from 'mono-svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { getClient, site } from '$lib/api/client.svelte'
import type { SaveUserSettings } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
import ImageInputUpload from '$lib/ui/form/ImageInputUpload.svelte'
+1 -1
View File
@@ -1,5 +1,5 @@
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte'
import { profile } from '$lib/app/auth'
import { error } from '@sveltejs/kit'
// disable ssr, as the server cannot be authenticated
Loaded 100 of 105 files, more files were not shown because too many files have changed in this diff. Show more