mirror of
https://github.com/dergigi/boris.git
synced 2026-02-10 09:34:49 +01:00
fix: resolve TypeScript type issues
- Update AccountWithExtension interface to be more flexible - Add type guard for runtime type checking - Change fetchBookmarks parameter to accept unknown type with validation - All linting and type checks now pass
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
---
|
||||
description: applesauce reference documentation and examples
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
|
||||
@@ -22,7 +22,13 @@ interface ApplesauceBookmarks {
|
||||
|
||||
interface AccountWithExtension {
|
||||
pubkey: string
|
||||
[key: string]: unknown // Allow other properties from the full account object
|
||||
signer?: unknown
|
||||
[key: string]: unknown // Allow any properties from the full account object
|
||||
}
|
||||
|
||||
// Type guard to check if an object has the required properties
|
||||
function isAccountWithExtension(account: unknown): account is AccountWithExtension {
|
||||
return typeof account === 'object' && account !== null && 'pubkey' in account
|
||||
}
|
||||
|
||||
|
||||
@@ -85,13 +91,19 @@ const processApplesauceBookmarks = (
|
||||
|
||||
export const fetchBookmarks = async (
|
||||
relayPool: RelayPool,
|
||||
activeAccount: AccountWithExtension, // Full account object with extension capabilities
|
||||
activeAccount: unknown, // Full account object with extension capabilities
|
||||
setBookmarks: (bookmarks: Bookmark[]) => void,
|
||||
setLoading: (loading: boolean) => void,
|
||||
timeoutId: number
|
||||
) => {
|
||||
try {
|
||||
setLoading(true)
|
||||
|
||||
// Type check the account object
|
||||
if (!isAccountWithExtension(activeAccount)) {
|
||||
throw new Error('Invalid account object provided')
|
||||
}
|
||||
|
||||
console.log('🚀 Using applesauce bookmark helpers for pubkey:', activeAccount.pubkey)
|
||||
|
||||
// Get relay URLs from the pool
|
||||
|
||||
Reference in New Issue
Block a user