-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Handle SendDb deeplink in its own hook
- Loading branch information
Showing
3 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/app/domain/offline/hooks/useOfflineDebugUniversalLinks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useEffect } from 'react' | ||
import { Linking } from 'react-native' | ||
|
||
import CozyClient from 'cozy-client' | ||
import Minilog from 'cozy-minilog' | ||
|
||
import { handleDbDeepLink } from '/pouchdb/deeplinkHandler' | ||
|
||
const log = Minilog('useOfflineDebugUniversalLinks') | ||
|
||
export const useOfflineDebugUniversalLinks = (client: CozyClient): void => { | ||
useEffect(() => { | ||
const subscription = Linking.addEventListener('url', ({ url }) => { | ||
log.debug(`🔗 Linking URL is ${url}`) | ||
if (handleDbDeepLink(url, client)) { | ||
return | ||
} | ||
}) | ||
|
||
return () => { | ||
subscription.remove() | ||
} | ||
}, [client]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters