@dubsdotapp/expo 0.5.15 → 0.5.16
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/dist/index.js +229 -201
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -149
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useShorts.ts +36 -0
- package/src/index.ts +2 -1
package/package.json
CHANGED
package/src/hooks/index.ts
CHANGED
|
@@ -18,6 +18,8 @@ export { useUFCFightCard } from './useUFCFightCard';
|
|
|
18
18
|
export { useUFCFighterDetail } from './useUFCFighterDetail';
|
|
19
19
|
export { useHighlights } from './useHighlights';
|
|
20
20
|
export type { HighlightVideo } from './useHighlights';
|
|
21
|
+
export { useShorts } from './useShorts';
|
|
22
|
+
export type { ShortVideo } from './useShorts';
|
|
21
23
|
export { usePushNotifications } from './usePushNotifications';
|
|
22
24
|
export type { PushNotificationStatus } from './usePushNotifications';
|
|
23
25
|
export { useArcadePools } from './useArcadePools';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import { useDubs } from '../provider';
|
|
3
|
+
import type { QueryResult } from '../types';
|
|
4
|
+
|
|
5
|
+
export interface ShortVideo {
|
|
6
|
+
videoId: string;
|
|
7
|
+
title: string;
|
|
8
|
+
channelTitle: string;
|
|
9
|
+
thumbnail: string;
|
|
10
|
+
publishedAt: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function useShorts(league: string = 'NBA', limit: number = 20): QueryResult<ShortVideo[]> {
|
|
14
|
+
const { client } = useDubs();
|
|
15
|
+
const [data, setData] = useState<ShortVideo[] | null>(null);
|
|
16
|
+
const [loading, setLoading] = useState(true);
|
|
17
|
+
const [error, setError] = useState<Error | null>(null);
|
|
18
|
+
|
|
19
|
+
const fetchData = useCallback(async () => {
|
|
20
|
+
setLoading(true);
|
|
21
|
+
setError(null);
|
|
22
|
+
try {
|
|
23
|
+
const qs = new URLSearchParams({ league, limit: String(limit) });
|
|
24
|
+
const res = await (client as any).request('GET', `/shorts?${qs.toString()}`);
|
|
25
|
+
setData(res.videos || []);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
28
|
+
} finally {
|
|
29
|
+
setLoading(false);
|
|
30
|
+
}
|
|
31
|
+
}, [client, league, limit]);
|
|
32
|
+
|
|
33
|
+
useEffect(() => { fetchData(); }, [fetchData]);
|
|
34
|
+
|
|
35
|
+
return { data, loading, error, refetch: fetchData };
|
|
36
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -128,9 +128,10 @@ export type {
|
|
|
128
128
|
UseArcadeBridgeOptions,
|
|
129
129
|
UseArcadeBridgeResult,
|
|
130
130
|
HighlightVideo,
|
|
131
|
+
ShortVideo,
|
|
131
132
|
} from './hooks';
|
|
132
133
|
|
|
133
|
-
export { useHighlights } from './hooks';
|
|
134
|
+
export { useHighlights, useShorts } from './hooks';
|
|
134
135
|
|
|
135
136
|
// UI
|
|
136
137
|
export { AuthGate, ConnectWalletScreen, ConnectWalletButton, UserProfileCard, SettingsSheet, UserProfileSheet, useDubsTheme, mergeTheme } from './ui';
|