Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0199c59014 | ||
|
|
44fb63fc59 | ||
|
|
13a28d2dbd | ||
|
|
f87a7da32e | ||
|
|
8fdf9938c2 | ||
|
|
ee4d480961 | ||
|
|
bd866549a0 | ||
|
|
7c39f1d821 | ||
|
|
e6a7bb4c98 | ||
|
|
14cf3189b8 | ||
|
|
66b060627a | ||
|
|
d9bcf14baa | ||
|
|
c571e6ebf7 | ||
|
|
fb06a1aec3 | ||
|
|
5a0d08641b | ||
|
|
8a8419385e | ||
|
|
0d5dc6e785 | ||
|
|
1d90333803 | ||
|
|
91e6e62688 | ||
|
|
619a8a9753 | ||
|
|
0fe38e94d3 | ||
|
|
722e8adbdf | ||
|
|
886d5ac08c | ||
|
|
89d5ba4c37 | ||
|
|
b8b9f82d91 | ||
|
|
b3fc9bb5c3 | ||
|
|
d2ebcd8fbe | ||
|
|
68c9623c35 | ||
|
|
496d1df404 | ||
|
|
ea1046fe13 | ||
|
|
6d58d6e7f3 | ||
|
|
e1420140d1 | ||
|
|
484c2e0c2f | ||
|
|
31f7d53829 | ||
|
|
e3debfa5df | ||
|
|
a1305fba81 | ||
|
|
ca95d6c7f4 | ||
|
|
5513fc9850 | ||
|
|
86de98e644 | ||
|
|
fd374cd705 | ||
|
|
20b4658bef | ||
|
|
0850ba250c | ||
|
|
b71d188fd8 | ||
|
|
579f6b9a96 | ||
|
|
d9403a73c6 | ||
|
|
747811fa94 | ||
|
|
489e480394 | ||
|
|
418bcb0295 | ||
|
|
88f01554e7 | ||
|
|
c85092a644 | ||
|
|
096478bcec | ||
|
|
b8de4a85e0 |
70
CHANGELOG.md
@@ -7,6 +7,74 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.5.0] - 2025-10-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Upgrade to full PWA with `vite-plugin-pwa`
|
||||||
|
- Replace placeholder icons with branded favicons
|
||||||
|
- Author info card for nostr-native articles
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Explore: shrink refresh spinner footprint; inline-sized loading row
|
||||||
|
- Explore: preserve posts across navigations; seed from cache; merge streamed and final results
|
||||||
|
- Explore: keep posts visible during refresh; inline spinner; no list wipe
|
||||||
|
- Bookmarks: keep list visible during refresh; show spinner only; no wipe
|
||||||
|
- Bookmarks: avoid clearing list when no new events; decouple refetch from route changes
|
||||||
|
- Highlights: split service into smaller modules to keep files under 210 lines
|
||||||
|
- Lint/TypeScript: satisfy react-hooks dependencies; fix worker typings; clear ESLint/TS issues
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Highlights: merge remote results after local for article/url
|
||||||
|
- Explore: always query remote relays after local; stream merge into UI
|
||||||
|
- Improve mobile touch targets for highlight icons
|
||||||
|
- Color `/me` highlights with "my highlights" color setting
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
- Local-first then remote follow-up across services (titles, bookmarks, highlights)
|
||||||
|
- Run local and remote fetches concurrently; stream and dedupe results
|
||||||
|
- Stream contacts and early posts from local; merge remote later
|
||||||
|
- Relay queries use local-first with short timeouts; fallback to remote when needed
|
||||||
|
- Stream results to UI; display cached/local immediately (articles, highlights, explore)
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
- PWA implementation summary and launch checklist updates
|
||||||
|
- Update docs to reflect branded icons and final steps
|
||||||
|
- Remove temporary PWA launch checklist and implementation summary
|
||||||
|
|
||||||
|
## [0.4.3] - 2025-10-11
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Mark as read functionality for articles (NIP-25)
|
||||||
|
- Button at the end of each article to mark as read with 📚 emoji
|
||||||
|
- Creates kind:7 reactions for nostr-native articles (`/a/` paths)
|
||||||
|
- Creates kind:17 reactions for external websites (`/r/` paths)
|
||||||
|
- Button shows loading state while publishing reaction
|
||||||
|
- Only visible when user is logged in
|
||||||
|
- Highlight deletion with confirmation dialog (NIP-09)
|
||||||
|
- Small delete button (trash icon) on highlight items
|
||||||
|
- Only visible for user's own highlights
|
||||||
|
- Confirmation dialog prevents accidental deletions
|
||||||
|
- Styled to match relay indicator (subtle, same size)
|
||||||
|
- Removes highlights from UI immediately after deletion request
|
||||||
|
- `/me` page showing user's recent highlights
|
||||||
|
- Accessible by clicking profile picture in bookmark sidebar
|
||||||
|
- Displays all highlights created by the logged-in user
|
||||||
|
- Uses same rendering as Settings and Explore pages
|
||||||
|
- Includes highlight count in header
|
||||||
|
- Confirmation dialog component
|
||||||
|
- Reusable modal with danger/warning/info variants
|
||||||
|
- Backdrop blur effect
|
||||||
|
- Mobile-responsive design
|
||||||
|
- Prevents accidental destructive actions
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Relay status indicator on mobile now displays in compact mode
|
||||||
|
- Shows only airplane icon by default (44x44px touch target)
|
||||||
|
- Tap to expand for full connection details
|
||||||
|
- Reduces screen clutter on mobile while keeping info accessible
|
||||||
|
- Smooth transition between compact and expanded states
|
||||||
|
- Desktop view remains unchanged (always shows full details)
|
||||||
|
|
||||||
## [0.4.2] - 2025-10-11
|
## [0.4.2] - 2025-10-11
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -624,6 +692,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Optimize relay usage following applesauce-relay best practices
|
- Optimize relay usage following applesauce-relay best practices
|
||||||
- Use applesauce-react event models for better profile handling
|
- Use applesauce-react event models for better profile handling
|
||||||
|
|
||||||
|
[Unreleased]: https://github.com/dergigi/boris/compare/v0.5.0...HEAD
|
||||||
|
[0.5.0]: https://github.com/dergigi/boris/compare/v0.4.3...v0.5.0
|
||||||
[0.4.0]: https://github.com/dergigi/boris/compare/v0.3.8...v0.4.0
|
[0.4.0]: https://github.com/dergigi/boris/compare/v0.3.8...v0.4.0
|
||||||
[0.3.8]: https://github.com/dergigi/boris/compare/v0.3.7...v0.3.8
|
[0.3.8]: https://github.com/dergigi/boris/compare/v0.3.7...v0.3.8
|
||||||
[0.3.7]: https://github.com/dergigi/boris/compare/v0.3.6...v0.3.7
|
[0.3.7]: https://github.com/dergigi/boris/compare/v0.3.6...v0.3.7
|
||||||
|
|||||||
@@ -1,156 +0,0 @@
|
|||||||
# Mobile Implementation Summary
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
Boris is now mobile-friendly! The app now works seamlessly on mobile devices with a responsive design that includes:
|
|
||||||
- Auto-collapsing sidebar that opens as an overlay drawer on small screens
|
|
||||||
- Touch-optimized UI with proper touch target sizes (44x44px minimum)
|
|
||||||
- Safe area insets for notched devices (iPhone X+, etc.)
|
|
||||||
- Focus trap and keyboard navigation in the mobile sidebar
|
|
||||||
- Mobile-optimized modals, toasts, and other UI elements
|
|
||||||
|
|
||||||
## Changes Made
|
|
||||||
|
|
||||||
### 1. Viewport & Base Setup
|
|
||||||
**File: `index.html`**
|
|
||||||
- Updated viewport meta tag to include `viewport-fit=cover` for proper safe area handling
|
|
||||||
|
|
||||||
### 2. Media Query Hooks
|
|
||||||
**File: `src/hooks/useMediaQuery.ts` (NEW)**
|
|
||||||
- `useMediaQuery(query)` - Generic hook for any media query
|
|
||||||
- `useIsMobile()` - Detects mobile viewport (≤768px)
|
|
||||||
- `useIsTablet()` - Detects tablet viewport (≤1024px)
|
|
||||||
- `useIsCoarsePointer()` - Detects touch devices
|
|
||||||
|
|
||||||
### 3. Mobile CSS Styles
|
|
||||||
**File: `src/index.css`**
|
|
||||||
- Added CSS custom properties for mobile breakpoints and safe areas
|
|
||||||
- Mobile-specific three-pane layout that stacks into single column
|
|
||||||
- Overlay sidebar with backdrop and transitions
|
|
||||||
- Touch target improvements (44x44px minimum)
|
|
||||||
- Disabled hover effects on touch devices
|
|
||||||
- Mobile-optimized modals (full-screen sheet style)
|
|
||||||
- Mobile-optimized toasts (bottom position with safe area)
|
|
||||||
- Dynamic viewport height support (`100dvh`)
|
|
||||||
- Overscroll behavior and body scroll locking
|
|
||||||
|
|
||||||
### 4. Sidebar State Management
|
|
||||||
**File: `src/hooks/useBookmarksUI.ts`**
|
|
||||||
- Added `isMobile` state from media query
|
|
||||||
- Added `isSidebarOpen` state for mobile overlay
|
|
||||||
- Added `toggleSidebar()` function
|
|
||||||
- Auto-collapse logic based on `autoCollapseSidebarOnMobile` setting
|
|
||||||
- Mobile sidebar defaults to closed, desktop defaults to open
|
|
||||||
|
|
||||||
### 5. Three-Pane Layout Mobile Support
|
|
||||||
**File: `src/components/ThreePaneLayout.tsx`**
|
|
||||||
- Mobile hamburger button (visible only on mobile)
|
|
||||||
- Mobile backdrop for closing sidebar
|
|
||||||
- Body scroll locking when sidebar is open
|
|
||||||
- ESC key handler to close sidebar
|
|
||||||
- Focus trap in sidebar (Tab navigation stays within sidebar)
|
|
||||||
- Focus restoration when closing sidebar
|
|
||||||
- Accessibility attributes (`aria-hidden`, `aria-expanded`, etc.)
|
|
||||||
|
|
||||||
### 6. Sidebar Header Mobile Controls
|
|
||||||
**File: `src/components/SidebarHeader.tsx`**
|
|
||||||
- Close button (X) visible on mobile instead of collapse chevron
|
|
||||||
- Hamburger button hidden in header (shown in layout instead)
|
|
||||||
|
|
||||||
### 7. Bookmark List Mobile Props
|
|
||||||
**File: `src/components/BookmarkList.tsx`**
|
|
||||||
- Added `isMobile` prop support
|
|
||||||
- Passes mobile state to SidebarHeader
|
|
||||||
|
|
||||||
### 8. Main Bookmarks Component
|
|
||||||
**File: `src/components/Bookmarks.tsx`**
|
|
||||||
- Uses mobile state from `useBookmarksUI`
|
|
||||||
- Auto-closes sidebar when selecting bookmark on mobile
|
|
||||||
- Closes sidebar when opening settings on mobile
|
|
||||||
- Proper desktop/mobile toggle behavior
|
|
||||||
|
|
||||||
### 9. Icon Button Enhancement
|
|
||||||
**File: `src/components/IconButton.tsx`**
|
|
||||||
- Added optional `className` prop for additional styling
|
|
||||||
|
|
||||||
### 10. Mobile Settings
|
|
||||||
**File: `src/services/settingsService.ts`**
|
|
||||||
- Added `autoCollapseSidebarOnMobile?: boolean` setting (default: true)
|
|
||||||
|
|
||||||
**File: `src/components/Settings/StartupPreferencesSettings.tsx`**
|
|
||||||
- Added UI toggle for "Auto-collapse sidebar on small screens"
|
|
||||||
|
|
||||||
## Accessibility Features
|
|
||||||
- Focus trap in mobile sidebar (Tab key navigation stays within drawer)
|
|
||||||
- ESC key closes mobile sidebar
|
|
||||||
- Backdrop click closes mobile sidebar
|
|
||||||
- Proper ARIA attributes (`aria-hidden`, `aria-expanded`, `aria-controls`)
|
|
||||||
- Touch target minimum size enforcement (44x44px)
|
|
||||||
- Focus restoration when closing sidebar
|
|
||||||
|
|
||||||
## Mobile Behaviors
|
|
||||||
1. **Sidebar**: Slides in from left as overlay drawer with backdrop
|
|
||||||
2. **Hamburger Menu**: Fixed position top-left when sidebar closed
|
|
||||||
3. **Selecting Content**: Auto-closes sidebar on mobile
|
|
||||||
4. **Opening Settings**: Auto-closes sidebar on mobile
|
|
||||||
5. **Highlights Panel**: Hidden on mobile (content takes full width)
|
|
||||||
6. **Modals**: Full-screen sheet style from bottom
|
|
||||||
7. **Toasts**: Bottom position with safe area padding
|
|
||||||
|
|
||||||
## Responsive Breakpoints
|
|
||||||
- **Mobile**: ≤768px (sidebar overlay, single column)
|
|
||||||
- **Tablet**: ≤1024px (defined but not actively used yet)
|
|
||||||
- **Desktop**: >768px (three-pane layout as before)
|
|
||||||
|
|
||||||
## Browser Support
|
|
||||||
- Modern browsers with CSS Grid support
|
|
||||||
- iOS Safari (including safe area insets)
|
|
||||||
- Chrome for Android
|
|
||||||
- Firefox Mobile
|
|
||||||
- Safari on iPadOS
|
|
||||||
|
|
||||||
## Safe Area Support
|
|
||||||
The app respects device safe areas (notches, home indicators) through CSS environment variables:
|
|
||||||
- `env(safe-area-inset-top)`
|
|
||||||
- `env(safe-area-inset-bottom)`
|
|
||||||
- `env(safe-area-inset-left)`
|
|
||||||
- `env(safe-area-inset-right)`
|
|
||||||
|
|
||||||
## Future Enhancements
|
|
||||||
Potential improvements for future iterations:
|
|
||||||
- Swipe gesture to open/close sidebar
|
|
||||||
- Pull-to-refresh on mobile
|
|
||||||
- Bottom sheet for highlights panel on mobile
|
|
||||||
- Optimized font sizes for mobile reading
|
|
||||||
- Mobile-specific view mode (perhaps auto-switch to compact on mobile)
|
|
||||||
- Haptic feedback on interactions (iOS/Android)
|
|
||||||
- Share sheet integration
|
|
||||||
- Install prompt for PWA
|
|
||||||
|
|
||||||
## Testing Checklist
|
|
||||||
- [x] Sidebar opens/closes on mobile
|
|
||||||
- [x] Hamburger button visible on mobile
|
|
||||||
- [x] Backdrop closes sidebar
|
|
||||||
- [x] ESC key closes sidebar
|
|
||||||
- [x] Focus trap works in sidebar
|
|
||||||
- [x] Selecting bookmark closes sidebar
|
|
||||||
- [x] No horizontal scroll
|
|
||||||
- [x] Touch targets ≥ 44px
|
|
||||||
- [x] Modals are full-screen on mobile
|
|
||||||
- [x] Toasts appear at bottom with safe area
|
|
||||||
- [x] Build completes without errors
|
|
||||||
- [ ] Test on actual iOS device (iPhone)
|
|
||||||
- [ ] Test on actual Android device
|
|
||||||
- [ ] Test with keyboard navigation
|
|
||||||
- [ ] Test with screen reader
|
|
||||||
- [ ] Test landscape orientation
|
|
||||||
- [ ] Test on various screen sizes (320px, 375px, 414px, 768px)
|
|
||||||
|
|
||||||
## Commit History
|
|
||||||
1. `feat: update viewport meta for mobile support`
|
|
||||||
2. `feat: add media query hooks for responsive design`
|
|
||||||
3. `feat: add mobile sidebar state management to useBookmarksUI`
|
|
||||||
4. `feat: add mobile-responsive CSS with breakpoints and safe areas`
|
|
||||||
5. `feat: implement mobile overlay sidebar with focus trap and ESC handling`
|
|
||||||
6. `feat: add mobile auto-collapse setting`
|
|
||||||
7. `fix: resolve TypeScript errors for mobile implementation`
|
|
||||||
|
|
||||||
@@ -2,8 +2,13 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
||||||
|
<meta name="theme-color" content="#0f172a" />
|
||||||
|
<link rel="manifest" href="/manifest.webmanifest" />
|
||||||
<title>Boris - Nostr Bookmarks</title>
|
<title>Boris - Nostr Bookmarks</title>
|
||||||
<meta name="description" content="Your reading list for the Nostr world. A minimal nostr client for bookmark management with highlights." />
|
<meta name="description" content="Your reading list for the Nostr world. A minimal nostr client for bookmark management with highlights." />
|
||||||
<link rel="canonical" href="https://read.withboris.com/" />
|
<link rel="canonical" href="https://read.withboris.com/" />
|
||||||
|
|||||||
4181
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "boris",
|
"name": "boris",
|
||||||
"version": "0.4.3",
|
"version": "0.5.2",
|
||||||
"description": "A minimal nostr client for bookmark management",
|
"description": "A minimal nostr client for bookmark management",
|
||||||
"homepage": "https://read.withboris.com/",
|
"homepage": "https://read.withboris.com/",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -40,7 +40,9 @@
|
|||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.5",
|
"eslint-plugin-react-refresh": "^0.4.5",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "^5.2.2",
|
||||||
"vite": "^5.0.8"
|
"vite": "^5.0.8",
|
||||||
|
"vite-plugin-pwa": "^1.0.3",
|
||||||
|
"workbox-window": "^7.3.0"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
BIN
public/apple-touch-icon.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
public/favicon-16x16.png
Normal file
|
After Width: | Height: | Size: 465 B |
BIN
public/favicon-32x32.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
public/icon-192.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
public/icon-512.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
public/icon-maskable-192.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
public/icon-maskable-512.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
37
public/manifest.webmanifest
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"name": "Boris - Nostr Bookmarks",
|
||||||
|
"short_name": "Boris",
|
||||||
|
"description": "Your reading list for the Nostr world. A minimal nostr client for bookmark management with highlights.",
|
||||||
|
"start_url": "/",
|
||||||
|
"scope": "/",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#0f172a",
|
||||||
|
"background_color": "#0b1220",
|
||||||
|
"orientation": "any",
|
||||||
|
"categories": ["productivity", "social", "utilities"],
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/icon-192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/icon-512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/icon-maskable-192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/icon-maskable-512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
56
public/sw.js
@@ -1,56 +0,0 @@
|
|||||||
// Service Worker for Boris - handles offline image caching
|
|
||||||
const CACHE_NAME = 'boris-image-cache-v1'
|
|
||||||
|
|
||||||
// Install event - activate immediately
|
|
||||||
self.addEventListener('install', (event) => {
|
|
||||||
console.log('[SW] Installing service worker...')
|
|
||||||
self.skipWaiting()
|
|
||||||
})
|
|
||||||
|
|
||||||
// Activate event - take control immediately
|
|
||||||
self.addEventListener('activate', (event) => {
|
|
||||||
console.log('[SW] Activating service worker...')
|
|
||||||
event.waitUntil(self.clients.claim())
|
|
||||||
})
|
|
||||||
|
|
||||||
// Fetch event - intercept image requests
|
|
||||||
self.addEventListener('fetch', (event) => {
|
|
||||||
const url = new URL(event.request.url)
|
|
||||||
|
|
||||||
// Only intercept image requests
|
|
||||||
const isImage = event.request.destination === 'image' ||
|
|
||||||
/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(url.pathname)
|
|
||||||
|
|
||||||
if (!isImage) {
|
|
||||||
return // Let other requests pass through
|
|
||||||
}
|
|
||||||
|
|
||||||
event.respondWith(
|
|
||||||
caches.open(CACHE_NAME).then(cache => {
|
|
||||||
return cache.match(event.request).then(cachedResponse => {
|
|
||||||
if (cachedResponse) {
|
|
||||||
console.log('[SW] Serving cached image:', url.pathname)
|
|
||||||
return cachedResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not in cache, try to fetch
|
|
||||||
return fetch(event.request)
|
|
||||||
.then(response => {
|
|
||||||
// Only cache successful responses
|
|
||||||
if (response && response.status === 200) {
|
|
||||||
// Clone the response before caching
|
|
||||||
cache.put(event.request, response.clone())
|
|
||||||
console.log('[SW] Cached new image:', url.pathname)
|
|
||||||
}
|
|
||||||
return response
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('[SW] Fetch failed for:', url.pathname, error)
|
|
||||||
// Return a fallback or let it fail
|
|
||||||
throw error
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
21
src/App.tsx
@@ -11,6 +11,7 @@ import { createAddressLoader } from 'applesauce-loaders/loaders'
|
|||||||
import Bookmarks from './components/Bookmarks'
|
import Bookmarks from './components/Bookmarks'
|
||||||
import Toast from './components/Toast'
|
import Toast from './components/Toast'
|
||||||
import { useToast } from './hooks/useToast'
|
import { useToast } from './hooks/useToast'
|
||||||
|
import { useOnlineStatus } from './hooks/useOnlineStatus'
|
||||||
import { RELAYS } from './config/relays'
|
import { RELAYS } from './config/relays'
|
||||||
|
|
||||||
const DEFAULT_ARTICLE = import.meta.env.VITE_DEFAULT_ARTICLE_NADDR ||
|
const DEFAULT_ARTICLE = import.meta.env.VITE_DEFAULT_ARTICLE_NADDR ||
|
||||||
@@ -88,6 +89,7 @@ function App() {
|
|||||||
const [accountManager, setAccountManager] = useState<AccountManager | null>(null)
|
const [accountManager, setAccountManager] = useState<AccountManager | null>(null)
|
||||||
const [relayPool, setRelayPool] = useState<RelayPool | null>(null)
|
const [relayPool, setRelayPool] = useState<RelayPool | null>(null)
|
||||||
const { toastMessage, toastType, showToast, clearToast } = useToast()
|
const { toastMessage, toastType, showToast, clearToast } = useToast()
|
||||||
|
const isOnline = useOnlineStatus()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const initializeApp = async () => {
|
const initializeApp = async () => {
|
||||||
@@ -183,6 +185,25 @@ function App() {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
// Monitor online/offline status
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isOnline) {
|
||||||
|
showToast('You are offline. Some features may be limited.')
|
||||||
|
}
|
||||||
|
}, [isOnline, showToast])
|
||||||
|
|
||||||
|
// Listen for service worker updates
|
||||||
|
useEffect(() => {
|
||||||
|
const handleSWUpdate = () => {
|
||||||
|
showToast('New version available! Refresh to update.')
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('sw-update-available', handleSWUpdate)
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('sw-update-available', handleSWUpdate)
|
||||||
|
}
|
||||||
|
}, [showToast])
|
||||||
|
|
||||||
if (!eventStore || !accountManager || !relayPool) {
|
if (!eventStore || !accountManager || !relayPool) {
|
||||||
return (
|
return (
|
||||||
<div className="loading">
|
<div className="loading">
|
||||||
|
|||||||
43
src/components/AuthorCard.tsx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
|
import { faUserCircle } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { useEventModel } from 'applesauce-react/hooks'
|
||||||
|
import { Models } from 'applesauce-core'
|
||||||
|
|
||||||
|
interface AuthorCardProps {
|
||||||
|
authorPubkey: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const AuthorCard: React.FC<AuthorCardProps> = ({ authorPubkey }) => {
|
||||||
|
const profile = useEventModel(Models.ProfileModel, [authorPubkey])
|
||||||
|
|
||||||
|
const getAuthorName = () => {
|
||||||
|
if (profile?.name) return profile.name
|
||||||
|
if (profile?.display_name) return profile.display_name
|
||||||
|
return `${authorPubkey.slice(0, 8)}...${authorPubkey.slice(-8)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const authorImage = profile?.picture || profile?.image
|
||||||
|
const authorBio = profile?.about
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="author-card">
|
||||||
|
<div className="author-card-avatar">
|
||||||
|
{authorImage ? (
|
||||||
|
<img src={authorImage} alt={getAuthorName()} />
|
||||||
|
) : (
|
||||||
|
<FontAwesomeIcon icon={faUserCircle} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="author-card-content">
|
||||||
|
<div className="author-card-name">{getAuthorName()}</div>
|
||||||
|
{authorBio && (
|
||||||
|
<p className="author-card-bio">{authorBio}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AuthorCard
|
||||||
|
|
||||||
@@ -111,16 +111,18 @@ export const BookmarkList: React.FC<BookmarkListProps> = ({
|
|||||||
isMobile={isMobile}
|
isMobile={isMobile}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{loading ? (
|
{allIndividualBookmarks.length === 0 ? (
|
||||||
<div className="loading">
|
loading ? (
|
||||||
<FontAwesomeIcon icon={faSpinner} spin />
|
<div className="loading">
|
||||||
</div>
|
<FontAwesomeIcon icon={faSpinner} spin />
|
||||||
) : allIndividualBookmarks.length === 0 ? (
|
</div>
|
||||||
<div className="empty-state">
|
) : (
|
||||||
<p>No bookmarks found.</p>
|
<div className="empty-state">
|
||||||
<p>Add bookmarks using your nostr client to see them here.</p>
|
<p>No bookmarks found.</p>
|
||||||
<p>If you aren't on nostr yet, start here: <a href="https://nstart.me/" target="_blank" rel="noopener noreferrer">nstart.me</a></p>
|
<p>Add bookmarks using your nostr client to see them here.</p>
|
||||||
</div>
|
<p>If you aren't on nostr yet, start here: <a href="https://nstart.me/" target="_blank" rel="noopener noreferrer">nstart.me</a></p>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<div className="bookmarks-list">
|
<div className="bookmarks-list">
|
||||||
<div className={`bookmarks-grid bookmarks-${viewMode}`}>
|
<div className={`bookmarks-grid bookmarks-${viewMode}`}>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { classifyUrl } from '../../utils/helpers'
|
|||||||
import { IconGetter } from './shared'
|
import { IconGetter } from './shared'
|
||||||
import { useImageCache } from '../../hooks/useImageCache'
|
import { useImageCache } from '../../hooks/useImageCache'
|
||||||
import { UserSettings } from '../../services/settingsService'
|
import { UserSettings } from '../../services/settingsService'
|
||||||
|
import { getProfileUrl, getEventUrl } from '../../config/nostrGateways'
|
||||||
|
|
||||||
interface CardViewProps {
|
interface CardViewProps {
|
||||||
bookmark: IndividualBookmark
|
bookmark: IndividualBookmark
|
||||||
@@ -79,7 +80,7 @@ export const CardView: React.FC<CardViewProps> = ({
|
|||||||
|
|
||||||
{eventNevent ? (
|
{eventNevent ? (
|
||||||
<a
|
<a
|
||||||
href={`https://search.dergigi.com/e/${eventNevent}`}
|
href={getEventUrl(eventNevent)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="bookmark-date-link"
|
className="bookmark-date-link"
|
||||||
@@ -159,7 +160,7 @@ export const CardView: React.FC<CardViewProps> = ({
|
|||||||
<div className="bookmark-footer">
|
<div className="bookmark-footer">
|
||||||
<div className="bookmark-meta-minimal">
|
<div className="bookmark-meta-minimal">
|
||||||
<a
|
<a
|
||||||
href={`https://search.dergigi.com/p/${authorNpub}`}
|
href={getProfileUrl(authorNpub)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="author-link-minimal"
|
className="author-link-minimal"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import ContentWithResolvedProfiles from '../ContentWithResolvedProfiles'
|
|||||||
import { IconGetter } from './shared'
|
import { IconGetter } from './shared'
|
||||||
import { useImageCache } from '../../hooks/useImageCache'
|
import { useImageCache } from '../../hooks/useImageCache'
|
||||||
import { UserSettings } from '../../services/settingsService'
|
import { UserSettings } from '../../services/settingsService'
|
||||||
|
import { getProfileUrl, getEventUrl } from '../../config/nostrGateways'
|
||||||
|
|
||||||
interface LargeViewProps {
|
interface LargeViewProps {
|
||||||
bookmark: IndividualBookmark
|
bookmark: IndividualBookmark
|
||||||
@@ -79,7 +80,7 @@ export const LargeView: React.FC<LargeViewProps> = ({
|
|||||||
<div className="large-footer">
|
<div className="large-footer">
|
||||||
<span className="large-author">
|
<span className="large-author">
|
||||||
<a
|
<a
|
||||||
href={`https://search.dergigi.com/p/${authorNpub}`}
|
href={getProfileUrl(authorNpub)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="author-link-minimal"
|
className="author-link-minimal"
|
||||||
@@ -90,7 +91,7 @@ export const LargeView: React.FC<LargeViewProps> = ({
|
|||||||
|
|
||||||
{eventNevent && (
|
{eventNevent && (
|
||||||
<a
|
<a
|
||||||
href={`https://search.dergigi.com/e/${eventNevent}`}
|
href={getEventUrl(eventNevent)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="bookmark-date-link"
|
className="bookmark-date-link"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { useHighlightedContent } from '../hooks/useHighlightedContent'
|
|||||||
import { useHighlightInteractions } from '../hooks/useHighlightInteractions'
|
import { useHighlightInteractions } from '../hooks/useHighlightInteractions'
|
||||||
import { UserSettings } from '../services/settingsService'
|
import { UserSettings } from '../services/settingsService'
|
||||||
import { createEventReaction, createWebsiteReaction } from '../services/reactionService'
|
import { createEventReaction, createWebsiteReaction } from '../services/reactionService'
|
||||||
|
import AuthorCard from './AuthorCard'
|
||||||
|
|
||||||
interface ContentPanelProps {
|
interface ContentPanelProps {
|
||||||
loading: boolean
|
loading: boolean
|
||||||
@@ -179,6 +180,8 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
|||||||
hasHighlights={hasHighlights}
|
hasHighlights={hasHighlights}
|
||||||
highlightCount={relevantHighlights.length}
|
highlightCount={relevantHighlights.length}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
|
highlights={relevantHighlights}
|
||||||
|
highlightVisibility={highlightVisibility}
|
||||||
/>
|
/>
|
||||||
{markdown || html ? (
|
{markdown || html ? (
|
||||||
<>
|
<>
|
||||||
@@ -222,6 +225,13 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Author info card for nostr-native articles */}
|
||||||
|
{isNostrArticle && currentArticle && (
|
||||||
|
<div className="author-card-container">
|
||||||
|
<AuthorCard authorPubkey={currentArticle.pubkey} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div className="reader empty">
|
<div className="reader empty">
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { nip19 } from 'nostr-tools'
|
|||||||
import { fetchContacts } from '../services/contactService'
|
import { fetchContacts } from '../services/contactService'
|
||||||
import { fetchBlogPostsFromAuthors, BlogPostPreview } from '../services/exploreService'
|
import { fetchBlogPostsFromAuthors, BlogPostPreview } from '../services/exploreService'
|
||||||
import BlogPostCard from './BlogPostCard'
|
import BlogPostCard from './BlogPostCard'
|
||||||
|
import { getCachedPosts, upsertCachedPost, setCachedPosts } from '../services/exploreCache'
|
||||||
|
|
||||||
interface ExploreProps {
|
interface ExploreProps {
|
||||||
relayPool: RelayPool
|
relayPool: RelayPool
|
||||||
@@ -27,11 +28,59 @@ const Explore: React.FC<ExploreProps> = ({ relayPool }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// show spinner but keep existing posts
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
setError(null)
|
setError(null)
|
||||||
|
|
||||||
|
// Seed from in-memory cache if available to avoid empty flash
|
||||||
|
const cached = getCachedPosts(activeAccount.pubkey)
|
||||||
|
if (cached && cached.length > 0 && blogPosts.length === 0) {
|
||||||
|
setBlogPosts(cached)
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch the user's contacts (friends)
|
// Fetch the user's contacts (friends)
|
||||||
const contacts = await fetchContacts(relayPool, activeAccount.pubkey)
|
const contacts = await fetchContacts(
|
||||||
|
relayPool,
|
||||||
|
activeAccount.pubkey,
|
||||||
|
(partial) => {
|
||||||
|
// When local contacts are available, kick off early posts fetch
|
||||||
|
if (partial.size > 0) {
|
||||||
|
const relayUrls = Array.from(relayPool.relays.values()).map(relay => relay.url)
|
||||||
|
fetchBlogPostsFromAuthors(
|
||||||
|
relayPool,
|
||||||
|
Array.from(partial),
|
||||||
|
relayUrls,
|
||||||
|
(post) => {
|
||||||
|
// merge into UI and cache as we stream
|
||||||
|
setBlogPosts((prev) => {
|
||||||
|
const exists = prev.some(p => p.event.id === post.event.id)
|
||||||
|
if (exists) return prev
|
||||||
|
const next = [...prev, post]
|
||||||
|
return next.sort((a, b) => {
|
||||||
|
const timeA = a.published || a.event.created_at
|
||||||
|
const timeB = b.published || b.event.created_at
|
||||||
|
return timeB - timeA
|
||||||
|
})
|
||||||
|
})
|
||||||
|
setCachedPosts(activeAccount.pubkey, upsertCachedPost(activeAccount.pubkey, post))
|
||||||
|
}
|
||||||
|
).then((all) => {
|
||||||
|
// Ensure union of streamed + final is displayed
|
||||||
|
setBlogPosts((prev) => {
|
||||||
|
const byId = new Map(prev.map(p => [p.event.id, p]))
|
||||||
|
for (const post of all) byId.set(post.event.id, post)
|
||||||
|
const merged = Array.from(byId.values()).sort((a, b) => {
|
||||||
|
const timeA = a.published || a.event.created_at
|
||||||
|
const timeB = b.published || b.event.created_at
|
||||||
|
return timeB - timeA
|
||||||
|
})
|
||||||
|
setCachedPosts(activeAccount.pubkey, merged)
|
||||||
|
return merged
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if (contacts.size === 0) {
|
if (contacts.size === 0) {
|
||||||
setError('You are not following anyone yet. Follow some people to see their blog posts!')
|
setError('You are not following anyone yet. Follow some people to see their blog posts!')
|
||||||
@@ -39,21 +88,25 @@ const Explore: React.FC<ExploreProps> = ({ relayPool }) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get relay URLs from pool
|
// After full contacts, do a final pass for completeness
|
||||||
const relayUrls = Array.from(relayPool.relays.values()).map(relay => relay.url)
|
const relayUrls = Array.from(relayPool.relays.values()).map(relay => relay.url)
|
||||||
|
const posts = await fetchBlogPostsFromAuthors(relayPool, Array.from(contacts), relayUrls)
|
||||||
// Fetch blog posts from friends
|
|
||||||
const posts = await fetchBlogPostsFromAuthors(
|
|
||||||
relayPool,
|
|
||||||
Array.from(contacts),
|
|
||||||
relayUrls
|
|
||||||
)
|
|
||||||
|
|
||||||
if (posts.length === 0) {
|
if (posts.length === 0) {
|
||||||
setError('No blog posts found from your friends yet')
|
setError('No blog posts found from your friends yet')
|
||||||
}
|
}
|
||||||
|
|
||||||
setBlogPosts(posts)
|
setBlogPosts((prev) => {
|
||||||
|
const byId = new Map(prev.map(p => [p.event.id, p]))
|
||||||
|
for (const post of posts) byId.set(post.event.id, post)
|
||||||
|
const merged = Array.from(byId.values()).sort((a, b) => {
|
||||||
|
const timeA = a.published || a.event.created_at
|
||||||
|
const timeB = b.published || b.event.created_at
|
||||||
|
return timeB - timeA
|
||||||
|
})
|
||||||
|
setCachedPosts(activeAccount.pubkey, merged)
|
||||||
|
return merged
|
||||||
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to load blog posts:', err)
|
console.error('Failed to load blog posts:', err)
|
||||||
setError('Failed to load blog posts. Please try again.')
|
setError('Failed to load blog posts. Please try again.')
|
||||||
@@ -63,7 +116,7 @@ const Explore: React.FC<ExploreProps> = ({ relayPool }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadBlogPosts()
|
loadBlogPosts()
|
||||||
}, [relayPool, activeAccount])
|
}, [relayPool, activeAccount, blogPosts.length])
|
||||||
|
|
||||||
const getPostUrl = (post: BlogPostPreview) => {
|
const getPostUrl = (post: BlogPostPreview) => {
|
||||||
// Get the d-tag identifier
|
// Get the d-tag identifier
|
||||||
@@ -79,17 +132,6 @@ const Explore: React.FC<ExploreProps> = ({ relayPool }) => {
|
|||||||
return `/a/${naddr}`
|
return `/a/${naddr}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
return (
|
|
||||||
<div className="explore-container">
|
|
||||||
<div className="explore-loading">
|
|
||||||
<FontAwesomeIcon icon={faSpinner} spin size="2x" />
|
|
||||||
<p>Loading blog posts from your friends...</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
<div className="explore-container">
|
<div className="explore-container">
|
||||||
@@ -112,6 +154,11 @@ const Explore: React.FC<ExploreProps> = ({ relayPool }) => {
|
|||||||
Discover blog posts from your friends on Nostr
|
Discover blog posts from your friends on Nostr
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
{loading && (
|
||||||
|
<div className="explore-loading" style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', padding: '0.5rem 0' }}>
|
||||||
|
<FontAwesomeIcon icon={faSpinner} spin />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="explore-grid">
|
<div className="explore-grid">
|
||||||
{blogPosts.map((post) => (
|
{blogPosts.map((post) => (
|
||||||
<BlogPostCard
|
<BlogPostCard
|
||||||
@@ -120,6 +167,11 @@ const Explore: React.FC<ExploreProps> = ({ relayPool }) => {
|
|||||||
href={getPostUrl(post)}
|
href={getPostUrl(post)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
{!loading && blogPosts.length === 0 && (
|
||||||
|
<div className="explore-empty" style={{ gridColumn: '1/-1', textAlign: 'center', color: 'var(--text-secondary)' }}>
|
||||||
|
<p>No blog posts found yet.</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
import { faQuoteLeft, faExternalLinkAlt, faPlane, faSpinner, faServer, faTrash } from '@fortawesome/free-solid-svg-icons'
|
import { faQuoteLeft, faExternalLinkAlt, faPlane, faSpinner, faServer, faTrash, faEllipsisH } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { Highlight } from '../types/highlights'
|
import { Highlight } from '../types/highlights'
|
||||||
import { useEventModel } from 'applesauce-react/hooks'
|
import { useEventModel } from 'applesauce-react/hooks'
|
||||||
import { Models, IEventStore } from 'applesauce-core'
|
import { Models, IEventStore } from 'applesauce-core'
|
||||||
@@ -13,6 +13,7 @@ import { nip19 } from 'nostr-tools'
|
|||||||
import { formatDateCompact } from '../utils/bookmarkUtils'
|
import { formatDateCompact } from '../utils/bookmarkUtils'
|
||||||
import { createDeletionRequest } from '../services/deletionService'
|
import { createDeletionRequest } from '../services/deletionService'
|
||||||
import ConfirmDialog from './ConfirmDialog'
|
import ConfirmDialog from './ConfirmDialog'
|
||||||
|
import { getNostrUrl } from '../config/nostrGateways'
|
||||||
|
|
||||||
interface HighlightWithLevel extends Highlight {
|
interface HighlightWithLevel extends Highlight {
|
||||||
level?: 'mine' | 'friends' | 'nostrverse'
|
level?: 'mine' | 'friends' | 'nostrverse'
|
||||||
@@ -31,7 +32,7 @@ interface HighlightItemProps {
|
|||||||
|
|
||||||
export const HighlightItem: React.FC<HighlightItemProps> = ({
|
export const HighlightItem: React.FC<HighlightItemProps> = ({
|
||||||
highlight,
|
highlight,
|
||||||
onSelectUrl,
|
// onSelectUrl is not used but kept in props for API compatibility
|
||||||
isSelected,
|
isSelected,
|
||||||
onHighlightClick,
|
onHighlightClick,
|
||||||
relayPool,
|
relayPool,
|
||||||
@@ -40,11 +41,13 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
|||||||
onHighlightDelete
|
onHighlightDelete
|
||||||
}) => {
|
}) => {
|
||||||
const itemRef = useRef<HTMLDivElement>(null)
|
const itemRef = useRef<HTMLDivElement>(null)
|
||||||
|
const menuRef = useRef<HTMLDivElement>(null)
|
||||||
const [isSyncing, setIsSyncing] = useState(() => isEventSyncing(highlight.id))
|
const [isSyncing, setIsSyncing] = useState(() => isEventSyncing(highlight.id))
|
||||||
const [showOfflineIndicator, setShowOfflineIndicator] = useState(() => highlight.isOfflineCreated && !isSyncing)
|
const [showOfflineIndicator, setShowOfflineIndicator] = useState(() => highlight.isOfflineCreated && !isSyncing)
|
||||||
const [isRebroadcasting, setIsRebroadcasting] = useState(false)
|
const [isRebroadcasting, setIsRebroadcasting] = useState(false)
|
||||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false)
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false)
|
||||||
const [isDeleting, setIsDeleting] = useState(false)
|
const [isDeleting, setIsDeleting] = useState(false)
|
||||||
|
const [showMenu, setShowMenu] = useState(false)
|
||||||
|
|
||||||
const activeAccount = Hooks.useActiveAccount()
|
const activeAccount = Hooks.useActiveAccount()
|
||||||
|
|
||||||
@@ -97,61 +100,45 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
|||||||
}
|
}
|
||||||
}, [isSelected])
|
}, [isSelected])
|
||||||
|
|
||||||
|
// Close menu when clicking outside
|
||||||
|
useEffect(() => {
|
||||||
|
const handleClickOutside = (event: MouseEvent) => {
|
||||||
|
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
|
||||||
|
setShowMenu(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showMenu) {
|
||||||
|
document.addEventListener('mousedown', handleClickOutside)
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('mousedown', handleClickOutside)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [showMenu])
|
||||||
|
|
||||||
const handleItemClick = () => {
|
const handleItemClick = () => {
|
||||||
if (onHighlightClick) {
|
if (onHighlightClick) {
|
||||||
onHighlightClick(highlight.id)
|
onHighlightClick(highlight.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleLinkClick = (url: string, e: React.MouseEvent) => {
|
const getHighlightLink = () => {
|
||||||
if (onSelectUrl) {
|
// Encode the highlight event itself (kind 9802) as a nevent
|
||||||
e.preventDefault()
|
// Get non-local relays for the hint
|
||||||
onSelectUrl(url)
|
const relayHints = RELAYS.filter(r =>
|
||||||
}
|
!r.includes('localhost') && !r.includes('127.0.0.1')
|
||||||
|
).slice(0, 3) // Include up to 3 relay hints
|
||||||
|
|
||||||
|
const nevent = nip19.neventEncode({
|
||||||
|
id: highlight.id,
|
||||||
|
relays: relayHints,
|
||||||
|
author: highlight.pubkey,
|
||||||
|
kind: 9802
|
||||||
|
})
|
||||||
|
return getNostrUrl(nevent)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSourceLink = () => {
|
const highlightLink = getHighlightLink()
|
||||||
if (highlight.eventReference) {
|
|
||||||
// Check if it's a coordinate string (kind:pubkey:identifier) or a simple event ID
|
|
||||||
if (highlight.eventReference.includes(':')) {
|
|
||||||
// It's an addressable event coordinate, encode as naddr
|
|
||||||
const parts = highlight.eventReference.split(':')
|
|
||||||
if (parts.length === 3) {
|
|
||||||
const [kindStr, pubkey, identifier] = parts
|
|
||||||
const kind = parseInt(kindStr, 10)
|
|
||||||
|
|
||||||
// Get non-local relays for the hint
|
|
||||||
const relayHints = RELAYS.filter(r =>
|
|
||||||
!r.includes('localhost') && !r.includes('127.0.0.1')
|
|
||||||
).slice(0, 3) // Include up to 3 relay hints
|
|
||||||
|
|
||||||
const naddr = nip19.naddrEncode({
|
|
||||||
kind,
|
|
||||||
pubkey,
|
|
||||||
identifier,
|
|
||||||
relays: relayHints
|
|
||||||
})
|
|
||||||
return `https://njump.me/${naddr}`
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// It's a simple event ID, encode as nevent
|
|
||||||
// Get non-local relays for the hint
|
|
||||||
const relayHints = RELAYS.filter(r =>
|
|
||||||
!r.includes('localhost') && !r.includes('127.0.0.1')
|
|
||||||
).slice(0, 3) // Include up to 3 relay hints
|
|
||||||
|
|
||||||
const nevent = nip19.neventEncode({
|
|
||||||
id: highlight.eventReference,
|
|
||||||
relays: relayHints,
|
|
||||||
author: highlight.author
|
|
||||||
})
|
|
||||||
return `https://njump.me/${nevent}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return highlight.urlReference
|
|
||||||
}
|
|
||||||
|
|
||||||
const sourceLink = getSourceLink()
|
|
||||||
|
|
||||||
// Handle rebroadcast to all relays
|
// Handle rebroadcast to all relays
|
||||||
const handleRebroadcast = async (e: React.MouseEvent) => {
|
const handleRebroadcast = async (e: React.MouseEvent) => {
|
||||||
@@ -255,11 +242,6 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
|||||||
// Check if current user can delete this highlight
|
// Check if current user can delete this highlight
|
||||||
const canDelete = activeAccount && highlight.pubkey === activeAccount.pubkey
|
const canDelete = activeAccount && highlight.pubkey === activeAccount.pubkey
|
||||||
|
|
||||||
const handleDeleteClick = (e: React.MouseEvent) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
setShowDeleteConfirm(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleConfirmDelete = async () => {
|
const handleConfirmDelete = async () => {
|
||||||
if (!activeAccount || !relayPool) {
|
if (!activeAccount || !relayPool) {
|
||||||
console.warn('Cannot delete: no account or relay pool')
|
console.warn('Cannot delete: no account or relay pool')
|
||||||
@@ -295,6 +277,23 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
|||||||
setShowDeleteConfirm(false)
|
setShowDeleteConfirm(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleMenuToggle = (e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
setShowMenu(!showMenu)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleOpenExternal = (e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
window.open(highlightLink, '_blank', 'noopener,noreferrer')
|
||||||
|
setShowMenu(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleMenuDeleteClick = (e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
setShowMenu(false)
|
||||||
|
setShowDeleteConfirm(true)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
@@ -316,15 +315,6 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
|||||||
<FontAwesomeIcon icon={relayIndicator.icon} spin={relayIndicator.spin} />
|
<FontAwesomeIcon icon={relayIndicator.icon} spin={relayIndicator.spin} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{canDelete && (
|
|
||||||
<div
|
|
||||||
className="highlight-delete-btn"
|
|
||||||
title="Delete highlight"
|
|
||||||
onClick={handleDeleteClick}
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon icon={isDeleting ? faSpinner : faTrash} spin={isDeleting} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="highlight-content">
|
<div className="highlight-content">
|
||||||
@@ -348,18 +338,37 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
|||||||
{formatDateCompact(highlight.created_at)}
|
{formatDateCompact(highlight.created_at)}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{sourceLink && (
|
<div className="highlight-menu-wrapper" ref={menuRef}>
|
||||||
<a
|
<button
|
||||||
href={sourceLink}
|
className="highlight-menu-btn"
|
||||||
target="_blank"
|
onClick={handleMenuToggle}
|
||||||
rel="noopener noreferrer"
|
title="More options"
|
||||||
onClick={(e) => highlight.urlReference && onSelectUrl ? handleLinkClick(highlight.urlReference, e) : undefined}
|
|
||||||
className="highlight-source"
|
|
||||||
title={highlight.eventReference ? 'Open on Nostr' : 'Open source'}
|
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={faExternalLinkAlt} />
|
<FontAwesomeIcon icon={faEllipsisH} />
|
||||||
</a>
|
</button>
|
||||||
)}
|
|
||||||
|
{showMenu && (
|
||||||
|
<div className="highlight-menu">
|
||||||
|
<button
|
||||||
|
className="highlight-menu-item"
|
||||||
|
onClick={handleOpenExternal}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={faExternalLinkAlt} />
|
||||||
|
<span>Open on Nostr</span>
|
||||||
|
</button>
|
||||||
|
{canDelete && (
|
||||||
|
<button
|
||||||
|
className="highlight-menu-item highlight-menu-item-danger"
|
||||||
|
onClick={handleMenuDeleteClick}
|
||||||
|
disabled={isDeleting}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={isDeleting ? faSpinner : faTrash} spin={isDeleting} />
|
||||||
|
<span>Delete</span>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import HighlightsPanelCollapsed from './HighlightsPanel/HighlightsPanelCollapsed
|
|||||||
import HighlightsPanelHeader from './HighlightsPanel/HighlightsPanelHeader'
|
import HighlightsPanelHeader from './HighlightsPanel/HighlightsPanelHeader'
|
||||||
import { RelayPool } from 'applesauce-relay'
|
import { RelayPool } from 'applesauce-relay'
|
||||||
import { IEventStore } from 'applesauce-core'
|
import { IEventStore } from 'applesauce-core'
|
||||||
|
import { UserSettings } from '../services/settingsService'
|
||||||
|
|
||||||
export interface HighlightVisibility {
|
export interface HighlightVisibility {
|
||||||
nostrverse: boolean
|
nostrverse: boolean
|
||||||
@@ -32,6 +33,7 @@ interface HighlightsPanelProps {
|
|||||||
followedPubkeys?: Set<string>
|
followedPubkeys?: Set<string>
|
||||||
relayPool?: RelayPool | null
|
relayPool?: RelayPool | null
|
||||||
eventStore?: IEventStore | null
|
eventStore?: IEventStore | null
|
||||||
|
settings?: UserSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
export const HighlightsPanel: React.FC<HighlightsPanelProps> = ({
|
export const HighlightsPanel: React.FC<HighlightsPanelProps> = ({
|
||||||
@@ -50,7 +52,8 @@ export const HighlightsPanel: React.FC<HighlightsPanelProps> = ({
|
|||||||
onHighlightVisibilityChange,
|
onHighlightVisibilityChange,
|
||||||
followedPubkeys = new Set(),
|
followedPubkeys = new Set(),
|
||||||
relayPool,
|
relayPool,
|
||||||
eventStore
|
eventStore,
|
||||||
|
settings
|
||||||
}) => {
|
}) => {
|
||||||
const [showHighlights, setShowHighlights] = useState(true)
|
const [showHighlights, setShowHighlights] = useState(true)
|
||||||
const [localHighlights, setLocalHighlights] = useState(highlights)
|
const [localHighlights, setLocalHighlights] = useState(highlights)
|
||||||
@@ -90,6 +93,7 @@ export const HighlightsPanel: React.FC<HighlightsPanelProps> = ({
|
|||||||
<HighlightsPanelCollapsed
|
<HighlightsPanelCollapsed
|
||||||
hasHighlights={filteredHighlights.length > 0}
|
hasHighlights={filteredHighlights.length > 0}
|
||||||
onToggleCollapse={onToggleCollapse}
|
onToggleCollapse={onToggleCollapse}
|
||||||
|
settings={settings}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
import { faHighlighter, faChevronRight } from '@fortawesome/free-solid-svg-icons'
|
import { faHighlighter, faChevronRight } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { UserSettings } from '../../services/settingsService'
|
||||||
|
|
||||||
interface HighlightsPanelCollapsedProps {
|
interface HighlightsPanelCollapsedProps {
|
||||||
hasHighlights: boolean
|
hasHighlights: boolean
|
||||||
onToggleCollapse: () => void
|
onToggleCollapse: () => void
|
||||||
|
settings?: UserSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
const HighlightsPanelCollapsed: React.FC<HighlightsPanelCollapsedProps> = ({
|
const HighlightsPanelCollapsed: React.FC<HighlightsPanelCollapsedProps> = ({
|
||||||
hasHighlights,
|
hasHighlights,
|
||||||
onToggleCollapse
|
onToggleCollapse,
|
||||||
|
settings
|
||||||
}) => {
|
}) => {
|
||||||
|
const highlightColor = settings?.highlightColorMine || '#ffff00'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="highlights-container collapsed">
|
<div className="highlights-container collapsed">
|
||||||
<button
|
<button
|
||||||
@@ -19,8 +24,12 @@ const HighlightsPanelCollapsed: React.FC<HighlightsPanelCollapsedProps> = ({
|
|||||||
title="Expand highlights panel"
|
title="Expand highlights panel"
|
||||||
aria-label="Expand highlights panel"
|
aria-label="Expand highlights panel"
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={faHighlighter} className={hasHighlights ? 'glow' : ''} />
|
<FontAwesomeIcon
|
||||||
<FontAwesomeIcon icon={faChevronRight} />
|
icon={faHighlighter}
|
||||||
|
className={hasHighlights ? 'glow' : ''}
|
||||||
|
style={{ color: highlightColor }}
|
||||||
|
/>
|
||||||
|
<FontAwesomeIcon icon={faChevronRight} style={{ color: highlightColor }} />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ const Me: React.FC<MeProps> = ({ relayPool }) => {
|
|||||||
<div className="explore-container">
|
<div className="explore-container">
|
||||||
<div className="explore-loading">
|
<div className="explore-loading">
|
||||||
<FontAwesomeIcon icon={faSpinner} spin size="2x" />
|
<FontAwesomeIcon icon={faSpinner} spin size="2x" />
|
||||||
<p>Loading your highlights...</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -105,7 +104,7 @@ const Me: React.FC<MeProps> = ({ relayPool }) => {
|
|||||||
{highlights.map((highlight) => (
|
{highlights.map((highlight) => (
|
||||||
<HighlightItem
|
<HighlightItem
|
||||||
key={highlight.id}
|
key={highlight.id}
|
||||||
highlight={highlight}
|
highlight={{ ...highlight, level: 'mine' }}
|
||||||
relayPool={relayPool}
|
relayPool={relayPool}
|
||||||
onHighlightDelete={handleHighlightDelete}
|
onHighlightDelete={handleHighlightDelete}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import React from 'react'
|
import React, { useMemo } from 'react'
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
import { faHighlighter, faClock } from '@fortawesome/free-solid-svg-icons'
|
import { faHighlighter, faClock } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { format } from 'date-fns'
|
import { format } from 'date-fns'
|
||||||
import { useImageCache } from '../hooks/useImageCache'
|
import { useImageCache } from '../hooks/useImageCache'
|
||||||
import { UserSettings } from '../services/settingsService'
|
import { UserSettings } from '../services/settingsService'
|
||||||
|
import { Highlight, HighlightLevel } from '../types/highlights'
|
||||||
|
import { HighlightVisibility } from './HighlightsPanel'
|
||||||
|
import { hexToRgb } from '../utils/colorHelpers'
|
||||||
|
|
||||||
interface ReaderHeaderProps {
|
interface ReaderHeaderProps {
|
||||||
title?: string
|
title?: string
|
||||||
@@ -14,6 +17,8 @@ interface ReaderHeaderProps {
|
|||||||
hasHighlights: boolean
|
hasHighlights: boolean
|
||||||
highlightCount: number
|
highlightCount: number
|
||||||
settings?: UserSettings
|
settings?: UserSettings
|
||||||
|
highlights?: Highlight[]
|
||||||
|
highlightVisibility?: HighlightVisibility
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReaderHeader: React.FC<ReaderHeaderProps> = ({
|
const ReaderHeader: React.FC<ReaderHeaderProps> = ({
|
||||||
@@ -24,12 +29,46 @@ const ReaderHeader: React.FC<ReaderHeaderProps> = ({
|
|||||||
readingTimeText,
|
readingTimeText,
|
||||||
hasHighlights,
|
hasHighlights,
|
||||||
highlightCount,
|
highlightCount,
|
||||||
settings
|
settings,
|
||||||
|
highlights = [],
|
||||||
|
highlightVisibility = { nostrverse: true, friends: true, mine: true }
|
||||||
}) => {
|
}) => {
|
||||||
const cachedImage = useImageCache(image, settings)
|
const cachedImage = useImageCache(image, settings)
|
||||||
const formattedDate = published ? format(new Date(published * 1000), 'MMM d, yyyy') : null
|
const formattedDate = published ? format(new Date(published * 1000), 'MMM d, yyyy') : null
|
||||||
const isLongSummary = summary && summary.length > 150
|
const isLongSummary = summary && summary.length > 150
|
||||||
|
|
||||||
|
// Determine the dominant highlight color based on visibility and priority
|
||||||
|
const highlightIndicatorStyles = useMemo(() => {
|
||||||
|
if (!highlights.length) return undefined
|
||||||
|
|
||||||
|
// Count highlights by level that are visible
|
||||||
|
const visibleLevels = new Set<HighlightLevel>()
|
||||||
|
highlights.forEach(h => {
|
||||||
|
if (h.level && highlightVisibility[h.level]) {
|
||||||
|
visibleLevels.add(h.level)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let hexColor: string | undefined
|
||||||
|
// Priority: nostrverse > friends > mine
|
||||||
|
if (visibleLevels.has('nostrverse') && highlightVisibility.nostrverse) {
|
||||||
|
hexColor = settings?.highlightColorNostrverse || '#9333ea'
|
||||||
|
} else if (visibleLevels.has('friends') && highlightVisibility.friends) {
|
||||||
|
hexColor = settings?.highlightColorFriends || '#f97316'
|
||||||
|
} else if (visibleLevels.has('mine') && highlightVisibility.mine) {
|
||||||
|
hexColor = settings?.highlightColorMine || '#ffff00'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hexColor) return undefined
|
||||||
|
|
||||||
|
const rgb = hexToRgb(hexColor)
|
||||||
|
return {
|
||||||
|
backgroundColor: `rgba(${rgb}, 0.1)`,
|
||||||
|
borderColor: `rgba(${rgb}, 0.3)`,
|
||||||
|
color: '#fff'
|
||||||
|
}
|
||||||
|
}, [highlights, highlightVisibility, settings])
|
||||||
|
|
||||||
if (cachedImage) {
|
if (cachedImage) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -52,7 +91,10 @@ const ReaderHeader: React.FC<ReaderHeaderProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{hasHighlights && (
|
{hasHighlights && (
|
||||||
<div className="highlight-indicator">
|
<div
|
||||||
|
className="highlight-indicator"
|
||||||
|
style={highlightIndicatorStyles}
|
||||||
|
>
|
||||||
<FontAwesomeIcon icon={faHighlighter} />
|
<FontAwesomeIcon icon={faHighlighter} />
|
||||||
<span>{highlightCount} highlight{highlightCount !== 1 ? 's' : ''}</span>
|
<span>{highlightCount} highlight{highlightCount !== 1 ? 's' : ''}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -89,7 +131,10 @@ const ReaderHeader: React.FC<ReaderHeaderProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{hasHighlights && (
|
{hasHighlights && (
|
||||||
<div className="highlight-indicator">
|
<div
|
||||||
|
className="highlight-indicator"
|
||||||
|
style={highlightIndicatorStyles}
|
||||||
|
>
|
||||||
<FontAwesomeIcon icon={faHighlighter} />
|
<FontAwesomeIcon icon={faHighlighter} />
|
||||||
<span>{highlightCount} highlight{highlightCount !== 1 ? 's' : ''}</span>
|
<span>{highlightCount} highlight{highlightCount !== 1 ? 's' : ''}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from 'react'
|
|||||||
import { useEventModel } from 'applesauce-react/hooks'
|
import { useEventModel } from 'applesauce-react/hooks'
|
||||||
import { Models, Helpers } from 'applesauce-core'
|
import { Models, Helpers } from 'applesauce-core'
|
||||||
import { decode, npubEncode } from 'nostr-tools/nip19'
|
import { decode, npubEncode } from 'nostr-tools/nip19'
|
||||||
|
import { getProfileUrl } from '../config/nostrGateways'
|
||||||
|
|
||||||
const { getPubkeyFromDecodeResult } = Helpers
|
const { getPubkeyFromDecodeResult } = Helpers
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ const ResolvedMention: React.FC<ResolvedMentionProps> = ({ encoded }) => {
|
|||||||
if (npub) {
|
if (npub) {
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
href={`https://search.dergigi.com/p/${npub}`}
|
href={getProfileUrl(npub)}
|
||||||
className="nostr-mention"
|
className="nostr-mention"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import StartupPreferencesSettings from './Settings/StartupPreferencesSettings'
|
|||||||
import ZapSettings from './Settings/ZapSettings'
|
import ZapSettings from './Settings/ZapSettings'
|
||||||
import OfflineModeSettings from './Settings/OfflineModeSettings'
|
import OfflineModeSettings from './Settings/OfflineModeSettings'
|
||||||
import RelaySettings from './Settings/RelaySettings'
|
import RelaySettings from './Settings/RelaySettings'
|
||||||
|
import PWASettings from './Settings/PWASettings'
|
||||||
import { useRelayStatus } from '../hooks/useRelayStatus'
|
import { useRelayStatus } from '../hooks/useRelayStatus'
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: UserSettings = {
|
const DEFAULT_SETTINGS: UserSettings = {
|
||||||
@@ -164,6 +165,7 @@ const Settings: React.FC<SettingsProps> = ({ settings, onSave, onClose, relayPoo
|
|||||||
<ZapSettings settings={localSettings} onUpdate={handleUpdate} />
|
<ZapSettings settings={localSettings} onUpdate={handleUpdate} />
|
||||||
<OfflineModeSettings settings={localSettings} onUpdate={handleUpdate} onClose={onClose} />
|
<OfflineModeSettings settings={localSettings} onUpdate={handleUpdate} onClose={onClose} />
|
||||||
<RelaySettings relayStatuses={relayStatuses} onClose={onClose} />
|
<RelaySettings relayStatuses={relayStatuses} onClose={onClose} />
|
||||||
|
<PWASettings />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
84
src/components/Settings/PWASettings.tsx
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { faDownload, faCheckCircle, faMobileAlt } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
|
import { usePWAInstall } from '../../hooks/usePWAInstall'
|
||||||
|
|
||||||
|
const PWASettings: React.FC = () => {
|
||||||
|
const { isInstallable, isInstalled, installApp } = usePWAInstall()
|
||||||
|
|
||||||
|
const handleInstall = async () => {
|
||||||
|
const success = await installApp()
|
||||||
|
if (success) {
|
||||||
|
console.log('App installed successfully')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isInstalled) {
|
||||||
|
return (
|
||||||
|
<div className="settings-section">
|
||||||
|
<h3>Progressive Web App</h3>
|
||||||
|
<div className="setting-item">
|
||||||
|
<div className="setting-info">
|
||||||
|
<FontAwesomeIcon icon={faCheckCircle} style={{ color: '#22c55e', marginRight: '8px' }} />
|
||||||
|
<span>Boris is installed as an app</span>
|
||||||
|
</div>
|
||||||
|
<p className="setting-description">
|
||||||
|
You can launch Boris from your home screen or app drawer.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isInstallable) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="settings-section">
|
||||||
|
<h3>Progressive Web App</h3>
|
||||||
|
<div className="setting-item">
|
||||||
|
<div className="setting-info">
|
||||||
|
<FontAwesomeIcon icon={faMobileAlt} style={{ marginRight: '8px' }} />
|
||||||
|
<span>Install Boris as an app</span>
|
||||||
|
</div>
|
||||||
|
<p className="setting-description">
|
||||||
|
Install Boris on your device for a native app experience with offline support.
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
onClick={handleInstall}
|
||||||
|
className="install-button"
|
||||||
|
style={{
|
||||||
|
marginTop: '12px',
|
||||||
|
padding: '8px 16px',
|
||||||
|
background: 'linear-gradient(135deg, #3b82f6 0%, #1e40af 100%)',
|
||||||
|
color: 'white',
|
||||||
|
border: 'none',
|
||||||
|
borderRadius: '8px',
|
||||||
|
cursor: 'pointer',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '8px',
|
||||||
|
fontSize: '14px',
|
||||||
|
fontWeight: '500',
|
||||||
|
transition: 'transform 0.2s, box-shadow 0.2s',
|
||||||
|
}}
|
||||||
|
onMouseEnter={(e) => {
|
||||||
|
e.currentTarget.style.transform = 'translateY(-2px)'
|
||||||
|
e.currentTarget.style.boxShadow = '0 4px 12px rgba(59, 130, 246, 0.3)'
|
||||||
|
}}
|
||||||
|
onMouseLeave={(e) => {
|
||||||
|
e.currentTarget.style.transform = 'translateY(0)'
|
||||||
|
e.currentTarget.style.boxShadow = 'none'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={faDownload} />
|
||||||
|
Install App
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PWASettings
|
||||||
|
|
||||||
@@ -241,6 +241,10 @@ const ThreePaneLayout: React.FC<ThreePaneLayoutProps> = (props) => {
|
|||||||
onClick={props.onToggleHighlightsPanel}
|
onClick={props.onToggleHighlightsPanel}
|
||||||
aria-label="Open highlights"
|
aria-label="Open highlights"
|
||||||
aria-expanded={!props.isHighlightsCollapsed}
|
aria-expanded={!props.isHighlightsCollapsed}
|
||||||
|
style={{
|
||||||
|
backgroundColor: props.settings.highlightColorMine || '#ffff00',
|
||||||
|
color: '#000'
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={faHighlighter} />
|
<FontAwesomeIcon icon={faHighlighter} />
|
||||||
</button>
|
</button>
|
||||||
@@ -351,6 +355,7 @@ const ThreePaneLayout: React.FC<ThreePaneLayoutProps> = (props) => {
|
|||||||
followedPubkeys={props.followedPubkeys}
|
followedPubkeys={props.followedPubkeys}
|
||||||
relayPool={props.relayPool}
|
relayPool={props.relayPool}
|
||||||
eventStore={props.eventStore}
|
eventStore={props.eventStore}
|
||||||
|
settings={props.settings}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -358,7 +363,7 @@ const ThreePaneLayout: React.FC<ThreePaneLayoutProps> = (props) => {
|
|||||||
<HighlightButton
|
<HighlightButton
|
||||||
ref={props.highlightButtonRef}
|
ref={props.highlightButtonRef}
|
||||||
onHighlight={props.onCreateHighlight}
|
onHighlight={props.onCreateHighlight}
|
||||||
highlightColor={props.settings.highlightColor || '#ffff00'}
|
highlightColor={props.settings.highlightColorMine || '#ffff00'}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<RelayStatusIndicator relayPool={props.relayPool} />
|
<RelayStatusIndicator relayPool={props.relayPool} />
|
||||||
|
|||||||
34
src/config/nostrGateways.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* Nostr gateway URLs for viewing events and profiles on the web
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const NOSTR_GATEWAY = 'https://ants.sh' as const
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a profile URL on the gateway
|
||||||
|
*/
|
||||||
|
export function getProfileUrl(npub: string): string {
|
||||||
|
return `${NOSTR_GATEWAY}/p/${npub}`
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an event URL on the gateway
|
||||||
|
*/
|
||||||
|
export function getEventUrl(nevent: string): string {
|
||||||
|
return `${NOSTR_GATEWAY}/e/${nevent}`
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a general nostr link on the gateway
|
||||||
|
* Automatically detects if it's a profile (npub/nprofile) or event (note/nevent/naddr)
|
||||||
|
*/
|
||||||
|
export function getNostrUrl(identifier: string): string {
|
||||||
|
// Check the prefix to determine if it's a profile or event
|
||||||
|
if (identifier.startsWith('npub') || identifier.startsWith('nprofile')) {
|
||||||
|
return `${NOSTR_GATEWAY}/p/${identifier}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Everything else (note, nevent, naddr) goes to /e/
|
||||||
|
return `${NOSTR_GATEWAY}/e/${identifier}`
|
||||||
|
}
|
||||||
|
|
||||||
@@ -44,10 +44,14 @@ export const useBookmarksData = ({
|
|||||||
|
|
||||||
const handleFetchBookmarks = useCallback(async () => {
|
const handleFetchBookmarks = useCallback(async () => {
|
||||||
if (!relayPool || !activeAccount) return
|
if (!relayPool || !activeAccount) return
|
||||||
|
// don't clear existing bookmarks: we keep UI stable and show spinner unobtrusively
|
||||||
setBookmarksLoading(true)
|
setBookmarksLoading(true)
|
||||||
try {
|
try {
|
||||||
const fullAccount = accountManager.getActive()
|
const fullAccount = accountManager.getActive()
|
||||||
await fetchBookmarks(relayPool, fullAccount || activeAccount, setBookmarks, settings)
|
// merge-friendly: updater form that preserves visible list until replacement
|
||||||
|
await fetchBookmarks(relayPool, fullAccount || activeAccount, (next) => {
|
||||||
|
setBookmarks(() => next)
|
||||||
|
}, settings)
|
||||||
} finally {
|
} finally {
|
||||||
setBookmarksLoading(false)
|
setBookmarksLoading(false)
|
||||||
}
|
}
|
||||||
@@ -102,15 +106,21 @@ export const useBookmarksData = ({
|
|||||||
}
|
}
|
||||||
}, [relayPool, activeAccount, isRefreshing, handleFetchBookmarks, handleFetchHighlights, handleFetchContacts])
|
}, [relayPool, activeAccount, isRefreshing, handleFetchBookmarks, handleFetchHighlights, handleFetchContacts])
|
||||||
|
|
||||||
// Load initial data
|
// Load initial data (avoid clearing on route-only changes)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!relayPool || !activeAccount) return
|
if (!relayPool || !activeAccount) return
|
||||||
|
// Only (re)fetch bookmarks when account or relayPool changes, not on naddr route changes
|
||||||
handleFetchBookmarks()
|
handleFetchBookmarks()
|
||||||
|
}, [relayPool, activeAccount, handleFetchBookmarks])
|
||||||
|
|
||||||
|
// Fetch highlights/contacts independently to avoid disturbing bookmarks
|
||||||
|
useEffect(() => {
|
||||||
|
if (!relayPool || !activeAccount) return
|
||||||
if (!naddr) {
|
if (!naddr) {
|
||||||
handleFetchHighlights()
|
handleFetchHighlights()
|
||||||
}
|
}
|
||||||
handleFetchContacts()
|
handleFetchContacts()
|
||||||
}, [relayPool, activeAccount, naddr, handleFetchBookmarks, handleFetchHighlights, handleFetchContacts])
|
}, [relayPool, activeAccount, naddr, handleFetchHighlights, handleFetchContacts])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bookmarks,
|
bookmarks,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ interface UseExternalUrlLoaderProps {
|
|||||||
setReaderContent: (content: ReadableContent | undefined) => void
|
setReaderContent: (content: ReadableContent | undefined) => void
|
||||||
setReaderLoading: (loading: boolean) => void
|
setReaderLoading: (loading: boolean) => void
|
||||||
setIsCollapsed: (collapsed: boolean) => void
|
setIsCollapsed: (collapsed: boolean) => void
|
||||||
setHighlights: (highlights: Highlight[]) => void
|
setHighlights: (highlights: Highlight[] | ((prev: Highlight[]) => Highlight[])) => void
|
||||||
setHighlightsLoading: (loading: boolean) => void
|
setHighlightsLoading: (loading: boolean) => void
|
||||||
setCurrentArticleCoordinate: (coord: string | undefined) => void
|
setCurrentArticleCoordinate: (coord: string | undefined) => void
|
||||||
setCurrentArticleEventId: (id: string | undefined) => void
|
setCurrentArticleEventId: (id: string | undefined) => void
|
||||||
@@ -57,7 +57,21 @@ export function useExternalUrlLoader({
|
|||||||
|
|
||||||
// Check if fetchHighlightsForUrl exists, otherwise skip
|
// Check if fetchHighlightsForUrl exists, otherwise skip
|
||||||
if (typeof fetchHighlightsForUrl === 'function') {
|
if (typeof fetchHighlightsForUrl === 'function') {
|
||||||
const highlightsList = await fetchHighlightsForUrl(relayPool, url)
|
const seen = new Set<string>()
|
||||||
|
const highlightsList = await fetchHighlightsForUrl(
|
||||||
|
relayPool,
|
||||||
|
url,
|
||||||
|
(highlight) => {
|
||||||
|
if (seen.has(highlight.id)) return
|
||||||
|
seen.add(highlight.id)
|
||||||
|
setHighlights((prev) => {
|
||||||
|
if (prev.some(h => h.id === highlight.id)) return prev
|
||||||
|
const next = [...prev, highlight]
|
||||||
|
return next.sort((a, b) => b.created_at - a.created_at)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
// Ensure final list is sorted and contains all items
|
||||||
setHighlights(highlightsList.sort((a, b) => b.created_at - a.created_at))
|
setHighlights(highlightsList.sort((a, b) => b.created_at - a.created_at))
|
||||||
console.log(`📌 Found ${highlightsList.length} highlights for URL`)
|
console.log(`📌 Found ${highlightsList.length} highlights for URL`)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
28
src/hooks/useOnlineStatus.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { useState, useEffect } from 'react'
|
||||||
|
|
||||||
|
export function useOnlineStatus() {
|
||||||
|
const [isOnline, setIsOnline] = useState(navigator.onLine)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleOnline = () => {
|
||||||
|
console.log('🌐 Back online')
|
||||||
|
setIsOnline(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleOffline = () => {
|
||||||
|
console.log('📴 Gone offline')
|
||||||
|
setIsOnline(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('online', handleOnline)
|
||||||
|
window.addEventListener('offline', handleOffline)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('online', handleOnline)
|
||||||
|
window.removeEventListener('offline', handleOffline)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return isOnline
|
||||||
|
}
|
||||||
|
|
||||||
74
src/hooks/usePWAInstall.ts
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import { useState, useEffect } from 'react'
|
||||||
|
|
||||||
|
interface BeforeInstallPromptEvent extends Event {
|
||||||
|
prompt: () => Promise<void>
|
||||||
|
userChoice: Promise<{ outcome: 'accepted' | 'dismissed' }>
|
||||||
|
}
|
||||||
|
|
||||||
|
export function usePWAInstall() {
|
||||||
|
const [deferredPrompt, setDeferredPrompt] = useState<BeforeInstallPromptEvent | null>(null)
|
||||||
|
const [isInstallable, setIsInstallable] = useState(false)
|
||||||
|
const [isInstalled, setIsInstalled] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Check if app is already installed
|
||||||
|
if (window.matchMedia('(display-mode: standalone)').matches) {
|
||||||
|
setIsInstalled(true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Listen for the beforeinstallprompt event
|
||||||
|
const handleBeforeInstallPrompt = (e: Event) => {
|
||||||
|
e.preventDefault()
|
||||||
|
const installPromptEvent = e as BeforeInstallPromptEvent
|
||||||
|
setDeferredPrompt(installPromptEvent)
|
||||||
|
setIsInstallable(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Listen for successful installation
|
||||||
|
const handleAppInstalled = () => {
|
||||||
|
setIsInstalled(true)
|
||||||
|
setIsInstallable(false)
|
||||||
|
setDeferredPrompt(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('beforeinstallprompt', handleBeforeInstallPrompt)
|
||||||
|
window.addEventListener('appinstalled', handleAppInstalled)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('beforeinstallprompt', handleBeforeInstallPrompt)
|
||||||
|
window.removeEventListener('appinstalled', handleAppInstalled)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const installApp = async () => {
|
||||||
|
if (!deferredPrompt) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await deferredPrompt.prompt()
|
||||||
|
const choiceResult = await deferredPrompt.userChoice
|
||||||
|
|
||||||
|
if (choiceResult.outcome === 'accepted') {
|
||||||
|
console.log('✅ PWA installed')
|
||||||
|
setIsInstallable(false)
|
||||||
|
setDeferredPrompt(null)
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
console.log('❌ PWA installation dismissed')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error installing PWA:', error)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
isInstallable,
|
||||||
|
isInstalled,
|
||||||
|
installApp,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
256
src/index.css
@@ -1018,6 +1018,99 @@ body.mobile-sidebar-open {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Author Card */
|
||||||
|
.author-card-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 2rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card {
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1.5rem;
|
||||||
|
background: #1a1a1a;
|
||||||
|
border: 1px solid #333;
|
||||||
|
border-radius: 12px;
|
||||||
|
max-width: 600px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card-avatar {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #2a2a2a;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card-avatar img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card-avatar svg {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card-content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card-name {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #ddd;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card-bio {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: #999;
|
||||||
|
line-height: 1.5;
|
||||||
|
margin: 0;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.author-card-container {
|
||||||
|
padding: 1.5rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card-avatar {
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card-avatar svg {
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card-name {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-card-bio {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.bookmark-item {
|
.bookmark-item {
|
||||||
background: #1a1a1a;
|
background: #1a1a1a;
|
||||||
padding: 1.5rem;
|
padding: 1.5rem;
|
||||||
@@ -1690,6 +1783,35 @@ body.mobile-sidebar-open {
|
|||||||
.highlight-text {
|
.highlight-text {
|
||||||
color: #213547;
|
color: #213547;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.highlight-menu-btn {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu-btn:hover {
|
||||||
|
color: #646cff;
|
||||||
|
background: rgba(100, 108, 255, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu {
|
||||||
|
background: #fff;
|
||||||
|
border-color: #ddd;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu-item {
|
||||||
|
color: #213547;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu-item:hover {
|
||||||
|
background: rgba(100, 108, 255, 0.08);
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu-item-danger:hover {
|
||||||
|
background: rgba(255, 68, 68, 0.08);
|
||||||
|
color: #cc0000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Highlights Panel Styles */
|
/* Highlights Panel Styles */
|
||||||
@@ -1743,17 +1865,17 @@ body.mobile-sidebar-open {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.highlights-container.collapsed .toggle-highlights-btn .glow {
|
.highlights-container.collapsed .toggle-highlights-btn .glow {
|
||||||
color: #ffff00;
|
|
||||||
filter: drop-shadow(0 0 4px rgba(255, 255, 0, 0.6));
|
|
||||||
animation: pulse-glow 2s ease-in-out infinite;
|
animation: pulse-glow 2s ease-in-out infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes pulse-glow {
|
@keyframes pulse-glow {
|
||||||
0%, 100% {
|
0%, 100% {
|
||||||
filter: drop-shadow(0 0 4px rgba(255, 255, 0, 0.6));
|
opacity: 0.8;
|
||||||
|
transform: scale(1);
|
||||||
}
|
}
|
||||||
50% {
|
50% {
|
||||||
filter: drop-shadow(0 0 8px rgba(255, 255, 0, 0.9));
|
opacity: 1;
|
||||||
|
transform: scale(1.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1991,13 +2113,19 @@ body.mobile-sidebar-open {
|
|||||||
|
|
||||||
.highlight-relay-indicator {
|
.highlight-relay-indicator {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: -2px;
|
bottom: -4px;
|
||||||
left: 0;
|
left: -6px;
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
color: #888;
|
color: #888;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
padding: 4px;
|
||||||
|
min-width: 20px;
|
||||||
|
min-height: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight-relay-indicator:hover {
|
.highlight-relay-indicator:hover {
|
||||||
@@ -2012,13 +2140,19 @@ body.mobile-sidebar-open {
|
|||||||
|
|
||||||
.highlight-delete-btn {
|
.highlight-delete-btn {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: -2px;
|
bottom: -4px;
|
||||||
right: 0;
|
right: -6px;
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
color: #888;
|
color: #888;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
padding: 4px;
|
||||||
|
min-width: 20px;
|
||||||
|
min-height: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight-delete-btn:hover {
|
.highlight-delete-btn:hover {
|
||||||
@@ -2031,6 +2165,31 @@ body.mobile-sidebar-open {
|
|||||||
transform: scale(0.95);
|
transform: scale(0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Mobile: Larger touch targets and better spacing */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.highlight-quote-icon {
|
||||||
|
min-width: 100px; /* Ensure enough space for both touch targets */
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-relay-indicator {
|
||||||
|
bottom: -8px;
|
||||||
|
left: -8px;
|
||||||
|
padding: 8px;
|
||||||
|
min-width: var(--min-touch-target);
|
||||||
|
min-height: var(--min-touch-target);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-delete-btn {
|
||||||
|
bottom: -8px;
|
||||||
|
right: -8px;
|
||||||
|
padding: 8px;
|
||||||
|
min-width: var(--min-touch-target);
|
||||||
|
min-height: var(--min-touch-target);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Level-colored quote icon */
|
/* Level-colored quote icon */
|
||||||
.highlight-item.level-mine .highlight-quote-icon {
|
.highlight-item.level-mine .highlight-quote-icon {
|
||||||
color: var(--highlight-color-mine, #ffff00);
|
color: var(--highlight-color-mine, #ffff00);
|
||||||
@@ -2106,25 +2265,77 @@ body.mobile-sidebar-open {
|
|||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight-source {
|
.highlight-menu-wrapper {
|
||||||
|
position: relative;
|
||||||
|
margin-left: auto;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu-btn {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: #888;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.375rem;
|
|
||||||
color: #646cff;
|
|
||||||
text-decoration: none;
|
|
||||||
transition: color 0.2s ease;
|
transition: color 0.2s ease;
|
||||||
flex-shrink: 0;
|
border-radius: 4px;
|
||||||
margin-left: auto;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight-source:hover {
|
.highlight-menu-btn:hover {
|
||||||
color: #535bf2;
|
color: #646cff;
|
||||||
text-decoration: underline;
|
background: rgba(100, 108, 255, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight-source svg {
|
.highlight-menu {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: calc(100% + 4px);
|
||||||
|
background: #2a2a2a;
|
||||||
|
border: 1px solid #444;
|
||||||
|
border-radius: 6px;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||||
|
z-index: 1000;
|
||||||
|
min-width: 160px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu-item {
|
||||||
|
width: 100%;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: #ddd;
|
||||||
|
padding: 0.625rem 0.875rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.625rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
text-align: left;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu-item:hover {
|
||||||
|
background: rgba(100, 108, 255, 0.15);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu-item:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu-item-danger:hover {
|
||||||
|
background: rgba(255, 68, 68, 0.15);
|
||||||
|
color: #ff4444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-menu-item svg {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inline content highlights - fluorescent marker style */
|
/* Inline content highlights - fluorescent marker style */
|
||||||
@@ -3130,10 +3341,15 @@ body.mobile-sidebar-open {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
min-height: 50vh;
|
|
||||||
color: rgba(255, 255, 255, 0.7);
|
color: rgba(255, 255, 255, 0.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Compact, inline loading row for Explore refresh */
|
||||||
|
.explore-loading {
|
||||||
|
min-height: 0;
|
||||||
|
padding: 0.25rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
.explore-error {
|
.explore-error {
|
||||||
color: #ff6b6b;
|
color: #ff6b6b;
|
||||||
}
|
}
|
||||||
|
|||||||
20
src/main.tsx
@@ -3,21 +3,31 @@ import ReactDOM from 'react-dom/client'
|
|||||||
import App from './App.tsx'
|
import App from './App.tsx'
|
||||||
import './index.css'
|
import './index.css'
|
||||||
|
|
||||||
// Register Service Worker for offline image caching
|
// Register Service Worker for PWA functionality
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register('/sw.js')
|
.register('/sw.js', { type: 'module' })
|
||||||
.then(registration => {
|
.then(registration => {
|
||||||
console.log('✅ Service Worker registered:', registration.scope)
|
console.log('✅ Service Worker registered:', registration.scope)
|
||||||
|
|
||||||
// Update service worker when a new version is available
|
// Check for updates periodically
|
||||||
|
setInterval(() => {
|
||||||
|
registration.update()
|
||||||
|
}, 60 * 60 * 1000) // Check every hour
|
||||||
|
|
||||||
|
// Handle service worker updates
|
||||||
registration.addEventListener('updatefound', () => {
|
registration.addEventListener('updatefound', () => {
|
||||||
const newWorker = registration.installing
|
const newWorker = registration.installing
|
||||||
if (newWorker) {
|
if (newWorker) {
|
||||||
newWorker.addEventListener('statechange', () => {
|
newWorker.addEventListener('statechange', () => {
|
||||||
if (newWorker.state === 'activated') {
|
if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
|
||||||
console.log('🔄 Service Worker updated, page may need reload')
|
// New service worker available
|
||||||
|
console.log('🔄 New version available! Reload to update.')
|
||||||
|
|
||||||
|
// Optionally show a toast notification
|
||||||
|
const updateAvailable = new CustomEvent('sw-update-available')
|
||||||
|
window.dispatchEvent(updateAvailable)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { RelayPool, completeOnEose } from 'applesauce-relay'
|
import { RelayPool } from 'applesauce-relay'
|
||||||
import { lastValueFrom, takeUntil, timer, toArray } from 'rxjs'
|
import { lastValueFrom, take } from 'rxjs'
|
||||||
import { nip19 } from 'nostr-tools'
|
import { nip19 } from 'nostr-tools'
|
||||||
import { AddressPointer } from 'nostr-tools/nip19'
|
import { AddressPointer } from 'nostr-tools/nip19'
|
||||||
import { NostrEvent } from 'nostr-tools'
|
import { NostrEvent } from 'nostr-tools'
|
||||||
import { Helpers } from 'applesauce-core'
|
import { Helpers } from 'applesauce-core'
|
||||||
import { RELAYS } from '../config/relays'
|
import { RELAYS } from '../config/relays'
|
||||||
|
import { prioritizeLocalRelays, partitionRelays, createParallelReqStreams } from '../utils/helpers'
|
||||||
|
import { merge, toArray as rxToArray } from 'rxjs'
|
||||||
import { UserSettings } from './settingsService'
|
import { UserSettings } from './settingsService'
|
||||||
import { rebroadcastEvents } from './rebroadcastService'
|
import { rebroadcastEvents } from './rebroadcastService'
|
||||||
|
|
||||||
@@ -98,9 +100,11 @@ export async function fetchArticleByNaddr(
|
|||||||
const pointer = decoded.data as AddressPointer
|
const pointer = decoded.data as AddressPointer
|
||||||
|
|
||||||
// Define relays to query - prefer relays from naddr, fallback to configured relays (including local)
|
// Define relays to query - prefer relays from naddr, fallback to configured relays (including local)
|
||||||
const relays = pointer.relays && pointer.relays.length > 0
|
const baseRelays = pointer.relays && pointer.relays.length > 0
|
||||||
? pointer.relays
|
? pointer.relays
|
||||||
: RELAYS
|
: RELAYS
|
||||||
|
const orderedRelays = prioritizeLocalRelays(baseRelays)
|
||||||
|
const { local: localRelays, remote: remoteRelays } = partitionRelays(orderedRelays)
|
||||||
|
|
||||||
// Fetch the article event
|
// Fetch the article event
|
||||||
const filter = {
|
const filter = {
|
||||||
@@ -109,12 +113,10 @@ export async function fetchArticleByNaddr(
|
|||||||
'#d': [pointer.identifier]
|
'#d': [pointer.identifier]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use applesauce relay pool pattern
|
// Parallel local+remote, stream immediate, collect up to first from each
|
||||||
const events = await lastValueFrom(
|
const { local$, remote$ } = createParallelReqStreams(relayPool, localRelays, remoteRelays, filter, 1200, 6000)
|
||||||
relayPool
|
const collected = await lastValueFrom(merge(local$.pipe(take(1)), remote$.pipe(take(1))).pipe(rxToArray()))
|
||||||
.req(relays, filter)
|
const events = collected as NostrEvent[]
|
||||||
.pipe(completeOnEose(), takeUntil(timer(10000)), toArray())
|
|
||||||
)
|
|
||||||
|
|
||||||
if (events.length === 0) {
|
if (events.length === 0) {
|
||||||
throw new Error('Article not found')
|
throw new Error('Article not found')
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { RelayPool, completeOnEose } from 'applesauce-relay'
|
import { RelayPool } from 'applesauce-relay'
|
||||||
import { lastValueFrom, takeUntil, timer, toArray } from 'rxjs'
|
import { lastValueFrom, take } from 'rxjs'
|
||||||
import { nip19 } from 'nostr-tools'
|
import { nip19 } from 'nostr-tools'
|
||||||
import { AddressPointer } from 'nostr-tools/nip19'
|
import { AddressPointer } from 'nostr-tools/nip19'
|
||||||
import { Helpers } from 'applesauce-core'
|
import { Helpers } from 'applesauce-core'
|
||||||
import { RELAYS } from '../config/relays'
|
import { RELAYS } from '../config/relays'
|
||||||
|
import { prioritizeLocalRelays, partitionRelays, createParallelReqStreams } from '../utils/helpers'
|
||||||
|
import { merge, toArray as rxToArray } from 'rxjs'
|
||||||
|
|
||||||
const { getArticleTitle } = Helpers
|
const { getArticleTitle } = Helpers
|
||||||
|
|
||||||
@@ -25,9 +27,11 @@ export async function fetchArticleTitle(
|
|||||||
const pointer = decoded.data as AddressPointer
|
const pointer = decoded.data as AddressPointer
|
||||||
|
|
||||||
// Define relays to query
|
// Define relays to query
|
||||||
const relays = pointer.relays && pointer.relays.length > 0
|
const baseRelays = pointer.relays && pointer.relays.length > 0
|
||||||
? pointer.relays
|
? pointer.relays
|
||||||
: RELAYS
|
: RELAYS
|
||||||
|
const orderedRelays = prioritizeLocalRelays(baseRelays)
|
||||||
|
const { local: localRelays, remote: remoteRelays } = partitionRelays(orderedRelays)
|
||||||
|
|
||||||
// Fetch the article event
|
// Fetch the article event
|
||||||
const filter = {
|
const filter = {
|
||||||
@@ -36,11 +40,11 @@ export async function fetchArticleTitle(
|
|||||||
'#d': [pointer.identifier]
|
'#d': [pointer.identifier]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parallel local+remote: collect up to one event from each
|
||||||
|
const { local$, remote$ } = createParallelReqStreams(relayPool, localRelays, remoteRelays, filter, 1200, 5000)
|
||||||
const events = await lastValueFrom(
|
const events = await lastValueFrom(
|
||||||
relayPool
|
merge(local$.pipe(take(1)), remote$.pipe(take(1))).pipe(rxToArray())
|
||||||
.req(relays, filter)
|
) as unknown as { created_at: number }[]
|
||||||
.pipe(completeOnEose(), takeUntil(timer(5000)), toArray())
|
|
||||||
)
|
|
||||||
|
|
||||||
if (events.length === 0) {
|
if (events.length === 0) {
|
||||||
return null
|
return null
|
||||||
@@ -48,7 +52,7 @@ export async function fetchArticleTitle(
|
|||||||
|
|
||||||
// Sort by created_at and take the most recent
|
// Sort by created_at and take the most recent
|
||||||
events.sort((a, b) => b.created_at - a.created_at)
|
events.sort((a, b) => b.created_at - a.created_at)
|
||||||
const article = events[0]
|
const article = events[0] as unknown as Parameters<typeof getArticleTitle>[0]
|
||||||
|
|
||||||
return getArticleTitle(article) || null
|
return getArticleTitle(article) || null
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RelayPool, completeOnEose } from 'applesauce-relay'
|
import { RelayPool, completeOnEose } from 'applesauce-relay'
|
||||||
import { lastValueFrom, takeUntil, timer, toArray } from 'rxjs'
|
import { lastValueFrom, merge, Observable, takeUntil, timer, toArray } from 'rxjs'
|
||||||
import {
|
import {
|
||||||
AccountWithExtension,
|
AccountWithExtension,
|
||||||
NostrEvent,
|
NostrEvent,
|
||||||
@@ -16,6 +16,7 @@ import { Bookmark } from '../types/bookmarks'
|
|||||||
import { collectBookmarksFromEvents } from './bookmarkProcessing.ts'
|
import { collectBookmarksFromEvents } from './bookmarkProcessing.ts'
|
||||||
import { UserSettings } from './settingsService'
|
import { UserSettings } from './settingsService'
|
||||||
import { rebroadcastEvents } from './rebroadcastService'
|
import { rebroadcastEvents } from './rebroadcastService'
|
||||||
|
import { prioritizeLocalRelays, partitionRelays } from '../utils/helpers'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -31,14 +32,22 @@ export const fetchBookmarks = async (
|
|||||||
throw new Error('Invalid account object provided')
|
throw new Error('Invalid account object provided')
|
||||||
}
|
}
|
||||||
// Get relay URLs from the pool
|
// Get relay URLs from the pool
|
||||||
const relayUrls = Array.from(relayPool.relays.values()).map(relay => relay.url)
|
const relayUrls = prioritizeLocalRelays(Array.from(relayPool.relays.values()).map(relay => relay.url))
|
||||||
|
const { local: localRelays, remote: remoteRelays } = partitionRelays(relayUrls)
|
||||||
// Fetch bookmark events - NIP-51 standards, legacy formats, and web bookmarks (NIP-B0)
|
// Fetch bookmark events - NIP-51 standards, legacy formats, and web bookmarks (NIP-B0)
|
||||||
console.log('🔍 Fetching bookmark events from relays:', relayUrls)
|
console.log('🔍 Fetching bookmark events from relays:', relayUrls)
|
||||||
const rawEvents = await lastValueFrom(
|
// Try local-first quickly, then full set fallback
|
||||||
relayPool
|
const local$ = localRelays.length > 0
|
||||||
.req(relayUrls, { kinds: [10003, 30003, 30001, 39701], authors: [activeAccount.pubkey] })
|
? relayPool
|
||||||
.pipe(completeOnEose(), takeUntil(timer(20000)), toArray())
|
.req(localRelays, { kinds: [10003, 30003, 30001, 39701], authors: [activeAccount.pubkey] })
|
||||||
)
|
.pipe(completeOnEose(), takeUntil(timer(1200)))
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const remote$ = remoteRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(remoteRelays, { kinds: [10003, 30003, 30001, 39701], authors: [activeAccount.pubkey] })
|
||||||
|
.pipe(completeOnEose(), takeUntil(timer(6000)))
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const rawEvents = await lastValueFrom(merge(local$, remote$).pipe(toArray()))
|
||||||
console.log('📊 Raw events fetched:', rawEvents.length, 'events')
|
console.log('📊 Raw events fetched:', rawEvents.length, 'events')
|
||||||
|
|
||||||
// Rebroadcast bookmark events to local/all relays based on settings
|
// Rebroadcast bookmark events to local/all relays based on settings
|
||||||
@@ -64,7 +73,7 @@ export const fetchBookmarks = async (
|
|||||||
const bookmarkListEvents = dedupeNip51Events(rawEvents)
|
const bookmarkListEvents = dedupeNip51Events(rawEvents)
|
||||||
console.log('📋 After deduplication:', bookmarkListEvents.length, 'bookmark events')
|
console.log('📋 After deduplication:', bookmarkListEvents.length, 'bookmark events')
|
||||||
if (bookmarkListEvents.length === 0) {
|
if (bookmarkListEvents.length === 0) {
|
||||||
setBookmarks([])
|
// Keep existing bookmarks visible; do not clear list if nothing new found
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Aggregate across events
|
// Aggregate across events
|
||||||
@@ -102,9 +111,14 @@ export const fetchBookmarks = async (
|
|||||||
let idToEvent: Map<string, NostrEvent> = new Map()
|
let idToEvent: Map<string, NostrEvent> = new Map()
|
||||||
if (noteIds.length > 0) {
|
if (noteIds.length > 0) {
|
||||||
try {
|
try {
|
||||||
const events = await lastValueFrom(
|
const { local: localHydrate, remote: remoteHydrate } = partitionRelays(relayUrls)
|
||||||
relayPool.req(relayUrls, { ids: noteIds }).pipe(completeOnEose(), takeUntil(timer(10000)), toArray())
|
const localHydrate$ = localHydrate.length > 0
|
||||||
)
|
? relayPool.req(localHydrate, { ids: noteIds }).pipe(completeOnEose(), takeUntil(timer(800)))
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const remoteHydrate$ = remoteHydrate.length > 0
|
||||||
|
? relayPool.req(remoteHydrate, { ids: noteIds }).pipe(completeOnEose(), takeUntil(timer(2500)))
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const events: NostrEvent[] = await lastValueFrom(merge(localHydrate$, remoteHydrate$).pipe(toArray()))
|
||||||
idToEvent = new Map(events.map((e: NostrEvent) => [e.id, e]))
|
idToEvent = new Map(events.map((e: NostrEvent) => [e.id, e]))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Failed to fetch events for hydration:', error)
|
console.warn('Failed to fetch events for hydration:', error)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { RelayPool, completeOnEose } from 'applesauce-relay'
|
import { RelayPool, completeOnEose } from 'applesauce-relay'
|
||||||
import { lastValueFrom, takeUntil, timer, toArray } from 'rxjs'
|
import { lastValueFrom, merge, Observable, takeUntil, timer, toArray } from 'rxjs'
|
||||||
|
import { prioritizeLocalRelays } from '../utils/helpers'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the contact list (follows) for a specific user
|
* Fetches the contact list (follows) for a specific user
|
||||||
@@ -9,40 +10,49 @@ import { lastValueFrom, takeUntil, timer, toArray } from 'rxjs'
|
|||||||
*/
|
*/
|
||||||
export const fetchContacts = async (
|
export const fetchContacts = async (
|
||||||
relayPool: RelayPool,
|
relayPool: RelayPool,
|
||||||
pubkey: string
|
pubkey: string,
|
||||||
|
onPartial?: (contacts: Set<string>) => void
|
||||||
): Promise<Set<string>> => {
|
): Promise<Set<string>> => {
|
||||||
try {
|
try {
|
||||||
const relayUrls = Array.from(relayPool.relays.values()).map(relay => relay.url)
|
const relayUrls = prioritizeLocalRelays(Array.from(relayPool.relays.values()).map(relay => relay.url))
|
||||||
|
|
||||||
console.log('🔍 Fetching contacts (kind 3) for user:', pubkey)
|
console.log('🔍 Fetching contacts (kind 3) for user:', pubkey)
|
||||||
|
|
||||||
|
// Local-first quick attempt
|
||||||
|
const localRelays = relayUrls.filter(url => url.includes('localhost') || url.includes('127.0.0.1'))
|
||||||
|
const remoteRelays = relayUrls.filter(url => !url.includes('localhost') && !url.includes('127.0.0.1'))
|
||||||
|
const local$ = localRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(localRelays, { kinds: [3], authors: [pubkey] })
|
||||||
|
.pipe(completeOnEose(), takeUntil(timer(1200)))
|
||||||
|
: new Observable<{ created_at: number; tags: string[][] }>((sub) => sub.complete())
|
||||||
|
const remote$ = remoteRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(remoteRelays, { kinds: [3], authors: [pubkey] })
|
||||||
|
.pipe(completeOnEose(), takeUntil(timer(6000)))
|
||||||
|
: new Observable<{ created_at: number; tags: string[][] }>((sub) => sub.complete())
|
||||||
const events = await lastValueFrom(
|
const events = await lastValueFrom(
|
||||||
relayPool
|
merge(local$, remote$).pipe(toArray())
|
||||||
.req(relayUrls, { kinds: [3], authors: [pubkey] })
|
|
||||||
.pipe(completeOnEose(), takeUntil(timer(10000)), toArray())
|
|
||||||
)
|
)
|
||||||
|
const followed = new Set<string>()
|
||||||
|
if (events.length > 0) {
|
||||||
|
// Get the most recent contact list
|
||||||
|
const sortedEvents = events.sort((a, b) => b.created_at - a.created_at)
|
||||||
|
const contactList = sortedEvents[0]
|
||||||
|
// Extract pubkeys from 'p' tags
|
||||||
|
for (const tag of contactList.tags) {
|
||||||
|
if (tag[0] === 'p' && tag[1]) {
|
||||||
|
followed.add(tag[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (onPartial) onPartial(new Set(followed))
|
||||||
|
}
|
||||||
|
// merged already via streams
|
||||||
|
|
||||||
console.log('📊 Contact events fetched:', events.length)
|
console.log('📊 Contact events fetched:', events.length)
|
||||||
|
|
||||||
if (events.length === 0) {
|
console.log('👥 Followed contacts:', followed.size)
|
||||||
return new Set()
|
return followed
|
||||||
}
|
|
||||||
|
|
||||||
// Get the most recent contact list
|
|
||||||
const sortedEvents = events.sort((a, b) => b.created_at - a.created_at)
|
|
||||||
const contactList = sortedEvents[0]
|
|
||||||
|
|
||||||
// Extract pubkeys from 'p' tags
|
|
||||||
const followedPubkeys = new Set<string>()
|
|
||||||
for (const tag of contactList.tags) {
|
|
||||||
if (tag[0] === 'p' && tag[1]) {
|
|
||||||
followedPubkeys.add(tag[1])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('👥 Followed contacts:', followedPubkeys.size)
|
|
||||||
|
|
||||||
return followedPubkeys
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch contacts:', error)
|
console.error('Failed to fetch contacts:', error)
|
||||||
return new Set()
|
return new Set()
|
||||||
|
|||||||
42
src/services/exploreCache.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { NostrEvent } from 'nostr-tools'
|
||||||
|
|
||||||
|
export interface CachedBlogPostPreview {
|
||||||
|
event: NostrEvent
|
||||||
|
title: string
|
||||||
|
summary?: string
|
||||||
|
image?: string
|
||||||
|
published?: number
|
||||||
|
author: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type CacheValue = {
|
||||||
|
posts: CachedBlogPostPreview[]
|
||||||
|
timestamp: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const exploreCache = new Map<string, CacheValue>() // key: pubkey
|
||||||
|
|
||||||
|
export function getCachedPosts(pubkey: string): CachedBlogPostPreview[] | null {
|
||||||
|
const entry = exploreCache.get(pubkey)
|
||||||
|
if (!entry) return null
|
||||||
|
return entry.posts
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setCachedPosts(pubkey: string, posts: CachedBlogPostPreview[]): void {
|
||||||
|
exploreCache.set(pubkey, { posts, timestamp: Date.now() })
|
||||||
|
}
|
||||||
|
|
||||||
|
export function upsertCachedPost(pubkey: string, post: CachedBlogPostPreview): CachedBlogPostPreview[] {
|
||||||
|
const current = exploreCache.get(pubkey)?.posts || []
|
||||||
|
const byId = new Map(current.map(p => [p.event.id, p]))
|
||||||
|
byId.set(post.event.id, post)
|
||||||
|
const merged = Array.from(byId.values()).sort((a, b) => {
|
||||||
|
const ta = a.published || a.event.created_at
|
||||||
|
const tb = b.published || b.event.created_at
|
||||||
|
return tb - ta
|
||||||
|
})
|
||||||
|
setCachedPosts(pubkey, merged)
|
||||||
|
return merged
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { RelayPool, completeOnEose } from 'applesauce-relay'
|
import { RelayPool, completeOnEose } from 'applesauce-relay'
|
||||||
import { lastValueFrom, takeUntil, timer, toArray } from 'rxjs'
|
import { lastValueFrom, merge, Observable, takeUntil, timer, toArray } from 'rxjs'
|
||||||
|
import { prioritizeLocalRelays, partitionRelays } from '../utils/helpers'
|
||||||
import { NostrEvent } from 'nostr-tools'
|
import { NostrEvent } from 'nostr-tools'
|
||||||
import { Helpers } from 'applesauce-core'
|
import { Helpers } from 'applesauce-core'
|
||||||
|
|
||||||
@@ -24,7 +25,8 @@ export interface BlogPostPreview {
|
|||||||
export const fetchBlogPostsFromAuthors = async (
|
export const fetchBlogPostsFromAuthors = async (
|
||||||
relayPool: RelayPool,
|
relayPool: RelayPool,
|
||||||
pubkeys: string[],
|
pubkeys: string[],
|
||||||
relayUrls: string[]
|
relayUrls: string[],
|
||||||
|
onPost?: (post: BlogPostPreview) => void
|
||||||
): Promise<BlogPostPreview[]> => {
|
): Promise<BlogPostPreview[]> => {
|
||||||
try {
|
try {
|
||||||
if (pubkeys.length === 0) {
|
if (pubkeys.length === 0) {
|
||||||
@@ -34,42 +36,65 @@ export const fetchBlogPostsFromAuthors = async (
|
|||||||
|
|
||||||
console.log('📚 Fetching blog posts (kind 30023) from', pubkeys.length, 'authors')
|
console.log('📚 Fetching blog posts (kind 30023) from', pubkeys.length, 'authors')
|
||||||
|
|
||||||
const events = await lastValueFrom(
|
const prioritized = prioritizeLocalRelays(relayUrls)
|
||||||
relayPool
|
const { local: localRelays, remote: remoteRelays } = partitionRelays(prioritized)
|
||||||
.req(relayUrls, {
|
|
||||||
kinds: [30023],
|
|
||||||
authors: pubkeys,
|
|
||||||
limit: 100 // Fetch up to 100 recent posts
|
|
||||||
})
|
|
||||||
.pipe(completeOnEose(), takeUntil(timer(15000)), toArray())
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log('📊 Blog post events fetched:', events.length)
|
|
||||||
|
|
||||||
// Deduplicate replaceable events by keeping the most recent version
|
// Deduplicate replaceable events by keeping the most recent version
|
||||||
// Group by author + d-tag identifier
|
// Group by author + d-tag identifier
|
||||||
const uniqueEvents = new Map<string, NostrEvent>()
|
const uniqueEvents = new Map<string, NostrEvent>()
|
||||||
|
|
||||||
for (const event of events) {
|
const processEvents = (incoming: NostrEvent[]) => {
|
||||||
const dTag = event.tags.find(t => t[0] === 'd')?.[1] || ''
|
for (const event of incoming) {
|
||||||
const key = `${event.pubkey}:${dTag}`
|
const dTag = event.tags.find(t => t[0] === 'd')?.[1] || ''
|
||||||
|
const key = `${event.pubkey}:${dTag}`
|
||||||
const existing = uniqueEvents.get(key)
|
const existing = uniqueEvents.get(key)
|
||||||
if (!existing || event.created_at > existing.created_at) {
|
if (!existing || event.created_at > existing.created_at) {
|
||||||
uniqueEvents.set(key, event)
|
uniqueEvents.set(key, event)
|
||||||
|
// Emit as we incorporate
|
||||||
|
if (onPost) {
|
||||||
|
const post: BlogPostPreview = {
|
||||||
|
event,
|
||||||
|
title: getArticleTitle(event) || 'Untitled',
|
||||||
|
summary: getArticleSummary(event),
|
||||||
|
image: getArticleImage(event),
|
||||||
|
published: getArticlePublished(event),
|
||||||
|
author: event.pubkey
|
||||||
|
}
|
||||||
|
onPost(post)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const local$ = localRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(localRelays, { kinds: [30023], authors: pubkeys, limit: 100 })
|
||||||
|
.pipe(completeOnEose(), takeUntil(timer(1200)))
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const remote$ = remoteRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(remoteRelays, { kinds: [30023], authors: pubkeys, limit: 100 })
|
||||||
|
.pipe(completeOnEose(), takeUntil(timer(6000)))
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const events = await lastValueFrom(merge(local$, remote$).pipe(toArray()))
|
||||||
|
processEvents(events)
|
||||||
|
|
||||||
|
console.log('📊 Blog post events fetched (unique):', uniqueEvents.size)
|
||||||
|
|
||||||
// Convert to blog post previews and sort by published date (most recent first)
|
// Convert to blog post previews and sort by published date (most recent first)
|
||||||
const blogPosts: BlogPostPreview[] = Array.from(uniqueEvents.values())
|
const blogPosts: BlogPostPreview[] = Array.from(uniqueEvents.values())
|
||||||
.map(event => ({
|
.map(event => {
|
||||||
event,
|
const post: BlogPostPreview = {
|
||||||
title: getArticleTitle(event) || 'Untitled',
|
event,
|
||||||
summary: getArticleSummary(event),
|
title: getArticleTitle(event) || 'Untitled',
|
||||||
image: getArticleImage(event),
|
summary: getArticleSummary(event),
|
||||||
published: getArticlePublished(event),
|
image: getArticleImage(event),
|
||||||
author: event.pubkey
|
published: getArticlePublished(event),
|
||||||
}))
|
author: event.pubkey
|
||||||
|
}
|
||||||
|
if (onPost) onPost(post)
|
||||||
|
return post
|
||||||
|
})
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
const timeA = a.published || a.event.created_at
|
const timeA = a.published || a.event.created_at
|
||||||
const timeB = b.published || b.event.created_at
|
const timeB = b.published || b.event.created_at
|
||||||
|
|||||||
@@ -1,204 +1,5 @@
|
|||||||
import { RelayPool, completeOnEose, onlyEvents } from 'applesauce-relay'
|
export * from './highlights/fetchForArticle'
|
||||||
import { lastValueFrom, takeUntil, timer, tap, toArray } from 'rxjs'
|
export * from './highlights/fetchForUrl'
|
||||||
import { NostrEvent } from 'nostr-tools'
|
export * from './highlights/fetchByAuthor'
|
||||||
import { Highlight } from '../types/highlights'
|
|
||||||
import { RELAYS } from '../config/relays'
|
|
||||||
import { eventToHighlight, dedupeHighlights, sortHighlights } from './highlightEventProcessor'
|
|
||||||
import { UserSettings } from './settingsService'
|
|
||||||
import { rebroadcastEvents } from './rebroadcastService'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches highlights for a specific article by its address coordinate and/or event ID
|
|
||||||
* @param relayPool - The relay pool to query
|
|
||||||
* @param articleCoordinate - The article's address in format "kind:pubkey:identifier" (e.g., "30023:abc...def:my-article")
|
|
||||||
* @param eventId - Optional event ID to also query by 'e' tag
|
|
||||||
* @param onHighlight - Optional callback to receive highlights as they arrive
|
|
||||||
* @param settings - User settings for rebroadcast options
|
|
||||||
*/
|
|
||||||
export const fetchHighlightsForArticle = async (
|
|
||||||
relayPool: RelayPool,
|
|
||||||
articleCoordinate: string,
|
|
||||||
eventId?: string,
|
|
||||||
onHighlight?: (highlight: Highlight) => void,
|
|
||||||
settings?: UserSettings
|
|
||||||
): Promise<Highlight[]> => {
|
|
||||||
try {
|
|
||||||
console.log('🔍 Fetching highlights (kind 9802) for article:', articleCoordinate)
|
|
||||||
console.log('🔍 Event ID:', eventId || 'none')
|
|
||||||
console.log('🔍 From relays (including local):', RELAYS)
|
|
||||||
|
|
||||||
const seenIds = new Set<string>()
|
|
||||||
const processEvent = (event: NostrEvent): Highlight | null => {
|
|
||||||
if (seenIds.has(event.id)) return null
|
|
||||||
seenIds.add(event.id)
|
|
||||||
return eventToHighlight(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Query for highlights that reference this article via the 'a' tag
|
|
||||||
const aTagEvents = await lastValueFrom(
|
|
||||||
relayPool
|
|
||||||
.req(RELAYS, { kinds: [9802], '#a': [articleCoordinate] })
|
|
||||||
.pipe(
|
|
||||||
onlyEvents(),
|
|
||||||
tap((event: NostrEvent) => {
|
|
||||||
const highlight = processEvent(event)
|
|
||||||
if (highlight && onHighlight) {
|
|
||||||
onHighlight(highlight)
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
completeOnEose(),
|
|
||||||
takeUntil(timer(10000)),
|
|
||||||
toArray()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log('📊 Highlights via a-tag:', aTagEvents.length)
|
|
||||||
|
|
||||||
// If we have an event ID, also query for highlights that reference via the 'e' tag
|
|
||||||
let eTagEvents: NostrEvent[] = []
|
|
||||||
if (eventId) {
|
|
||||||
eTagEvents = await lastValueFrom(
|
|
||||||
relayPool
|
|
||||||
.req(RELAYS, { kinds: [9802], '#e': [eventId] })
|
|
||||||
.pipe(
|
|
||||||
onlyEvents(),
|
|
||||||
tap((event: NostrEvent) => {
|
|
||||||
const highlight = processEvent(event)
|
|
||||||
if (highlight && onHighlight) {
|
|
||||||
onHighlight(highlight)
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
completeOnEose(),
|
|
||||||
takeUntil(timer(10000)),
|
|
||||||
toArray()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
console.log('📊 Highlights via e-tag:', eTagEvents.length)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Combine results from both queries
|
|
||||||
const rawEvents = [...aTagEvents, ...eTagEvents]
|
|
||||||
console.log('📊 Total raw highlight events fetched:', rawEvents.length)
|
|
||||||
|
|
||||||
// Rebroadcast highlight events to local/all relays based on settings
|
|
||||||
await rebroadcastEvents(rawEvents, relayPool, settings)
|
|
||||||
|
|
||||||
if (rawEvents.length > 0) {
|
|
||||||
console.log('📄 Sample highlight tags:', JSON.stringify(rawEvents[0].tags, null, 2))
|
|
||||||
} else {
|
|
||||||
console.log('❌ No highlights found. Article coordinate:', articleCoordinate)
|
|
||||||
console.log('❌ Event ID:', eventId || 'none')
|
|
||||||
console.log('💡 Try checking if there are any highlights on this article at https://highlighter.com')
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deduplicate events by ID
|
|
||||||
const uniqueEvents = dedupeHighlights(rawEvents)
|
|
||||||
console.log('📊 Unique highlight events after deduplication:', uniqueEvents.length)
|
|
||||||
|
|
||||||
const highlights: Highlight[] = uniqueEvents.map(eventToHighlight)
|
|
||||||
return sortHighlights(highlights)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to fetch highlights for article:', error)
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches highlights for a specific URL
|
|
||||||
* @param relayPool - The relay pool to query
|
|
||||||
* @param url - The external URL to find highlights for
|
|
||||||
* @param settings - User settings for rebroadcast options
|
|
||||||
*/
|
|
||||||
export const fetchHighlightsForUrl = async (
|
|
||||||
relayPool: RelayPool,
|
|
||||||
url: string,
|
|
||||||
settings?: UserSettings
|
|
||||||
): Promise<Highlight[]> => {
|
|
||||||
try {
|
|
||||||
console.log('🔍 Fetching highlights (kind 9802) for URL:', url)
|
|
||||||
|
|
||||||
const seenIds = new Set<string>()
|
|
||||||
const rawEvents = await lastValueFrom(
|
|
||||||
relayPool
|
|
||||||
.req(RELAYS, { kinds: [9802], '#r': [url] })
|
|
||||||
.pipe(
|
|
||||||
onlyEvents(),
|
|
||||||
tap((event: NostrEvent) => {
|
|
||||||
seenIds.add(event.id)
|
|
||||||
}),
|
|
||||||
completeOnEose(),
|
|
||||||
takeUntil(timer(10000)),
|
|
||||||
toArray()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log('📊 Highlights for URL:', rawEvents.length)
|
|
||||||
|
|
||||||
// Rebroadcast highlight events to local/all relays based on settings
|
|
||||||
await rebroadcastEvents(rawEvents, relayPool, settings)
|
|
||||||
|
|
||||||
const uniqueEvents = dedupeHighlights(rawEvents)
|
|
||||||
const highlights: Highlight[] = uniqueEvents.map(eventToHighlight)
|
|
||||||
return sortHighlights(highlights)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to fetch highlights for URL:', error)
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches highlights created by a specific user
|
|
||||||
* @param relayPool - The relay pool to query
|
|
||||||
* @param pubkey - The user's public key
|
|
||||||
* @param onHighlight - Optional callback to receive highlights as they arrive
|
|
||||||
* @param settings - User settings for rebroadcast options
|
|
||||||
*/
|
|
||||||
export const fetchHighlights = async (
|
|
||||||
relayPool: RelayPool,
|
|
||||||
pubkey: string,
|
|
||||||
onHighlight?: (highlight: Highlight) => void,
|
|
||||||
settings?: UserSettings
|
|
||||||
): Promise<Highlight[]> => {
|
|
||||||
try {
|
|
||||||
const relayUrls = Array.from(relayPool.relays.values()).map(relay => relay.url)
|
|
||||||
|
|
||||||
console.log('🔍 Fetching highlights (kind 9802) by author:', pubkey)
|
|
||||||
|
|
||||||
const seenIds = new Set<string>()
|
|
||||||
const rawEvents = await lastValueFrom(
|
|
||||||
relayPool
|
|
||||||
.req(relayUrls, { kinds: [9802], authors: [pubkey] })
|
|
||||||
.pipe(
|
|
||||||
onlyEvents(),
|
|
||||||
tap((event: NostrEvent) => {
|
|
||||||
if (!seenIds.has(event.id)) {
|
|
||||||
seenIds.add(event.id)
|
|
||||||
const highlight = eventToHighlight(event)
|
|
||||||
if (onHighlight) {
|
|
||||||
onHighlight(highlight)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
completeOnEose(),
|
|
||||||
takeUntil(timer(10000)),
|
|
||||||
toArray()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log('📊 Raw highlight events fetched:', rawEvents.length)
|
|
||||||
|
|
||||||
// Rebroadcast highlight events to local/all relays based on settings
|
|
||||||
await rebroadcastEvents(rawEvents, relayPool, settings)
|
|
||||||
|
|
||||||
// Deduplicate and process events
|
|
||||||
const uniqueEvents = dedupeHighlights(rawEvents)
|
|
||||||
console.log('📊 Unique highlight events after deduplication:', uniqueEvents.length)
|
|
||||||
|
|
||||||
const highlights: Highlight[] = uniqueEvents.map(eventToHighlight)
|
|
||||||
return sortHighlights(highlights)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to fetch highlights by author:', error)
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
63
src/services/highlights/fetchByAuthor.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import { RelayPool, completeOnEose, onlyEvents } from 'applesauce-relay'
|
||||||
|
import { lastValueFrom, merge, Observable, takeUntil, timer, tap, toArray } from 'rxjs'
|
||||||
|
import { NostrEvent } from 'nostr-tools'
|
||||||
|
import { Highlight } from '../../types/highlights'
|
||||||
|
import { prioritizeLocalRelays, partitionRelays } from '../../utils/helpers'
|
||||||
|
import { eventToHighlight, dedupeHighlights, sortHighlights } from '../highlightEventProcessor'
|
||||||
|
import { UserSettings } from '../settingsService'
|
||||||
|
import { rebroadcastEvents } from '../rebroadcastService'
|
||||||
|
|
||||||
|
export const fetchHighlights = async (
|
||||||
|
relayPool: RelayPool,
|
||||||
|
pubkey: string,
|
||||||
|
onHighlight?: (highlight: Highlight) => void,
|
||||||
|
settings?: UserSettings
|
||||||
|
): Promise<Highlight[]> => {
|
||||||
|
try {
|
||||||
|
const relayUrls = Array.from(relayPool.relays.values()).map(relay => relay.url)
|
||||||
|
const ordered = prioritizeLocalRelays(relayUrls)
|
||||||
|
const { local: localRelays, remote: remoteRelays } = partitionRelays(ordered)
|
||||||
|
|
||||||
|
const seenIds = new Set<string>()
|
||||||
|
const local$ = localRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(localRelays, { kinds: [9802], authors: [pubkey] })
|
||||||
|
.pipe(
|
||||||
|
onlyEvents(),
|
||||||
|
tap((event: NostrEvent) => {
|
||||||
|
if (!seenIds.has(event.id)) {
|
||||||
|
seenIds.add(event.id)
|
||||||
|
if (onHighlight) onHighlight(eventToHighlight(event))
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
completeOnEose(),
|
||||||
|
takeUntil(timer(1200))
|
||||||
|
)
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const remote$ = remoteRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(remoteRelays, { kinds: [9802], authors: [pubkey] })
|
||||||
|
.pipe(
|
||||||
|
onlyEvents(),
|
||||||
|
tap((event: NostrEvent) => {
|
||||||
|
if (!seenIds.has(event.id)) {
|
||||||
|
seenIds.add(event.id)
|
||||||
|
if (onHighlight) onHighlight(eventToHighlight(event))
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
completeOnEose(),
|
||||||
|
takeUntil(timer(6000))
|
||||||
|
)
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const rawEvents: NostrEvent[] = await lastValueFrom(merge(local$, remote$).pipe(toArray()))
|
||||||
|
|
||||||
|
await rebroadcastEvents(rawEvents, relayPool, settings)
|
||||||
|
const uniqueEvents = dedupeHighlights(rawEvents)
|
||||||
|
const highlights = uniqueEvents.map(eventToHighlight)
|
||||||
|
return sortHighlights(highlights)
|
||||||
|
} catch {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
98
src/services/highlights/fetchForArticle.ts
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
import { RelayPool, completeOnEose, onlyEvents } from 'applesauce-relay'
|
||||||
|
import { lastValueFrom, merge, Observable, takeUntil, timer, tap, toArray } from 'rxjs'
|
||||||
|
import { NostrEvent } from 'nostr-tools'
|
||||||
|
import { Highlight } from '../../types/highlights'
|
||||||
|
import { RELAYS } from '../../config/relays'
|
||||||
|
import { prioritizeLocalRelays, partitionRelays } from '../../utils/helpers'
|
||||||
|
import { eventToHighlight, dedupeHighlights, sortHighlights } from '../highlightEventProcessor'
|
||||||
|
import { UserSettings } from '../settingsService'
|
||||||
|
import { rebroadcastEvents } from '../rebroadcastService'
|
||||||
|
|
||||||
|
export const fetchHighlightsForArticle = async (
|
||||||
|
relayPool: RelayPool,
|
||||||
|
articleCoordinate: string,
|
||||||
|
eventId?: string,
|
||||||
|
onHighlight?: (highlight: Highlight) => void,
|
||||||
|
settings?: UserSettings
|
||||||
|
): Promise<Highlight[]> => {
|
||||||
|
try {
|
||||||
|
const seenIds = new Set<string>()
|
||||||
|
const processEvent = (event: NostrEvent): Highlight | null => {
|
||||||
|
if (seenIds.has(event.id)) return null
|
||||||
|
seenIds.add(event.id)
|
||||||
|
return eventToHighlight(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
const orderedRelays = prioritizeLocalRelays(RELAYS)
|
||||||
|
const { local: localRelays, remote: remoteRelays } = partitionRelays(orderedRelays)
|
||||||
|
|
||||||
|
const aLocal$ = localRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(localRelays, { kinds: [9802], '#a': [articleCoordinate] })
|
||||||
|
.pipe(
|
||||||
|
onlyEvents(),
|
||||||
|
tap((event: NostrEvent) => {
|
||||||
|
const highlight = processEvent(event)
|
||||||
|
if (highlight && onHighlight) onHighlight(highlight)
|
||||||
|
}),
|
||||||
|
completeOnEose(),
|
||||||
|
takeUntil(timer(1200))
|
||||||
|
)
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const aRemote$ = remoteRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(remoteRelays, { kinds: [9802], '#a': [articleCoordinate] })
|
||||||
|
.pipe(
|
||||||
|
onlyEvents(),
|
||||||
|
tap((event: NostrEvent) => {
|
||||||
|
const highlight = processEvent(event)
|
||||||
|
if (highlight && onHighlight) onHighlight(highlight)
|
||||||
|
}),
|
||||||
|
completeOnEose(),
|
||||||
|
takeUntil(timer(6000))
|
||||||
|
)
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const aTagEvents: NostrEvent[] = await lastValueFrom(merge(aLocal$, aRemote$).pipe(toArray()))
|
||||||
|
|
||||||
|
let eTagEvents: NostrEvent[] = []
|
||||||
|
if (eventId) {
|
||||||
|
const eLocal$ = localRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(localRelays, { kinds: [9802], '#e': [eventId] })
|
||||||
|
.pipe(
|
||||||
|
onlyEvents(),
|
||||||
|
tap((event: NostrEvent) => {
|
||||||
|
const highlight = processEvent(event)
|
||||||
|
if (highlight && onHighlight) onHighlight(highlight)
|
||||||
|
}),
|
||||||
|
completeOnEose(),
|
||||||
|
takeUntil(timer(1200))
|
||||||
|
)
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const eRemote$ = remoteRelays.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(remoteRelays, { kinds: [9802], '#e': [eventId] })
|
||||||
|
.pipe(
|
||||||
|
onlyEvents(),
|
||||||
|
tap((event: NostrEvent) => {
|
||||||
|
const highlight = processEvent(event)
|
||||||
|
if (highlight && onHighlight) onHighlight(highlight)
|
||||||
|
}),
|
||||||
|
completeOnEose(),
|
||||||
|
takeUntil(timer(6000))
|
||||||
|
)
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
eTagEvents = await lastValueFrom(merge(eLocal$, eRemote$).pipe(toArray()))
|
||||||
|
}
|
||||||
|
|
||||||
|
const rawEvents = [...aTagEvents, ...eTagEvents]
|
||||||
|
await rebroadcastEvents(rawEvents, relayPool, settings)
|
||||||
|
const uniqueEvents = dedupeHighlights(rawEvents)
|
||||||
|
const highlights: Highlight[] = uniqueEvents.map(eventToHighlight)
|
||||||
|
return sortHighlights(highlights)
|
||||||
|
} catch {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
57
src/services/highlights/fetchForUrl.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import { RelayPool, completeOnEose, onlyEvents } from 'applesauce-relay'
|
||||||
|
import { lastValueFrom, merge, Observable, takeUntil, timer, tap, toArray } from 'rxjs'
|
||||||
|
import { NostrEvent } from 'nostr-tools'
|
||||||
|
import { Highlight } from '../../types/highlights'
|
||||||
|
import { RELAYS } from '../../config/relays'
|
||||||
|
import { prioritizeLocalRelays, partitionRelays } from '../../utils/helpers'
|
||||||
|
import { eventToHighlight, dedupeHighlights, sortHighlights } from '../highlightEventProcessor'
|
||||||
|
import { UserSettings } from '../settingsService'
|
||||||
|
import { rebroadcastEvents } from '../rebroadcastService'
|
||||||
|
|
||||||
|
export const fetchHighlightsForUrl = async (
|
||||||
|
relayPool: RelayPool,
|
||||||
|
url: string,
|
||||||
|
onHighlight?: (highlight: Highlight) => void,
|
||||||
|
settings?: UserSettings
|
||||||
|
): Promise<Highlight[]> => {
|
||||||
|
try {
|
||||||
|
const seenIds = new Set<string>()
|
||||||
|
const orderedRelaysUrl = prioritizeLocalRelays(RELAYS)
|
||||||
|
const { local: localRelaysUrl, remote: remoteRelaysUrl } = partitionRelays(orderedRelaysUrl)
|
||||||
|
const local$ = localRelaysUrl.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(localRelaysUrl, { kinds: [9802], '#r': [url] })
|
||||||
|
.pipe(
|
||||||
|
onlyEvents(),
|
||||||
|
tap((event: NostrEvent) => {
|
||||||
|
seenIds.add(event.id)
|
||||||
|
if (onHighlight) onHighlight(eventToHighlight(event))
|
||||||
|
}),
|
||||||
|
completeOnEose(),
|
||||||
|
takeUntil(timer(1200))
|
||||||
|
)
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const remote$ = remoteRelaysUrl.length > 0
|
||||||
|
? relayPool
|
||||||
|
.req(remoteRelaysUrl, { kinds: [9802], '#r': [url] })
|
||||||
|
.pipe(
|
||||||
|
onlyEvents(),
|
||||||
|
tap((event: NostrEvent) => {
|
||||||
|
seenIds.add(event.id)
|
||||||
|
if (onHighlight) onHighlight(eventToHighlight(event))
|
||||||
|
}),
|
||||||
|
completeOnEose(),
|
||||||
|
takeUntil(timer(6000))
|
||||||
|
)
|
||||||
|
: new Observable<NostrEvent>((sub) => sub.complete())
|
||||||
|
const rawEvents: NostrEvent[] = await lastValueFrom(merge(local$, remote$).pipe(toArray()))
|
||||||
|
await rebroadcastEvents(rawEvents, relayPool, settings)
|
||||||
|
const uniqueEvents = dedupeHighlights(rawEvents)
|
||||||
|
const highlights: Highlight[] = uniqueEvents.map(eventToHighlight)
|
||||||
|
return sortHighlights(highlights)
|
||||||
|
} catch {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
111
src/sw.ts
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/// <reference lib="webworker" />
|
||||||
|
/* eslint-env worker */
|
||||||
|
/* global ServiceWorkerGlobalScope, ExtendableMessageEvent, FetchEvent */
|
||||||
|
import { clientsClaim } from 'workbox-core'
|
||||||
|
import { precacheAndRoute, cleanupOutdatedCaches } from 'workbox-precaching'
|
||||||
|
import { registerRoute, NavigationRoute } from 'workbox-routing'
|
||||||
|
import { StaleWhileRevalidate } from 'workbox-strategies'
|
||||||
|
import { ExpirationPlugin } from 'workbox-expiration'
|
||||||
|
import { CacheableResponsePlugin } from 'workbox-cacheable-response'
|
||||||
|
|
||||||
|
// Narrow the global service worker scope for proper typings
|
||||||
|
const sw = self as unknown as ServiceWorkerGlobalScope
|
||||||
|
|
||||||
|
// Precache all build assets (app shell)
|
||||||
|
// @ts-ignore - __WB_MANIFEST is injected by vite-plugin-pwa
|
||||||
|
precacheAndRoute(self.__WB_MANIFEST)
|
||||||
|
|
||||||
|
// Clean up old caches
|
||||||
|
cleanupOutdatedCaches()
|
||||||
|
|
||||||
|
// Take control immediately
|
||||||
|
sw.skipWaiting()
|
||||||
|
clientsClaim()
|
||||||
|
|
||||||
|
console.log('[SW] Boris service worker loaded')
|
||||||
|
|
||||||
|
// Runtime cache: Cross-origin images
|
||||||
|
// This preserves the existing image caching behavior
|
||||||
|
registerRoute(
|
||||||
|
({ request, url }) => {
|
||||||
|
const isImage = request.destination === 'image' ||
|
||||||
|
/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(url.pathname)
|
||||||
|
return isImage && url.origin !== sw.location.origin
|
||||||
|
},
|
||||||
|
new StaleWhileRevalidate({
|
||||||
|
cacheName: 'boris-images',
|
||||||
|
plugins: [
|
||||||
|
new ExpirationPlugin({
|
||||||
|
maxEntries: 300,
|
||||||
|
maxAgeSeconds: 60 * 60 * 24 * 30, // 30 days
|
||||||
|
}),
|
||||||
|
new CacheableResponsePlugin({
|
||||||
|
statuses: [0, 200],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
// Runtime cache: Cross-origin article HTML
|
||||||
|
// Cache fetched articles for offline reading
|
||||||
|
registerRoute(
|
||||||
|
({ request, url }) => {
|
||||||
|
const accept = request.headers.get('accept') || ''
|
||||||
|
const isHTML = accept.includes('text/html')
|
||||||
|
const isCrossOrigin = url.origin !== sw.location.origin
|
||||||
|
// Exclude relay connections and local URLs
|
||||||
|
const isNotRelay = !url.protocol.includes('ws')
|
||||||
|
return isHTML && isCrossOrigin && isNotRelay
|
||||||
|
},
|
||||||
|
new StaleWhileRevalidate({
|
||||||
|
cacheName: 'boris-articles',
|
||||||
|
plugins: [
|
||||||
|
new ExpirationPlugin({
|
||||||
|
maxEntries: 100,
|
||||||
|
maxAgeSeconds: 60 * 60 * 24 * 14, // 14 days
|
||||||
|
}),
|
||||||
|
new CacheableResponsePlugin({
|
||||||
|
statuses: [0, 200],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
// SPA navigation fallback - serve app shell for navigation requests
|
||||||
|
// This ensures the app loads offline
|
||||||
|
const navigationRoute = new NavigationRoute(
|
||||||
|
async ({ request }) => {
|
||||||
|
try {
|
||||||
|
// Try to fetch from network first
|
||||||
|
const response = await fetch(request)
|
||||||
|
return response
|
||||||
|
} catch (error) {
|
||||||
|
// If offline, serve the cached app shell
|
||||||
|
const cache = await caches.match('/index.html')
|
||||||
|
if (cache) {
|
||||||
|
return cache
|
||||||
|
}
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
registerRoute(navigationRoute)
|
||||||
|
|
||||||
|
// Listen for messages from the app
|
||||||
|
sw.addEventListener('message', (event: ExtendableMessageEvent) => {
|
||||||
|
if (event.data && event.data.type === 'SKIP_WAITING') {
|
||||||
|
sw.skipWaiting()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Log fetch errors for debugging (doesn't affect functionality)
|
||||||
|
sw.addEventListener('fetch', (event: FetchEvent) => {
|
||||||
|
const url = new URL(event.request.url)
|
||||||
|
|
||||||
|
// Don't interfere with WebSocket connections (relay traffic)
|
||||||
|
if (url.protocol === 'ws:' || url.protocol === 'wss:') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
@@ -63,3 +63,58 @@ export const hasRemoteRelay = (relayUrls: string[]): boolean => {
|
|||||||
return relayUrls.some(url => !isLocalRelay(url))
|
return relayUrls.some(url => !isLocalRelay(url))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splits relay URLs into local and remote groups
|
||||||
|
*/
|
||||||
|
export const partitionRelays = (
|
||||||
|
relayUrls: string[]
|
||||||
|
): { local: string[]; remote: string[] } => {
|
||||||
|
const local: string[] = []
|
||||||
|
const remote: string[] = []
|
||||||
|
for (const url of relayUrls) {
|
||||||
|
if (isLocalRelay(url)) local.push(url)
|
||||||
|
else remote.push(url)
|
||||||
|
}
|
||||||
|
return { local, remote }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns relays ordered with local first while keeping uniqueness
|
||||||
|
*/
|
||||||
|
export const prioritizeLocalRelays = (relayUrls: string[]): string[] => {
|
||||||
|
const { local, remote } = partitionRelays(relayUrls)
|
||||||
|
const seen = new Set<string>()
|
||||||
|
const out: string[] = []
|
||||||
|
for (const url of [...local, ...remote]) {
|
||||||
|
if (!seen.has(url)) {
|
||||||
|
seen.add(url)
|
||||||
|
out.push(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parallel request helper
|
||||||
|
import { completeOnEose, onlyEvents, RelayPool } from 'applesauce-relay'
|
||||||
|
import { Observable, takeUntil, timer } from 'rxjs'
|
||||||
|
|
||||||
|
export function createParallelReqStreams(
|
||||||
|
relayPool: RelayPool,
|
||||||
|
localRelays: string[],
|
||||||
|
remoteRelays: string[],
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
filter: any,
|
||||||
|
localTimeoutMs = 1200,
|
||||||
|
remoteTimeoutMs = 6000
|
||||||
|
): { local$: Observable<unknown>; remote$: Observable<unknown> } {
|
||||||
|
const local$ = (localRelays.length > 0)
|
||||||
|
? relayPool.req(localRelays, filter).pipe(onlyEvents(), completeOnEose(), takeUntil(timer(localTimeoutMs)))
|
||||||
|
: new Observable<unknown>((sub) => { sub.complete() })
|
||||||
|
|
||||||
|
const remote$ = (remoteRelays.length > 0)
|
||||||
|
? relayPool.req(remoteRelays, filter).pipe(onlyEvents(), completeOnEose(), takeUntil(timer(remoteTimeoutMs)))
|
||||||
|
: new Observable<unknown>((sub) => { sub.complete() })
|
||||||
|
|
||||||
|
return { local$, remote$ }
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { decode, npubEncode, noteEncode } from 'nostr-tools/nip19'
|
import { decode, npubEncode, noteEncode } from 'nostr-tools/nip19'
|
||||||
|
import { getNostrUrl } from '../config/nostrGateways'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regular expression to match nostr: URIs and bare NIP-19 identifiers
|
* Regular expression to match nostr: URIs and bare NIP-19 identifiers
|
||||||
@@ -39,7 +40,7 @@ export function extractNaddrUris(text: string): string[] {
|
|||||||
/**
|
/**
|
||||||
* Decode a NIP-19 identifier and return a human-readable link
|
* Decode a NIP-19 identifier and return a human-readable link
|
||||||
* For articles (naddr), returns an internal app link
|
* For articles (naddr), returns an internal app link
|
||||||
* For other types, returns an external njump.me link
|
* For other types, returns an external gateway link
|
||||||
*/
|
*/
|
||||||
export function createNostrLink(encoded: string): string {
|
export function createNostrLink(encoded: string): string {
|
||||||
try {
|
try {
|
||||||
@@ -53,13 +54,13 @@ export function createNostrLink(encoded: string): string {
|
|||||||
case 'nprofile':
|
case 'nprofile':
|
||||||
case 'note':
|
case 'note':
|
||||||
case 'nevent':
|
case 'nevent':
|
||||||
return `https://njump.me/${encoded}`
|
return getNostrUrl(encoded)
|
||||||
default:
|
default:
|
||||||
return `https://njump.me/${encoded}`
|
return getNostrUrl(encoded)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Failed to decode nostr URI:', encoded, error)
|
console.warn('Failed to decode nostr URI:', encoded, error)
|
||||||
return `https://njump.me/${encoded}`
|
return getNostrUrl(encoded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,43 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
|
import { VitePWA } from 'vite-plugin-pwa'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [
|
||||||
|
react(),
|
||||||
|
VitePWA({
|
||||||
|
strategies: 'injectManifest',
|
||||||
|
srcDir: 'src',
|
||||||
|
filename: 'sw.ts',
|
||||||
|
injectRegister: null,
|
||||||
|
manifest: {
|
||||||
|
name: 'Boris - Nostr Bookmarks',
|
||||||
|
short_name: 'Boris',
|
||||||
|
description: 'Your reading list for the Nostr world. A minimal nostr client for bookmark management with highlights.',
|
||||||
|
start_url: '/',
|
||||||
|
scope: '/',
|
||||||
|
display: 'standalone',
|
||||||
|
theme_color: '#0f172a',
|
||||||
|
background_color: '#0b1220',
|
||||||
|
orientation: 'any',
|
||||||
|
categories: ['productivity', 'social', 'utilities'],
|
||||||
|
icons: [
|
||||||
|
{ src: '/icon-192.png', sizes: '192x192', type: 'image/png' },
|
||||||
|
{ src: '/icon-512.png', sizes: '512x512', type: 'image/png' },
|
||||||
|
{ src: '/icon-maskable-192.png', sizes: '192x192', type: 'image/png', purpose: 'maskable' },
|
||||||
|
{ src: '/icon-maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
injectManifest: {
|
||||||
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,webp}'],
|
||||||
|
globIgnores: ['**/_headers', '**/_redirects', '**/robots.txt']
|
||||||
|
},
|
||||||
|
devOptions: {
|
||||||
|
enabled: true,
|
||||||
|
type: 'module'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
],
|
||||||
server: {
|
server: {
|
||||||
port: 9802
|
port: 9802
|
||||||
},
|
},
|
||||||
|
|||||||