mirror of
https://github.com/dergigi/boris.git
synced 2025-12-19 15:44:20 +01:00
fix: resolve TypeScript type errors in offline sync
- Import IAccount from applesauce-accounts (not applesauce-core) - Remove unused account parameter from syncLocalEventsToRemote - Fix undefined vs null type mismatch in Bookmarks component - All linter and type checks now pass cleanly
This commit is contained in:
@@ -58,7 +58,7 @@ const Bookmarks: React.FC<BookmarksProps> = ({ relayPool, onLogout }) => {
|
|||||||
// Automatically sync local events to remote relays when coming back online
|
// Automatically sync local events to remote relays when coming back online
|
||||||
useOfflineSync({
|
useOfflineSync({
|
||||||
relayPool,
|
relayPool,
|
||||||
account: activeAccount,
|
account: activeAccount || null,
|
||||||
eventStore,
|
eventStore,
|
||||||
relayStatuses,
|
relayStatuses,
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useRef } from 'react'
|
import { useEffect, useRef } from 'react'
|
||||||
import { RelayPool } from 'applesauce-relay'
|
import { RelayPool } from 'applesauce-relay'
|
||||||
import { IAccount, IEventStore } from 'applesauce-core'
|
import { IAccount } from 'applesauce-accounts'
|
||||||
|
import { IEventStore } from 'applesauce-core'
|
||||||
import { syncLocalEventsToRemote } from '../services/offlineSyncService'
|
import { syncLocalEventsToRemote } from '../services/offlineSyncService'
|
||||||
import { isLocalRelay } from '../utils/helpers'
|
import { isLocalRelay } from '../utils/helpers'
|
||||||
import { RelayStatus } from '../services/relayStatusService'
|
import { RelayStatus } from '../services/relayStatusService'
|
||||||
@@ -15,7 +16,7 @@ interface UseOfflineSyncParams {
|
|||||||
|
|
||||||
export function useOfflineSync({
|
export function useOfflineSync({
|
||||||
relayPool,
|
relayPool,
|
||||||
account,
|
account: _account,
|
||||||
eventStore,
|
eventStore,
|
||||||
relayStatuses,
|
relayStatuses,
|
||||||
enabled = true
|
enabled = true
|
||||||
@@ -29,7 +30,7 @@ export function useOfflineSync({
|
|||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!enabled || !relayPool || !account || !eventStore) return
|
if (!enabled || !relayPool || !_account || !eventStore) return
|
||||||
|
|
||||||
const connectedRelays = relayStatuses.filter(r => r.isInPool)
|
const connectedRelays = relayStatuses.filter(r => r.isInPool)
|
||||||
const hasRemoteRelays = connectedRelays.some(r => !isLocalRelay(r.url))
|
const hasRemoteRelays = connectedRelays.some(r => !isLocalRelay(r.url))
|
||||||
@@ -59,11 +60,11 @@ export function useOfflineSync({
|
|||||||
// Wait a moment for relays to fully establish connections
|
// Wait a moment for relays to fully establish connections
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.log('🚀 Starting sync after delay...')
|
console.log('🚀 Starting sync after delay...')
|
||||||
syncLocalEventsToRemote(relayPool, account, eventStore)
|
syncLocalEventsToRemote(relayPool, eventStore)
|
||||||
}, 2000)
|
}, 2000)
|
||||||
}
|
}
|
||||||
|
|
||||||
previousStateRef.current.hasRemoteRelays = hasRemoteRelays
|
previousStateRef.current.hasRemoteRelays = hasRemoteRelays
|
||||||
}, [relayPool, account, eventStore, relayStatuses, enabled])
|
}, [relayPool, _account, eventStore, relayStatuses, enabled])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { RelayPool } from 'applesauce-relay'
|
import { RelayPool } from 'applesauce-relay'
|
||||||
import { NostrEvent } from 'nostr-tools'
|
import { NostrEvent } from 'nostr-tools'
|
||||||
import { IAccount, IEventStore } from 'applesauce-core'
|
import { IEventStore } from 'applesauce-core'
|
||||||
import { RELAYS } from '../config/relays'
|
import { RELAYS } from '../config/relays'
|
||||||
import { isLocalRelay } from '../utils/helpers'
|
import { isLocalRelay } from '../utils/helpers'
|
||||||
|
|
||||||
@@ -54,7 +54,6 @@ function notifySyncStateChange(eventId: string, isSyncing: boolean): void {
|
|||||||
*/
|
*/
|
||||||
export async function syncLocalEventsToRemote(
|
export async function syncLocalEventsToRemote(
|
||||||
relayPool: RelayPool,
|
relayPool: RelayPool,
|
||||||
account: IAccount,
|
|
||||||
eventStore: IEventStore
|
eventStore: IEventStore
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (isSyncing) {
|
if (isSyncing) {
|
||||||
|
|||||||
Reference in New Issue
Block a user