@youversion/platform-react-hooks 1.7.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/AGENTS.md +183 -0
- package/CHANGELOG.md +22 -0
- package/dist/useFilteredVersions.d.ts +1 -1
- package/dist/useFilteredVersions.d.ts.map +1 -1
- package/dist/useFilteredVersions.js +7 -2
- package/dist/useFilteredVersions.js.map +1 -1
- package/package.json +2 -2
- package/src/useFilteredVersions.test.tsx +58 -0
- package/src/useFilteredVersions.ts +8 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @youversion/platform-react-hooks@1.
|
|
2
|
+
> @youversion/platform-react-hooks@1.8.1 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
|
|
3
3
|
> tsc -p tsconfig.build.json
|
|
4
4
|
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# @youversion/platform-react-hooks
|
|
2
|
+
|
|
3
|
+
## OVERVIEW
|
|
4
|
+
React integration layer providing data fetching hooks with 3 core providers: YouVersionProvider, YouVersionAuthProvider, and ReaderProvider.
|
|
5
|
+
|
|
6
|
+
**Depends on `@youversion/platform-core` for all API calls.** Hooks delegate to core clients; do not implement raw HTTP here.
|
|
7
|
+
|
|
8
|
+
**Related packages:**
|
|
9
|
+
- For lower-level API clients → see `packages/core/AGENTS.md`
|
|
10
|
+
- For pre-built UI components → see `packages/ui/AGENTS.md`
|
|
11
|
+
|
|
12
|
+
## STRUCTURE
|
|
13
|
+
- `use*.ts` - Data fetching hooks (useBook, useChapter, usePassage, useVersion, etc.)
|
|
14
|
+
- `context/` - Providers and contexts (separate files, exported via index.ts)
|
|
15
|
+
- `utility/` - Helper functions (useDebounce, extractTextFromHTML, extractVersesFromHTML)
|
|
16
|
+
|
|
17
|
+
## PUBLIC API
|
|
18
|
+
- Data fetching hooks: useBook, useChapter, usePassage, useVersion, useVOTD, useVerse, useChapterNavigation, etc.
|
|
19
|
+
- YouVersionProvider - Core SDK configuration
|
|
20
|
+
- YouVersionAuthProvider - Authentication state
|
|
21
|
+
- ReaderProvider - Reading session context
|
|
22
|
+
- Utility functions exported from utility/index
|
|
23
|
+
|
|
24
|
+
## PROVIDERS
|
|
25
|
+
|
|
26
|
+
- **YouVersionProvider**
|
|
27
|
+
- Holds core SDK configuration (API base URL, clients)
|
|
28
|
+
- Wrap this around your app before using any data hooks
|
|
29
|
+
|
|
30
|
+
- **YouVersionAuthProvider**
|
|
31
|
+
- Manages authentication state (userInfo, tokens, isLoading, error)
|
|
32
|
+
- Auth hooks like `useYVAuth` depend on this provider
|
|
33
|
+
|
|
34
|
+
- **ReaderProvider**
|
|
35
|
+
- Manages Bible reading session state (currentVersion, currentChapter, currentBook, currentVerse)
|
|
36
|
+
- Hooks like `useChapterNavigation` depend on this provider
|
|
37
|
+
|
|
38
|
+
## DOs / DON'Ts
|
|
39
|
+
|
|
40
|
+
✅ Do: Use `YouVersionProvider` for configuration and access that config in hooks
|
|
41
|
+
✅ Do: Wrap async data access in hooks rather than calling core clients directly in components
|
|
42
|
+
✅ Do: Keep hooks **UI-agnostic** (no JSX returned, no direct DOM manipulation)
|
|
43
|
+
✅ Do: Use the `useApiData` pattern for new data fetching hooks
|
|
44
|
+
|
|
45
|
+
❌ Don't: Import components from `@youversion/platform-react-ui`
|
|
46
|
+
❌ Don't: Talk directly to `fetch`/HTTP; always use `@youversion/platform-core`
|
|
47
|
+
❌ Don't: Access `window.localStorage` directly for auth; rely on core's storage abstractions
|
|
48
|
+
|
|
49
|
+
## DATA FETCHING PATTERN
|
|
50
|
+
|
|
51
|
+
Hooks use a custom React Query-like pattern via `useApiData`:
|
|
52
|
+
- Returns `{ data, loading, error, refetch }`
|
|
53
|
+
- Provides caching and refetch capability
|
|
54
|
+
- New hooks should follow this same pattern
|
|
55
|
+
|
|
56
|
+
## CONVENTIONS
|
|
57
|
+
- Context and Provider in separate files
|
|
58
|
+
- All contexts exported via context/index.ts
|
|
59
|
+
- TypeScript declarations generated separately (no bundling)
|
|
60
|
+
- Build: tsc only
|
|
61
|
+
|
|
62
|
+
## USAGE EXAMPLES
|
|
63
|
+
|
|
64
|
+
### Provider Setup (Required)
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
// Wrap your app with YouVersionProvider before using any hooks
|
|
68
|
+
import { YouVersionProvider } from '@youversion/platform-react-hooks';
|
|
69
|
+
|
|
70
|
+
function App() {
|
|
71
|
+
return (
|
|
72
|
+
<YouVersionProvider
|
|
73
|
+
appKey="your-app-key"
|
|
74
|
+
theme="light" // "light" | "dark"
|
|
75
|
+
>
|
|
76
|
+
<MyApp />
|
|
77
|
+
</YouVersionProvider>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// With authentication enabled
|
|
82
|
+
function AppWithAuth() {
|
|
83
|
+
return (
|
|
84
|
+
<YouVersionProvider
|
|
85
|
+
appKey="your-app-key"
|
|
86
|
+
includeAuth={true}
|
|
87
|
+
authRedirectUrl="https://myapp.com/callback"
|
|
88
|
+
>
|
|
89
|
+
<MyApp />
|
|
90
|
+
</YouVersionProvider>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Data Fetching Hooks
|
|
96
|
+
|
|
97
|
+
All data hooks return `{ data, loading, error, refetch }`:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { useChapter, useVersion, useVerseOfTheDay } from '@youversion/platform-react-hooks';
|
|
101
|
+
|
|
102
|
+
// Fetch a Bible chapter
|
|
103
|
+
function ChapterView() {
|
|
104
|
+
const { chapter, loading, error } = useChapter(
|
|
105
|
+
111, // versionId (e.g., 111 = NIV)
|
|
106
|
+
'JHN', // book (USFM abbreviation)
|
|
107
|
+
3 // chapter number
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (loading) return <div>Loading...</div>;
|
|
111
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
112
|
+
return <div>{chapter?.content}</div>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Fetch Bible version metadata
|
|
116
|
+
function VersionInfo() {
|
|
117
|
+
const { version, loading } = useVersion(111);
|
|
118
|
+
if (loading) return <div>Loading...</div>;
|
|
119
|
+
return <div>{version?.name} ({version?.abbreviation})</div>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Fetch Verse of the Day
|
|
123
|
+
function DailyVerse() {
|
|
124
|
+
const dayOfYear = Math.floor((Date.now() - new Date(new Date().getFullYear(), 0, 0).getTime()) / 86400000);
|
|
125
|
+
const { data: votd, loading, refetch } = useVerseOfTheDay(dayOfYear);
|
|
126
|
+
|
|
127
|
+
if (loading) return <div>Loading...</div>;
|
|
128
|
+
return (
|
|
129
|
+
<div>
|
|
130
|
+
<p>{votd?.verse.text}</p>
|
|
131
|
+
<button onClick={refetch}>Refresh</button>
|
|
132
|
+
</div>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Authentication Hook
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import { useYVAuth } from '@youversion/platform-react-hooks';
|
|
141
|
+
|
|
142
|
+
function AuthExample() {
|
|
143
|
+
const { auth, userInfo, signIn, signOut } = useYVAuth();
|
|
144
|
+
|
|
145
|
+
if (auth.isLoading) return <div>Loading...</div>;
|
|
146
|
+
|
|
147
|
+
if (!auth.isAuthenticated) {
|
|
148
|
+
return (
|
|
149
|
+
<button onClick={() => signIn({ redirectUrl: window.location.origin + '/callback' })}>
|
|
150
|
+
Sign In with YouVersion
|
|
151
|
+
</button>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<div>
|
|
157
|
+
<p>Welcome, {userInfo?.name}!</p>
|
|
158
|
+
<button onClick={signOut}>Sign Out</button>
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Conditional Fetching
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
// Use the `enabled` option to conditionally fetch
|
|
168
|
+
function ConditionalFetch({ versionId }: { versionId: number | null }) {
|
|
169
|
+
const { version, loading } = useVersion(versionId ?? 0, {
|
|
170
|
+
enabled: versionId !== null, // Only fetch when versionId is provided
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// ...
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## TESTING
|
|
178
|
+
|
|
179
|
+
- Run tests: `pnpm --filter @youversion/platform-react-hooks test`
|
|
180
|
+
- Framework: Vitest with jsdom environment
|
|
181
|
+
- React Testing Library for component/hook tests
|
|
182
|
+
- Mock object factories live in `__tests__/mocks` (not MSW - hooks delegate HTTP to core)
|
|
183
|
+
- Use provider wrappers for tests so hooks see the same context as in the app
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @youversion/platform-react-hooks
|
|
2
2
|
|
|
3
|
+
## 1.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 607be3c: Refactor verse HTML transformation to support verse-level highlighting. Extract HTML processing logic to `verse-html-utils.ts` with new `wrapVerseContent()` function that wraps verse content in CSS-targetable `<span class="yv-v">` elements. Simplify footnote extraction using wrapped verse structure. Remove CSS rule preventing text wrapping. Add comprehensive test coverage for verse wrapping behavior.
|
|
8
|
+
- Updated dependencies [607be3c]
|
|
9
|
+
- @youversion/platform-core@1.8.1
|
|
10
|
+
|
|
11
|
+
## 1.8.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 45516c2: Add recently used versions to the Bible Version Picker
|
|
16
|
+
- Display up to 3 recently selected Bible versions at the top of the picker
|
|
17
|
+
- Persist recent version selections in localStorage
|
|
18
|
+
- Recent versions are searchable and excluded from the main "All Versions" list
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [45516c2]
|
|
23
|
+
- @youversion/platform-core@1.8.0
|
|
24
|
+
|
|
3
25
|
## 1.7.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -2,5 +2,5 @@ import type { BibleVersion } from '@youversion/platform-core';
|
|
|
2
2
|
/**
|
|
3
3
|
* Custom hook to filter versions based on search term
|
|
4
4
|
*/
|
|
5
|
-
export declare function useFilteredVersions(versions: BibleVersion[], searchTerm: string, selectedLanguage: string): BibleVersion[];
|
|
5
|
+
export declare function useFilteredVersions(versions: BibleVersion[], searchTerm: string, selectedLanguage: string, recentVersions?: Pick<BibleVersion, 'id' | 'title' | 'localized_abbreviation'>[]): BibleVersion[];
|
|
6
6
|
//# sourceMappingURL=useFilteredVersions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilteredVersions.d.ts","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,EAAE,EACxB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useFilteredVersions.d.ts","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,EAAE,EACxB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,OAAO,GAAG,wBAAwB,CAAC,EAAE,GAC/E,YAAY,EAAE,CA8BhB"}
|
|
@@ -4,7 +4,7 @@ import { getISOFromVersion } from './utility/version';
|
|
|
4
4
|
/**
|
|
5
5
|
* Custom hook to filter versions based on search term
|
|
6
6
|
*/
|
|
7
|
-
export function useFilteredVersions(versions, searchTerm, selectedLanguage) {
|
|
7
|
+
export function useFilteredVersions(versions, searchTerm, selectedLanguage, recentVersions) {
|
|
8
8
|
return useMemo(() => {
|
|
9
9
|
let result = [...versions];
|
|
10
10
|
// Language filter
|
|
@@ -18,7 +18,12 @@ export function useFilteredVersions(versions, searchTerm, selectedLanguage) {
|
|
|
18
18
|
version.abbreviation.toLowerCase().includes(searchLower) ||
|
|
19
19
|
getISOFromVersion(version).toLowerCase().includes(searchLower));
|
|
20
20
|
}
|
|
21
|
+
// Recently Used Filter
|
|
22
|
+
if (recentVersions) {
|
|
23
|
+
const recentVersionIds = recentVersions.map((version) => version.id);
|
|
24
|
+
result = result.filter((version) => !recentVersionIds.includes(version.id));
|
|
25
|
+
}
|
|
21
26
|
return result;
|
|
22
|
-
}, [versions, searchTerm, selectedLanguage]);
|
|
27
|
+
}, [versions, recentVersions, searchTerm, selectedLanguage]);
|
|
23
28
|
}
|
|
24
29
|
//# sourceMappingURL=useFilteredVersions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilteredVersions.js","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAwB,EACxB,UAAkB,EAClB,gBAAwB;
|
|
1
|
+
{"version":3,"file":"useFilteredVersions.js","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAwB,EACxB,UAAkB,EAClB,gBAAwB,EACxB,cAAgF;IAEhF,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;QAE3B,kBAAkB;QAClB,IAAI,gBAAgB,IAAI,gBAAgB,KAAK,GAAG,EAAE,CAAC;YACjD,MAAM,GAAG,MAAM,CAAC,MAAM,CACpB,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,KAAK,gBAAgB,CAAC,WAAW,EAAE,CACzF,CAAC;QACJ,CAAC;QAED,gBAAgB;QAChB,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;YACtB,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;YAC7C,MAAM,GAAG,MAAM,CAAC,MAAM,CACpB,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACjD,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACxD,iBAAiB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CACjE,CAAC;QACJ,CAAC;QAED,uBAAuB;QACvB,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,gBAAgB,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACrE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youversion/platform-react-hooks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@youversion/platform-core": "1.
|
|
25
|
+
"@youversion/platform-core": "1.8.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=19.1.0 <20.0.0"
|
|
@@ -198,6 +198,64 @@ describe('useFilteredVersions', () => {
|
|
|
198
198
|
});
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
+
describe('recent versions exclusion', () => {
|
|
202
|
+
it('should not exclude any versions when recentVersions is undefined', () => {
|
|
203
|
+
const { result } = renderHook(() => useFilteredVersions(mockVersions, '', '*', undefined));
|
|
204
|
+
|
|
205
|
+
expect(result.current).toEqual(mockVersions);
|
|
206
|
+
expect(result.current).toHaveLength(5);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('should exclude recent versions from the results', () => {
|
|
210
|
+
const recentVersions = [
|
|
211
|
+
{ id: 1, title: 'King James Version', localized_abbreviation: 'KJV' },
|
|
212
|
+
];
|
|
213
|
+
|
|
214
|
+
const { result } = renderHook(() =>
|
|
215
|
+
useFilteredVersions(mockVersions, '', '*', recentVersions),
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
expect(result.current).toHaveLength(4);
|
|
219
|
+
expect(result.current.find((v) => v.id === 1)).toBeUndefined();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('should exclude multiple recent versions from the results', () => {
|
|
223
|
+
const recentVersions = [
|
|
224
|
+
{ id: 1, title: 'King James Version', localized_abbreviation: 'KJV' },
|
|
225
|
+
{ id: 2, title: 'New International Version', localized_abbreviation: 'NIV' },
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
const { result } = renderHook(() =>
|
|
229
|
+
useFilteredVersions(mockVersions, '', '*', recentVersions),
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
expect(result.current).toHaveLength(3);
|
|
233
|
+
expect(result.current.find((v) => v.id === 1)).toBeUndefined();
|
|
234
|
+
expect(result.current.find((v) => v.id === 2)).toBeUndefined();
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('should not exclude any versions when recentVersions is empty array', () => {
|
|
238
|
+
const { result } = renderHook(() => useFilteredVersions(mockVersions, '', '*', []));
|
|
239
|
+
|
|
240
|
+
expect(result.current).toEqual(mockVersions);
|
|
241
|
+
expect(result.current).toHaveLength(5);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('should exclude recent versions even when they match search term', () => {
|
|
245
|
+
const recentVersions = [
|
|
246
|
+
{ id: 2, title: 'New International Version', localized_abbreviation: 'NIV' },
|
|
247
|
+
];
|
|
248
|
+
|
|
249
|
+
const { result } = renderHook(() =>
|
|
250
|
+
useFilteredVersions(mockVersions, 'Version', '*', recentVersions),
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
// "Version" matches KJV and NIV, but NIV is excluded as a recent version
|
|
254
|
+
expect(result.current).toHaveLength(1);
|
|
255
|
+
expect(result.current[0]?.title).toBe('King James Version');
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
201
259
|
describe('memoization', () => {
|
|
202
260
|
it('should return the same reference when inputs do not change', () => {
|
|
203
261
|
const { result, rerender } = renderHook(
|
|
@@ -11,6 +11,7 @@ export function useFilteredVersions(
|
|
|
11
11
|
versions: BibleVersion[],
|
|
12
12
|
searchTerm: string,
|
|
13
13
|
selectedLanguage: string,
|
|
14
|
+
recentVersions?: Pick<BibleVersion, 'id' | 'title' | 'localized_abbreviation'>[],
|
|
14
15
|
): BibleVersion[] {
|
|
15
16
|
return useMemo(() => {
|
|
16
17
|
let result = [...versions];
|
|
@@ -33,6 +34,12 @@ export function useFilteredVersions(
|
|
|
33
34
|
);
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
// Recently Used Filter
|
|
38
|
+
if (recentVersions) {
|
|
39
|
+
const recentVersionIds = recentVersions.map((version) => version.id);
|
|
40
|
+
result = result.filter((version) => !recentVersionIds.includes(version.id));
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
return result;
|
|
37
|
-
}, [versions, searchTerm, selectedLanguage]);
|
|
44
|
+
}, [versions, recentVersions, searchTerm, selectedLanguage]);
|
|
38
45
|
}
|