format: whole project
This commit is contained in:
1 parent
b883b5f6e0
commit
80269cf275
79 files changed
+590
-612
No files matched your search
@@ -20,7 +20,7 @@ export interface ContentView {
|
||||
}
|
||||
|
||||
const isSubmissionView = (
|
||||
item: SubmissionView | ContentView
|
||||
item: SubmissionView | ContentView,
|
||||
): item is SubmissionView => !('type' in item)
|
||||
|
||||
const isSubmission = (item: Submission | ContentView): item is Submission =>
|
||||
@@ -63,7 +63,7 @@ export const contentItem = (item: Submission): ContentView => {
|
||||
export async function save(
|
||||
item: ContentView | SubmissionView,
|
||||
save: boolean,
|
||||
jwt: string
|
||||
jwt: string,
|
||||
): Promise<boolean> {
|
||||
if (isSubmissionView(item)) item = contentView(item)
|
||||
|
||||
@@ -88,7 +88,7 @@ export async function save(
|
||||
export async function deleteItem(
|
||||
item: ContentView | SubmissionView,
|
||||
deleted: boolean,
|
||||
jwt: string
|
||||
jwt: string,
|
||||
): Promise<boolean> {
|
||||
if (isSubmissionView(item)) item = contentView(item)
|
||||
|
||||
@@ -113,7 +113,7 @@ export async function deleteItem(
|
||||
export async function vote(
|
||||
item: ContentView | Submission,
|
||||
vote: number,
|
||||
jwt: string
|
||||
jwt: string,
|
||||
): Promise<{ upvotes: number; downvotes: number; score: number }> {
|
||||
if (isSubmission(item)) item = contentItem(item)
|
||||
|
||||
@@ -138,7 +138,7 @@ export async function vote(
|
||||
export async function markAsRead(
|
||||
item: ContentView | Submission,
|
||||
read: boolean,
|
||||
jwt: string
|
||||
jwt: string,
|
||||
): Promise<boolean> {
|
||||
if (isSubmission(item)) item = contentItem(item)
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export const generalizeCommentReply = (item: CommentReplyView): InboxItem => ({
|
||||
})
|
||||
|
||||
export const generalizePersonMention = (
|
||||
item: PersonMentionView
|
||||
item: PersonMentionView,
|
||||
): InboxItem => ({
|
||||
type: 'person_mention',
|
||||
id: item.person_mention.id,
|
||||
@@ -38,7 +38,7 @@ export const generalizePersonMention = (
|
||||
})
|
||||
|
||||
export const generalizePrivateMessage = (
|
||||
item: PrivateMessageView
|
||||
item: PrivateMessageView,
|
||||
): InboxItem => ({
|
||||
type: 'private_message',
|
||||
id: item.private_message.id,
|
||||
|
||||
@@ -67,7 +67,7 @@ export const isCommentReport = (item: Result): item is CommentReportView =>
|
||||
'comment_report' in item
|
||||
|
||||
export const isPrivateMessageReport = (
|
||||
item: Result
|
||||
item: Result,
|
||||
): item is PrivateMessageReportView => 'private_message_report' in item
|
||||
|
||||
export interface ResumableItem {
|
||||
@@ -86,15 +86,18 @@ function resumableStore(limit: number = 10) {
|
||||
const { subscribe, set, update } = writable<ResumableItem[]>([])
|
||||
|
||||
return {
|
||||
subscribe, set, update,
|
||||
subscribe,
|
||||
set,
|
||||
update,
|
||||
add: (item: ResumableItem) => {
|
||||
update(resumables => {
|
||||
if (resumables.find(i => JSON.stringify(i) == JSON.stringify(item))) return resumables
|
||||
update((resumables) => {
|
||||
if (resumables.find((i) => JSON.stringify(i) == JSON.stringify(item)))
|
||||
return resumables
|
||||
resumables.unshift(item)
|
||||
if (resumables.length > limit) resumables.pop()
|
||||
return resumables
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { get, writable } from 'svelte/store'
|
||||
export const shouldReload = (
|
||||
cache: PostFeed | undefined,
|
||||
url: URL,
|
||||
instance: string
|
||||
instance: string,
|
||||
): boolean =>
|
||||
cache?.instance != instance || cache?.url.toString() != url.toString()
|
||||
|
||||
@@ -27,7 +27,7 @@ export async function postFeed(args: {
|
||||
url: URL
|
||||
fetch?: (
|
||||
input: RequestInfo | URL,
|
||||
init?: RequestInit | undefined
|
||||
init?: RequestInit | undefined,
|
||||
) => Promise<Response>
|
||||
}) {
|
||||
const feed = get(postFeeds)[args.id]
|
||||
|
||||
@@ -37,7 +37,7 @@ interface BaseReport {
|
||||
}
|
||||
|
||||
export const generalizeCommentReport = (
|
||||
report: CommentReportView
|
||||
report: CommentReportView,
|
||||
): ReportView => ({
|
||||
creator: report.creator,
|
||||
item: {
|
||||
@@ -77,7 +77,7 @@ export const generalizePostReport = (report: PostReportView): ReportView => ({
|
||||
})
|
||||
|
||||
export const generalizePrivateMessageReport = (
|
||||
report: PrivateMessageReportView
|
||||
report: PrivateMessageReportView,
|
||||
): ReportView => ({
|
||||
creator: report.creator,
|
||||
item: report.private_message,
|
||||
|
||||
@@ -20,7 +20,7 @@ export const isBlocked = (me: MyUserInfo, user: number) =>
|
||||
|
||||
export const addSubscription = (
|
||||
community: Community,
|
||||
subscribe: boolean = true
|
||||
subscribe: boolean = true,
|
||||
) => {
|
||||
const p = get(profile)
|
||||
|
||||
|
||||
Reference in new issue
Block a user