{error}
diff --git a/src/app/feed/components/NewCommentWidget.tsx b/src/app/feed/components/NewCommentWidget.tsx
deleted file mode 100644
index 3d2e4ea..0000000
--- a/src/app/feed/components/NewCommentWidget.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import { useState } from 'react'
-import FancyTextEditor, {
- TextInputKeyDownEvent,
-} from '../../../components/inputs/FancyTextEditor.tsx'
-import Button from '../../../components/buttons/Button.tsx'
-import { useTranslations } from '../../i18n/translations.ts'
-
-interface NewCommentWidgetProps {
- onSubmit: (content: string) => void
- isSubmitting?: boolean
-}
-
-export default function NewCommentWidget({
- onSubmit,
- isSubmitting = false,
-}: NewCommentWidgetProps) {
- const { t } = useTranslations()
- const [content, setContent] = useState('')
-
- const onContentInput = (value: string) => {
- setContent(value)
- }
-
- const handleSubmit = () => {
- if (!content.trim()) {
- return
- }
-
- onSubmit(content)
-
- setContent('')
- }
-
- const onInputKeyDown = (e: TextInputKeyDownEvent) => {
- if (e.key === 'Enter' && e.ctrlKey) {
- e.preventDefault()
- handleSubmit()
- }
- }
-
- return (
-
-
-
-
-
-
-
- )
-}
diff --git a/src/app/feed/components/PostItem.tsx b/src/app/feed/components/PostItem.tsx
index db766f6..a0a541c 100644
--- a/src/app/feed/components/PostItem.tsx
+++ b/src/app/feed/components/PostItem.tsx
@@ -1,24 +1,13 @@
-import { PostMedia, PostReaction } from '../posts/posts.ts'
+import { Post, PostMedia } from '../posts/posts.ts'
import { useEffect, useState } from 'react'
-import { Link } from 'react-router-dom'
-import { PostInfo } from '../posts/usePostViewModel.ts'
-import { useUserStore } from '../../user/user.ts'
interface PostItemProps {
- post: PostInfo
- reactions: PostReaction[]
+ post: Post
addReaction: (emoji: string) => void
clearReaction: (emoji: string) => void
- hideViewButton?: boolean
}
-export default function PostItem({
- post,
- reactions,
- addReaction,
- clearReaction,
- hideViewButton = false,
-}: PostItemProps) {
+export default function PostItem({ post, addReaction, clearReaction }: PostItemProps) {
const formattedDate = post.createdAt.toLocaleString('en-US', {
year: 'numeric',
month: 'short',
@@ -42,14 +31,6 @@ export default function PostItem({
@{post.authorName}• {formattedDate}
- {!hideViewButton && (
- <>
- {' • '}
-
- View
-
- >
- )}
{post.content}
@@ -62,30 +43,26 @@ export default function PostItem({
)}
-
{post.possibleReactions.map((emoji) => {
- const count = reactions.filter((r) => r.emoji === emoji).length
- const didReact = reactions.some((r) => r.emoji == emoji && r.authorName == username)
+ const reaction = reactionMap.get(emoji)
+ const count = reaction?.count ?? 0
+ const didReact = reaction?.didReact ?? false
const onClick = () => {
if (didReact) {
clearReaction(emoji)
@@ -122,7 +99,7 @@ function PostReactionButton({ emoji, didReact, onClick, count }: PostReactionBut
diff --git a/src/initApp.ts b/src/initApp.ts
new file mode 100644
index 0000000..d693692
--- /dev/null
+++ b/src/initApp.ts
@@ -0,0 +1,22 @@
+import { initUser } from './app/user/user.ts'
+import { setGlobal } from './app/femtoApp.ts'
+import { PostsService } from './app/feed/posts/postsService.ts'
+import { MediaService } from './app/media/mediaService.ts'
+import { AuthService } from './app/auth/authService.ts'
+import { initClient } from './app/api/client.ts'
+
+export function initApp() {
+ setGlobal('version', import.meta.env.VITE_FEMTO_VERSION)
+ initUser()
+
+ const client = initClient()
+
+ const postService = new PostsService(client)
+ const mediaService = new MediaService(client)
+ const authService = new AuthService(client)
+
+ setGlobal('postsService', postService)
+ setGlobal('authService', authService)
+
+ return { postService, mediaService, authService }
+}
diff --git a/src/useRefreshSessionLoop.ts b/src/useRefreshSessionLoop.ts
index 5a0bf1c..36144ce 100644
--- a/src/useRefreshSessionLoop.ts
+++ b/src/useRefreshSessionLoop.ts
@@ -1,10 +1,10 @@
import { useEffect } from 'react'
+import { useUser } from './app/user/user.ts'
import { AuthService } from './app/auth/authService.ts'
-import { useUserStore } from './app/user/user.ts'
// Starts a loop that pings the server to keep the session alive, while also getting any updates on the user profile
export function useRefreshSessionLoop(authService: AuthService) {
- const user = useUserStore((state) => state.user)
+ const user = useUser()
const userId = user?.id ?? null
useEffect(() => {
diff --git a/src/utils/delay.ts b/src/utils/delay.ts
deleted file mode 100644
index 9c70749..0000000
--- a/src/utils/delay.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export function delay(ms: number) {
- return new Promise((resolve) => setTimeout(resolve, ms))
-}
diff --git a/src/utils/groupByAndMap.ts b/src/utils/groupByAndMap.ts
deleted file mode 100644
index 7f30995..0000000
--- a/src/utils/groupByAndMap.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-export function groupByAndMap