-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: open reader / default mode lines with memory
Persists too across app restarts Closes #286
- Loading branch information
1 parent
f2906b0
commit c9c6e59
Showing
9 changed files
with
103 additions
and
33 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
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { Redirect } from 'expo-router' | ||
|
||
const Index = () => <Redirect href="/content/shabad/DMP" /> | ||
import { getLastContentPath } from '~/services/history/last-content-path' | ||
|
||
const lastContentPath = getLastContentPath() | ||
|
||
const Index = () => ( lastContentPath | ||
? <Redirect href={lastContentPath} /> | ||
: <Redirect href="/content/shabad/DMP" /> ) | ||
|
||
export default Index |
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
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
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
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
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
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,22 @@ | ||
import { useLocalSearchParams } from 'expo-router' | ||
import { useEffect } from 'react' | ||
|
||
import { mmkv } from '~/services/kv-storage' | ||
|
||
const key = 'last-content-params' | ||
|
||
export const getLastContentPath = () => { | ||
const params = mmkv.getJSON( key ) | ||
|
||
return params | ||
? { pathname: '/content/[type]/[id]', params } as const | ||
: undefined | ||
} | ||
|
||
export const useSaveContentPath = () => { | ||
const params = useLocalSearchParams<{ lineId?: string }>() | ||
|
||
useEffect( () => { | ||
mmkv.set( key, params ) | ||
}, [ params ] ) | ||
} |
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