[Draft] feat(nostr-feed): Reddit-style link aggregator #9

Open
padreug wants to merge 19 commits from feature/link-aggregator into main
8 changed files with 13 additions and 29 deletions
Showing only changes of commit 4aa18a2705 - Show all commits

View file

@ -6,8 +6,7 @@
import { computed, ref } from 'vue'
import { formatDistanceToNow } from 'date-fns'
import { ChevronUp, ChevronDown, Reply, Flag, MoreHorizontal, Send, X } from 'lucide-vue-next'
import VoteControls from './VoteControls.vue'
import { ChevronUp, ChevronDown, Reply, Flag, MoreHorizontal, Send } from 'lucide-vue-next'
import type { SubmissionComment as CommentType } from '../types/submission'
interface Props {

View file

@ -5,7 +5,7 @@
*/
import { ref, computed, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useRouter } from 'vue-router'
import { formatDistanceToNow } from 'date-fns'
import {
ArrowLeft,
@ -17,9 +17,6 @@ import {
Image as ImageIcon,
FileText,
Loader2,
ChevronUp,
ChevronDown,
Reply,
Send
} from 'lucide-vue-next'
import { Badge } from '@/components/ui/badge'
@ -31,7 +28,6 @@ import { tryInjectService, SERVICE_TOKENS } from '@/core/di-container'
import type { ProfileService } from '../services/ProfileService'
import type { SubmissionService } from '../services/SubmissionService'
import type {
SubmissionWithMeta,
SubmissionComment as SubmissionCommentType,
LinkSubmission,
MediaSubmission,
@ -245,15 +241,6 @@ function toggleCollapse(commentId: string) {
collapsedComments.value = new Set(collapsedComments.value)
}
// Count total replies
function countReplies(comment: SubmissionCommentType): number {
let count = comment.replies?.length || 0
comment.replies?.forEach(reply => {
count += countReplies(reply)
})
return count
}
// Go back
function goBack() {
router.back()

View file

@ -4,7 +4,7 @@
* Includes sort tabs, submission rows, and loading states
*/
import { ref, computed, onMounted, watch } from 'vue'
import { computed, onMounted, watch } from 'vue'
import { Loader2 } from 'lucide-vue-next'
import SortTabs from './SortTabs.vue'
import SubmissionRow from './SubmissionRow.vue'

View file

@ -5,7 +5,7 @@
*/
import { computed } from 'vue'
import { Link, FileText, Image, Film, MessageSquare, ExternalLink } from 'lucide-vue-next'
import { FileText, Image, ExternalLink } from 'lucide-vue-next'
import type { SubmissionType } from '../types/submission'
interface Props {

View file

@ -4,7 +4,7 @@
* Provides reactive access to the SubmissionService for Reddit-style submissions.
*/
import { computed, ref, onMounted, onUnmounted, watch } from 'vue'
import { computed, ref, onMounted, onUnmounted, watch, type Ref, type ComputedRef } from 'vue'
import { tryInjectService, SERVICE_TOKENS } from '@/core/di-container'
import type { SubmissionService } from '../services/SubmissionService'
import type { LinkPreviewService } from '../services/LinkPreviewService'
@ -31,13 +31,13 @@ export interface UseSubmissionsOptions {
export interface UseSubmissionsReturn {
// State
submissions: ReturnType<typeof computed<SubmissionWithMeta[]>>
isLoading: ReturnType<typeof computed<boolean>>
error: ReturnType<typeof computed<string | null>>
submissions: ComputedRef<SubmissionWithMeta[]>
isLoading: ComputedRef<boolean>
error: ComputedRef<string | null>
// Sorting
currentSort: ReturnType<typeof ref<SortType>>
currentTimeRange: ReturnType<typeof ref<TimeRange>>
currentSort: Ref<SortType>
currentTimeRange: Ref<TimeRange>
// Actions
subscribe: (config?: Partial<SubmissionFeedConfig>) => Promise<void>

View file

@ -5,7 +5,7 @@
* Used when creating link submissions to embed preview data.
*/
import { ref, reactive } from 'vue'
import { reactive } from 'vue'
import { BaseService } from '@/core/base/BaseService'
import type { LinkPreview } from '../types/submission'
import { extractDomain } from '../types/submission'

View file

@ -30,7 +30,6 @@ import {
type SubmissionComment,
type LinkPreview,
type MediaAttachment,
type CommunityRef,
parseCommunityRef,
formatCommunityRef,
extractDomain,
@ -505,7 +504,7 @@ export class SubmissionService extends BaseService {
id: event.id,
pubkey: event.pubkey,
created_at: event.created_at,
kind: SUBMISSION_KINDS.SUBMISSION as const,
kind: SUBMISSION_KINDS.SUBMISSION,
tags,
title,
communityRef: this.extractCommunityRef(tags),

View file

@ -5,7 +5,6 @@
* Submissions are kind 1111 events scoped to a community with structured metadata.
*/
import type { Event as NostrEvent } from 'nostr-tools'
// ============================================================================
// Constants
@ -193,7 +192,7 @@ export interface SubmissionRanking {
// ============================================================================
/** Complete submission with all associated data */
export interface SubmissionWithMeta extends Submission {
export type SubmissionWithMeta = Submission & {
/** Vote counts and user state */
votes: SubmissionVotes
/** Ranking scores */