Skip to content

Commit

Permalink
refactor routes, remove my votes page (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesNakayama authored Sep 10, 2024
1 parent 0c8c91a commit a1eb343
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 133 deletions.
2 changes: 1 addition & 1 deletion app/components/ui/post-details.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Link, useNavigate } from '@remix-run/react'
import type * as Immutable from 'immutable'
import { useRef } from 'react'
import { type FallacyList } from '#app/repositories/fallacy-detection.ts'
import { type TreeContext } from '#app/routes/post.$postId.tsx'
import {
type CommentTreeState,
Expand All @@ -10,7 +11,6 @@ import {
PollType,
type PostState,
} from '#app/types/api-types.ts'
import { type FallacyList } from '#app/utils/fallacy_detection.ts'
import { invariant } from '#app/utils/misc.tsx'
import { useOptionalUser } from '#app/utils/user.ts'
import PollResult from './poll-result.tsx'
Expand Down
2 changes: 1 addition & 1 deletion app/components/ui/post-info-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment'
import { useState } from 'react'
import { type FallacyList } from '#app/repositories/fallacy-detection.ts'
import { type PostState, type Post } from '#app/types/api-types.ts'
import { type FallacyList } from '#app/utils/fallacy_detection.ts'

export function PostInfoBar({
post,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { zodResponseFormat } from 'openai/helpers/zod'
import { z } from 'zod'
import { MAX_CHARS_PER_POST } from '#app/constants.ts'
import { db } from '#app/db.ts'
import { invariant } from './misc.tsx'
import { invariant } from '#app/utils/misc.tsx'

// Fallacy detection based on a paper by Helwe et at. (2023): https://arxiv.org/abs/2311.09761

Expand Down
6 changes: 3 additions & 3 deletions app/repositories/playground-post.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { type Transaction } from 'kysely'
import { type PlaygroundPost } from '#app/types/api-types.ts'
import { type DB } from '#app/types/kysely-types.ts'
import {
type FallacyList,
FallacyListSchema,
} from '#app/utils/fallacy_detection.ts'
} from '#app/repositories/fallacy-detection.ts'
import { type PlaygroundPost } from '#app/types/api-types.ts'
import { type DB } from '#app/types/kysely-types.ts'

export async function storePlaygroundPost(
trx: Transaction<DB>,
Expand Down
8 changes: 4 additions & 4 deletions app/repositories/post.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { sql, type Transaction } from 'kysely'
import { MAX_CHARS_PER_POST } from '#app/constants.ts'
import {
type FallacyList,
FallacyListSchema,
} from '#app/repositories/fallacy-detection.ts'
import { vote } from '#app/repositories/vote.ts'
import {
Direction,
Expand All @@ -9,10 +13,6 @@ import {
type PollType,
} from '#app/types/api-types.ts'
import { type DBPost } from '#app/types/db-types.ts'
import {
type FallacyList,
FallacyListSchema,
} from '#app/utils/fallacy_detection.ts'
import { invariant } from '#app/utils/misc.tsx'
import { type DB } from '../types/kysely-types.ts'
import { checkIsAdminOrThrow } from '../utils/auth.server.ts'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { z } from 'zod'
import { zfd } from 'zod-form-data'

import { db } from '#app/db.ts'
import { fallacyDetection } from '#app/repositories/fallacy-detection.ts'
import {
getNLatestPlaygroundPosts,
storePlaygroundPost,
} from '#app/repositories/playground-post.ts'
import { fallacyDetection } from '#app/utils/fallacy_detection.ts'

const postDataSchema = zfd.formData({
content: z.coerce.string(),
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { redirect } from '@remix-run/server-runtime'
import { z } from 'zod'
import { zfd } from 'zod-form-data'
import { db } from '#app/db.ts'
import { createPost } from '#app/repositories/post.ts'
import { requireUserId } from '#app/utils/auth.server.ts'

import {
fallacyDetection,
storeFallacies,
} from '#app/utils/fallacy_detection.ts'
} from '#app/repositories/fallacy-detection.ts'
import { createPost } from '#app/repositories/post.ts'
import { requireUserId } from '#app/utils/auth.server.ts'

const postDataSchema = zfd.formData({
content: z.coerce.string(),
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { redirect, type ActionFunctionArgs } from '@remix-run/node'
import invariant from 'tiny-invariant'
import { z } from 'zod'
import { db } from '#app/db.ts'
import { getPost } from '#app/repositories/post.ts'
import { checkIsAdminOrThrow, requireUserId } from '#app/utils/auth.server.ts'
import {
fallacyDetection,
storeFallacies,
} from '#app/utils/fallacy_detection.ts'
} from '#app/repositories/fallacy-detection.ts'
import { getPost } from '#app/repositories/post.ts'
import { checkIsAdminOrThrow, requireUserId } from '#app/utils/auth.server.ts'

const postIdSchema = z.coerce.number()

Expand Down
8 changes: 4 additions & 4 deletions app/routes/reply.tsx → app/routes/_actions+/reply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { type ActionFunctionArgs } from '@remix-run/node'
import invariant from 'tiny-invariant'
import { z } from 'zod'
import { db } from '#app/db.ts'
import { createPost } from '#app/repositories/post.ts'
import { getCommentTreeState, getReplyTree } from '#app/repositories/ranking.ts'
import { requireUserId } from '#app/utils/auth.server.ts'
import {
fallacyDetection,
storeFallacies,
} from '#app/utils/fallacy_detection.ts'
} from '#app/repositories/fallacy-detection.ts'
import { createPost } from '#app/repositories/post.ts'
import { getCommentTreeState, getReplyTree } from '#app/repositories/ranking.ts'
import { requireUserId } from '#app/utils/auth.server.ts'

type ReplyData = {
parentId: number
Expand Down
File renamed without changes.
File renamed without changes.
110 changes: 0 additions & 110 deletions app/routes/activities+/myVotes.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion app/types/api-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as Immutable from 'immutable'
import { type FallacyList } from '#app/utils/fallacy_detection.js'
import { type FallacyList } from '#app/repositories/fallacy-detection.ts'

export type Post = {
id: number
Expand Down

0 comments on commit a1eb343

Please sign in to comment.