mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 06:34:24 +01:00
fix: resolve all linter errors and type issues
- Remove unused state variables (readsMap, linksMap) by using only setters - Move VALID_FILTERS constant outside component to fix exhaustive-deps warning - Remove unused isReading variable in ReadingProgressIndicator - Remove unused extractUrlFromBookmark function and IndividualBookmark import - Fix type errors in linksFromBookmarks by extracting metadata from tags instead of non-existent properties
This commit is contained in:
@@ -41,6 +41,9 @@ interface MeProps {
|
|||||||
|
|
||||||
type TabType = 'highlights' | 'reading-list' | 'reads' | 'links' | 'writings'
|
type TabType = 'highlights' | 'reading-list' | 'reads' | 'links' | 'writings'
|
||||||
|
|
||||||
|
// Valid reading progress filters
|
||||||
|
const VALID_FILTERS: ReadingProgressFilterType[] = ['all', 'unopened', 'started', 'reading', 'completed']
|
||||||
|
|
||||||
const Me: React.FC<MeProps> = ({ relayPool, activeTab: propActiveTab, pubkey: propPubkey }) => {
|
const Me: React.FC<MeProps> = ({ relayPool, activeTab: propActiveTab, pubkey: propPubkey }) => {
|
||||||
const activeAccount = Hooks.useActiveAccount()
|
const activeAccount = Hooks.useActiveAccount()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
@@ -53,9 +56,9 @@ const Me: React.FC<MeProps> = ({ relayPool, activeTab: propActiveTab, pubkey: pr
|
|||||||
const [highlights, setHighlights] = useState<Highlight[]>([])
|
const [highlights, setHighlights] = useState<Highlight[]>([])
|
||||||
const [bookmarks, setBookmarks] = useState<Bookmark[]>([])
|
const [bookmarks, setBookmarks] = useState<Bookmark[]>([])
|
||||||
const [reads, setReads] = useState<ReadItem[]>([])
|
const [reads, setReads] = useState<ReadItem[]>([])
|
||||||
const [readsMap, setReadsMap] = useState<Map<string, ReadItem>>(new Map())
|
const [, setReadsMap] = useState<Map<string, ReadItem>>(new Map())
|
||||||
const [links, setLinks] = useState<ReadItem[]>([])
|
const [links, setLinks] = useState<ReadItem[]>([])
|
||||||
const [linksMap, setLinksMap] = useState<Map<string, ReadItem>>(new Map())
|
const [, setLinksMap] = useState<Map<string, ReadItem>>(new Map())
|
||||||
const [writings, setWritings] = useState<BlogPostPreview[]>([])
|
const [writings, setWritings] = useState<BlogPostPreview[]>([])
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [loadedTabs, setLoadedTabs] = useState<Set<TabType>>(new Set())
|
const [loadedTabs, setLoadedTabs] = useState<Set<TabType>>(new Set())
|
||||||
@@ -64,8 +67,7 @@ const Me: React.FC<MeProps> = ({ relayPool, activeTab: propActiveTab, pubkey: pr
|
|||||||
const [bookmarkFilter, setBookmarkFilter] = useState<BookmarkFilterType>('all')
|
const [bookmarkFilter, setBookmarkFilter] = useState<BookmarkFilterType>('all')
|
||||||
|
|
||||||
// Initialize reading progress filter from URL param
|
// Initialize reading progress filter from URL param
|
||||||
const validFilters: ReadingProgressFilterType[] = ['all', 'unopened', 'started', 'reading', 'completed']
|
const initialFilter = urlFilter && VALID_FILTERS.includes(urlFilter as ReadingProgressFilterType)
|
||||||
const initialFilter = urlFilter && validFilters.includes(urlFilter as ReadingProgressFilterType)
|
|
||||||
? (urlFilter as ReadingProgressFilterType)
|
? (urlFilter as ReadingProgressFilterType)
|
||||||
: 'all'
|
: 'all'
|
||||||
const [readingProgressFilter, setReadingProgressFilter] = useState<ReadingProgressFilterType>(initialFilter)
|
const [readingProgressFilter, setReadingProgressFilter] = useState<ReadingProgressFilterType>(initialFilter)
|
||||||
@@ -79,7 +81,7 @@ const Me: React.FC<MeProps> = ({ relayPool, activeTab: propActiveTab, pubkey: pr
|
|||||||
|
|
||||||
// Sync filter state with URL changes
|
// Sync filter state with URL changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const filterFromUrl = urlFilter && validFilters.includes(urlFilter as ReadingProgressFilterType)
|
const filterFromUrl = urlFilter && VALID_FILTERS.includes(urlFilter as ReadingProgressFilterType)
|
||||||
? (urlFilter as ReadingProgressFilterType)
|
? (urlFilter as ReadingProgressFilterType)
|
||||||
: 'all'
|
: 'all'
|
||||||
setReadingProgressFilter(filterFromUrl)
|
setReadingProgressFilter(filterFromUrl)
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ export const ReadingProgressIndicator: React.FC<ReadingProgressIndicatorProps> =
|
|||||||
// Determine reading state based on progress (matching readingProgressUtils.ts logic)
|
// Determine reading state based on progress (matching readingProgressUtils.ts logic)
|
||||||
const progressDecimal = clampedProgress / 100
|
const progressDecimal = clampedProgress / 100
|
||||||
const isStarted = progressDecimal > 0 && progressDecimal <= 0.10
|
const isStarted = progressDecimal > 0 && progressDecimal <= 0.10
|
||||||
const isReading = progressDecimal > 0.10 && progressDecimal <= 0.94
|
|
||||||
|
|
||||||
// Determine bar color based on state
|
// Determine bar color based on state
|
||||||
let barColorClass = ''
|
let barColorClass = ''
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { RelayPool } from 'applesauce-relay'
|
import { RelayPool } from 'applesauce-relay'
|
||||||
import { NostrEvent } from 'nostr-tools'
|
import { NostrEvent } from 'nostr-tools'
|
||||||
import { Helpers } from 'applesauce-core'
|
import { Helpers } from 'applesauce-core'
|
||||||
import { Bookmark, IndividualBookmark } from '../types/bookmarks'
|
import { Bookmark } from '../types/bookmarks'
|
||||||
import { fetchReadArticles } from './libraryService'
|
import { fetchReadArticles } from './libraryService'
|
||||||
import { queryEvents } from './dataFetch'
|
import { queryEvents } from './dataFetch'
|
||||||
import { RELAYS } from '../config/relays'
|
import { RELAYS } from '../config/relays'
|
||||||
@@ -195,26 +195,3 @@ export async function fetchAllReads(
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to extract URL from bookmark content
|
|
||||||
function extractUrlFromBookmark(bookmark: IndividualBookmark): string[] {
|
|
||||||
const urls: string[] = []
|
|
||||||
|
|
||||||
// Check for web bookmark (kind 39701) with 'd' tag
|
|
||||||
if (bookmark.kind === 39701) {
|
|
||||||
const dTag = bookmark.tags.find(t => t[0] === 'd')?.[1]
|
|
||||||
if (dTag) {
|
|
||||||
urls.push(dTag.startsWith('http') ? dTag : `https://${dTag}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract URLs from content
|
|
||||||
const urlRegex = /(https?:\/\/[^\s]+)/g
|
|
||||||
const matches = bookmark.content.match(urlRegex)
|
|
||||||
if (matches) {
|
|
||||||
urls.push(...matches)
|
|
||||||
}
|
|
||||||
|
|
||||||
return urls
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,6 @@ export function deriveLinksFromBookmarks(bookmarks: Bookmark[]): ReadItem[] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract URLs from urlReferences (pre-extracted by bookmarkService)
|
|
||||||
if (bookmark.urlReferences && bookmark.urlReferences.length > 0) {
|
|
||||||
urls.push(...bookmark.urlReferences)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract URLs from content if not already captured
|
// Extract URLs from content if not already captured
|
||||||
if (bookmark.content) {
|
if (bookmark.content) {
|
||||||
const urlRegex = /(https?:\/\/[^\s]+)/g
|
const urlRegex = /(https?:\/\/[^\s]+)/g
|
||||||
@@ -39,6 +34,11 @@ export function deriveLinksFromBookmarks(bookmarks: Bookmark[]): ReadItem[] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract metadata from tags (for web bookmarks and other types)
|
||||||
|
const title = bookmark.tags.find(t => t[0] === 'title')?.[1]
|
||||||
|
const summary = bookmark.tags.find(t => t[0] === 'summary')?.[1]
|
||||||
|
const image = bookmark.tags.find(t => t[0] === 'image')?.[1]
|
||||||
|
|
||||||
// Create ReadItem for each unique URL
|
// Create ReadItem for each unique URL
|
||||||
for (const url of [...new Set(urls)]) {
|
for (const url of [...new Set(urls)]) {
|
||||||
if (!linksMap.has(url)) {
|
if (!linksMap.has(url)) {
|
||||||
@@ -47,9 +47,9 @@ export function deriveLinksFromBookmarks(bookmarks: Bookmark[]): ReadItem[] {
|
|||||||
source: 'bookmark',
|
source: 'bookmark',
|
||||||
type: 'external',
|
type: 'external',
|
||||||
url,
|
url,
|
||||||
title: bookmark.title || fallbackTitleFromUrl(url),
|
title: title || fallbackTitleFromUrl(url),
|
||||||
summary: bookmark.summary,
|
summary,
|
||||||
image: bookmark.image,
|
image,
|
||||||
readingProgress: 0,
|
readingProgress: 0,
|
||||||
readingTimestamp: bookmark.added_at || bookmark.created_at
|
readingTimestamp: bookmark.added_at || bookmark.created_at
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user