@dubsdotapp/expo 0.5.30 → 0.5.32
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.d.mts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +264 -223
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +213 -173
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +17 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useCredits.ts +48 -0
- package/src/index.ts +3 -0
- package/src/types.ts +15 -0
package/dist/index.js
CHANGED
|
@@ -86,6 +86,7 @@ __export(index_exports, {
|
|
|
86
86
|
useConversations: () => useConversations,
|
|
87
87
|
useCreateCustomGame: () => useCreateCustomGame,
|
|
88
88
|
useCreateGame: () => useCreateGame,
|
|
89
|
+
useCredits: () => useCredits,
|
|
89
90
|
useDirectMessages: () => useDirectMessages,
|
|
90
91
|
useDubs: () => useDubs,
|
|
91
92
|
useDubsTheme: () => useDubsTheme,
|
|
@@ -715,6 +716,16 @@ var DubsClient = class {
|
|
|
715
716
|
);
|
|
716
717
|
return { round: res.round, lastWinner: res.lastWinner };
|
|
717
718
|
}
|
|
719
|
+
/**
|
|
720
|
+
* List the authenticated user's active promo credits — codes that
|
|
721
|
+
* have been reserved to them but not yet used in a game. Includes
|
|
722
|
+
* streak-milestone unlocks (auto-minted at each 1000-dub crossing)
|
|
723
|
+
* and any manually-reserved Twitter giveaway codes.
|
|
724
|
+
*/
|
|
725
|
+
async getCredits() {
|
|
726
|
+
const res = await this.request("GET", "/me/credits");
|
|
727
|
+
return { credits: res.credits, totalLamports: res.totalLamports, totalSOL: res.totalSOL };
|
|
728
|
+
}
|
|
718
729
|
/** Get current round entries with odds */
|
|
719
730
|
async getJackpotEntries() {
|
|
720
731
|
const res = await this.request(
|
|
@@ -936,7 +947,7 @@ function createSecureStoreStorage() {
|
|
|
936
947
|
}
|
|
937
948
|
|
|
938
949
|
// src/provider.tsx
|
|
939
|
-
var
|
|
950
|
+
var import_react30 = require("react");
|
|
940
951
|
|
|
941
952
|
// src/ui/theme.ts
|
|
942
953
|
var import_react = require("react");
|
|
@@ -1994,7 +2005,7 @@ function ManagedWalletProvider({
|
|
|
1994
2005
|
}
|
|
1995
2006
|
|
|
1996
2007
|
// src/ui/AuthGate.tsx
|
|
1997
|
-
var
|
|
2008
|
+
var import_react29 = __toESM(require("react"));
|
|
1998
2009
|
var import_react_native8 = require("react-native");
|
|
1999
2010
|
|
|
2000
2011
|
// src/hooks/useEvents.ts
|
|
@@ -3351,6 +3362,35 @@ function useEnterJackpot() {
|
|
|
3351
3362
|
return { execute, status, error, data, reset };
|
|
3352
3363
|
}
|
|
3353
3364
|
|
|
3365
|
+
// src/hooks/useCredits.ts
|
|
3366
|
+
var import_react28 = require("react");
|
|
3367
|
+
function useCredits() {
|
|
3368
|
+
const { client } = useDubs();
|
|
3369
|
+
const [credits, setCredits] = (0, import_react28.useState)([]);
|
|
3370
|
+
const [totalLamports, setTotalLamports] = (0, import_react28.useState)(0);
|
|
3371
|
+
const [totalSOL, setTotalSOL] = (0, import_react28.useState)(0);
|
|
3372
|
+
const [loading, setLoading] = (0, import_react28.useState)(false);
|
|
3373
|
+
const [error, setError] = (0, import_react28.useState)(null);
|
|
3374
|
+
const fetch2 = (0, import_react28.useCallback)(async () => {
|
|
3375
|
+
setLoading(true);
|
|
3376
|
+
setError(null);
|
|
3377
|
+
try {
|
|
3378
|
+
const result = await client.getCredits();
|
|
3379
|
+
setCredits(result.credits);
|
|
3380
|
+
setTotalLamports(result.totalLamports);
|
|
3381
|
+
setTotalSOL(result.totalSOL);
|
|
3382
|
+
} catch (err) {
|
|
3383
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
3384
|
+
} finally {
|
|
3385
|
+
setLoading(false);
|
|
3386
|
+
}
|
|
3387
|
+
}, [client]);
|
|
3388
|
+
(0, import_react28.useEffect)(() => {
|
|
3389
|
+
fetch2();
|
|
3390
|
+
}, [fetch2]);
|
|
3391
|
+
return { credits, totalLamports, totalSOL, loading, error, refetch: fetch2 };
|
|
3392
|
+
}
|
|
3393
|
+
|
|
3354
3394
|
// src/ui/AvatarEditor.tsx
|
|
3355
3395
|
var import_react_native7 = require("react-native");
|
|
3356
3396
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -3512,11 +3552,11 @@ function AuthGate({
|
|
|
3512
3552
|
}) {
|
|
3513
3553
|
const { client, pushEnabled, uiConfig } = useDubs();
|
|
3514
3554
|
const auth = useAuth();
|
|
3515
|
-
const [phase, setPhase] = (0,
|
|
3516
|
-
const [registrationPhase, setRegistrationPhase] = (0,
|
|
3517
|
-
const [showPushSetup, setShowPushSetup] = (0,
|
|
3518
|
-
const [isRestoredSession, setIsRestoredSession] = (0,
|
|
3519
|
-
(0,
|
|
3555
|
+
const [phase, setPhase] = (0, import_react29.useState)("init");
|
|
3556
|
+
const [registrationPhase, setRegistrationPhase] = (0, import_react29.useState)(false);
|
|
3557
|
+
const [showPushSetup, setShowPushSetup] = (0, import_react29.useState)(false);
|
|
3558
|
+
const [isRestoredSession, setIsRestoredSession] = (0, import_react29.useState)(false);
|
|
3559
|
+
(0, import_react29.useEffect)(() => {
|
|
3520
3560
|
let cancelled = false;
|
|
3521
3561
|
(async () => {
|
|
3522
3562
|
try {
|
|
@@ -3543,23 +3583,23 @@ function AuthGate({
|
|
|
3543
3583
|
cancelled = true;
|
|
3544
3584
|
};
|
|
3545
3585
|
}, []);
|
|
3546
|
-
(0,
|
|
3586
|
+
(0, import_react29.useEffect)(() => {
|
|
3547
3587
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
3548
3588
|
}, [auth.status]);
|
|
3549
|
-
(0,
|
|
3589
|
+
(0, import_react29.useEffect)(() => {
|
|
3550
3590
|
if (pushEnabled && uiConfig.pushConfigured?.android && auth.status === "authenticated" && registrationPhase && !isRestoredSession) {
|
|
3551
3591
|
setShowPushSetup(true);
|
|
3552
3592
|
}
|
|
3553
3593
|
}, [pushEnabled, uiConfig.pushConfigured?.android, auth.status, registrationPhase, isRestoredSession]);
|
|
3554
|
-
(0,
|
|
3594
|
+
(0, import_react29.useEffect)(() => {
|
|
3555
3595
|
if (auth.token) onSaveToken(auth.token);
|
|
3556
3596
|
}, [auth.token]);
|
|
3557
|
-
const retry = (0,
|
|
3597
|
+
const retry = (0, import_react29.useCallback)(() => {
|
|
3558
3598
|
setRegistrationPhase(false);
|
|
3559
3599
|
auth.reset();
|
|
3560
3600
|
auth.authenticate();
|
|
3561
3601
|
}, [auth]);
|
|
3562
|
-
const handleRegister = (0,
|
|
3602
|
+
const handleRegister = (0, import_react29.useCallback)(
|
|
3563
3603
|
(username, referralCode, avatarUrl) => {
|
|
3564
3604
|
auth.register(username, referralCode, avatarUrl);
|
|
3565
3605
|
},
|
|
@@ -3652,7 +3692,7 @@ function DefaultErrorScreen({ error, onRetry, appName, accentColor }) {
|
|
|
3652
3692
|
function StepIndicator({ currentStep }) {
|
|
3653
3693
|
const t = useDubsTheme();
|
|
3654
3694
|
const steps = [0, 1, 2, 3];
|
|
3655
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native8.View, { style: s.stepRow, children: steps.map((i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3695
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native8.View, { style: s.stepRow, children: steps.map((i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react29.default.Fragment, { children: [
|
|
3656
3696
|
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native8.View, { style: [s.stepLine, { backgroundColor: i <= currentStep ? t.success : t.border }] }),
|
|
3657
3697
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3658
3698
|
import_react_native8.View,
|
|
@@ -3679,20 +3719,20 @@ function DefaultRegistrationScreen({
|
|
|
3679
3719
|
const t = useDubsTheme();
|
|
3680
3720
|
const accent = accentColor || t.accent;
|
|
3681
3721
|
const push = usePushNotifications();
|
|
3682
|
-
const [step, setStep] = (0,
|
|
3683
|
-
const [avatarSeed, setAvatarSeed] = (0,
|
|
3684
|
-
const [avatarStyle, setAvatarStyle] = (0,
|
|
3685
|
-
const [avatarBg, setAvatarBg] = (0,
|
|
3686
|
-
const [showStyles, setShowStyles] = (0,
|
|
3687
|
-
const [username, setUsername] = (0,
|
|
3688
|
-
const [referralCode, setReferralCode] = (0,
|
|
3689
|
-
const [checking, setChecking] = (0,
|
|
3690
|
-
const [availability, setAvailability] = (0,
|
|
3691
|
-
const debounceRef = (0,
|
|
3692
|
-
const fadeAnim = (0,
|
|
3693
|
-
const slideAnim = (0,
|
|
3722
|
+
const [step, setStep] = (0, import_react29.useState)(0);
|
|
3723
|
+
const [avatarSeed, setAvatarSeed] = (0, import_react29.useState)(generateSeed);
|
|
3724
|
+
const [avatarStyle, setAvatarStyle] = (0, import_react29.useState)("adventurer");
|
|
3725
|
+
const [avatarBg, setAvatarBg] = (0, import_react29.useState)("1a1a2e");
|
|
3726
|
+
const [showStyles, setShowStyles] = (0, import_react29.useState)(false);
|
|
3727
|
+
const [username, setUsername] = (0, import_react29.useState)("");
|
|
3728
|
+
const [referralCode, setReferralCode] = (0, import_react29.useState)("");
|
|
3729
|
+
const [checking, setChecking] = (0, import_react29.useState)(false);
|
|
3730
|
+
const [availability, setAvailability] = (0, import_react29.useState)(null);
|
|
3731
|
+
const debounceRef = (0, import_react29.useRef)(null);
|
|
3732
|
+
const fadeAnim = (0, import_react29.useRef)(new import_react_native8.Animated.Value(1)).current;
|
|
3733
|
+
const slideAnim = (0, import_react29.useRef)(new import_react_native8.Animated.Value(0)).current;
|
|
3694
3734
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed, avatarBg);
|
|
3695
|
-
(0,
|
|
3735
|
+
(0, import_react29.useEffect)(() => {
|
|
3696
3736
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3697
3737
|
const trimmed = username.trim();
|
|
3698
3738
|
if (trimmed.length < 3) {
|
|
@@ -3715,7 +3755,7 @@ function DefaultRegistrationScreen({
|
|
|
3715
3755
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3716
3756
|
};
|
|
3717
3757
|
}, [username, client]);
|
|
3718
|
-
const animateToStep = (0,
|
|
3758
|
+
const animateToStep = (0, import_react29.useCallback)((newStep) => {
|
|
3719
3759
|
const dir = newStep > step ? 1 : -1;
|
|
3720
3760
|
import_react_native8.Keyboard.dismiss();
|
|
3721
3761
|
import_react_native8.Animated.parallel([
|
|
@@ -3914,7 +3954,7 @@ function DefaultRegistrationScreen({
|
|
|
3914
3954
|
)
|
|
3915
3955
|
] })
|
|
3916
3956
|
] });
|
|
3917
|
-
(0,
|
|
3957
|
+
(0, import_react29.useEffect)(() => {
|
|
3918
3958
|
if (pushStepActive && step !== 3) {
|
|
3919
3959
|
animateToStep(3);
|
|
3920
3960
|
}
|
|
@@ -4008,8 +4048,8 @@ function DefaultRegistrationScreen({
|
|
|
4008
4048
|
}
|
|
4009
4049
|
function PushTokenRestorer() {
|
|
4010
4050
|
const push = usePushNotifications();
|
|
4011
|
-
const restored = (0,
|
|
4012
|
-
(0,
|
|
4051
|
+
const restored = (0, import_react29.useRef)(false);
|
|
4052
|
+
(0, import_react29.useEffect)(() => {
|
|
4013
4053
|
if (restored.current) return;
|
|
4014
4054
|
restored.current = true;
|
|
4015
4055
|
push.restoreIfGranted();
|
|
@@ -4091,7 +4131,7 @@ var s = import_react_native8.StyleSheet.create({
|
|
|
4091
4131
|
|
|
4092
4132
|
// src/provider.tsx
|
|
4093
4133
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
4094
|
-
var DubsContext = (0,
|
|
4134
|
+
var DubsContext = (0, import_react30.createContext)(null);
|
|
4095
4135
|
function DubsProvider({
|
|
4096
4136
|
apiKey,
|
|
4097
4137
|
children,
|
|
@@ -4113,11 +4153,11 @@ function DubsProvider({
|
|
|
4113
4153
|
const config = NETWORK_CONFIG[network];
|
|
4114
4154
|
const baseUrl = baseUrlOverride || config.baseUrl;
|
|
4115
4155
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
4116
|
-
const client = (0,
|
|
4117
|
-
const storage = (0,
|
|
4118
|
-
const [uiConfig, setUiConfig] = (0,
|
|
4119
|
-
const [resolvedNetwork, setResolvedNetwork] = (0,
|
|
4120
|
-
(0,
|
|
4156
|
+
const client = (0, import_react30.useMemo)(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
4157
|
+
const storage = (0, import_react30.useMemo)(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
4158
|
+
const [uiConfig, setUiConfig] = (0, import_react30.useState)(null);
|
|
4159
|
+
const [resolvedNetwork, setResolvedNetwork] = (0, import_react30.useState)(network);
|
|
4160
|
+
(0, import_react30.useEffect)(() => {
|
|
4121
4161
|
client.getAppConfig().then((cfg) => {
|
|
4122
4162
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
|
|
4123
4163
|
setUiConfig(cfg);
|
|
@@ -4133,7 +4173,7 @@ function DubsProvider({
|
|
|
4133
4173
|
const resolvedConfig = NETWORK_CONFIG[resolvedNetwork];
|
|
4134
4174
|
const resolvedRpcUrl = rpcUrlOverride || resolvedConfig.rpcUrl;
|
|
4135
4175
|
const cluster = resolvedConfig.cluster;
|
|
4136
|
-
const connection = (0,
|
|
4176
|
+
const connection = (0, import_react30.useMemo)(() => new import_web34.Connection(resolvedRpcUrl, { commitment: "confirmed" }), [resolvedRpcUrl]);
|
|
4137
4177
|
if (uiConfig === null) return null;
|
|
4138
4178
|
const themeOverrides = {};
|
|
4139
4179
|
if (uiConfig.accentColor) {
|
|
@@ -4209,11 +4249,11 @@ function ManagedInner({
|
|
|
4209
4249
|
children
|
|
4210
4250
|
}) {
|
|
4211
4251
|
const managedDisconnect = useDisconnect();
|
|
4212
|
-
const disconnect = (0,
|
|
4252
|
+
const disconnect = (0, import_react30.useCallback)(async () => {
|
|
4213
4253
|
client.setToken(null);
|
|
4214
4254
|
await managedDisconnect?.();
|
|
4215
4255
|
}, [client, managedDisconnect]);
|
|
4216
|
-
const value = (0,
|
|
4256
|
+
const value = (0, import_react30.useMemo)(
|
|
4217
4257
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled }),
|
|
4218
4258
|
[client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled]
|
|
4219
4259
|
);
|
|
@@ -4250,13 +4290,13 @@ function ExternalWalletProvider({
|
|
|
4250
4290
|
pushEnabled,
|
|
4251
4291
|
children
|
|
4252
4292
|
}) {
|
|
4253
|
-
const disconnect = (0,
|
|
4293
|
+
const disconnect = (0, import_react30.useCallback)(async () => {
|
|
4254
4294
|
client.setToken(null);
|
|
4255
4295
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
4256
4296
|
});
|
|
4257
4297
|
await wallet.disconnect?.();
|
|
4258
4298
|
}, [client, storage, wallet]);
|
|
4259
|
-
const value = (0,
|
|
4299
|
+
const value = (0, import_react30.useMemo)(
|
|
4260
4300
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled }),
|
|
4261
4301
|
[client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled]
|
|
4262
4302
|
);
|
|
@@ -4281,14 +4321,14 @@ function ExternalWalletProvider({
|
|
|
4281
4321
|
) });
|
|
4282
4322
|
}
|
|
4283
4323
|
function useDubs() {
|
|
4284
|
-
const ctx = (0,
|
|
4324
|
+
const ctx = (0, import_react30.useContext)(DubsContext);
|
|
4285
4325
|
if (!ctx) {
|
|
4286
4326
|
throw new Error("useDubs must be used within a <DubsProvider>");
|
|
4287
4327
|
}
|
|
4288
4328
|
return ctx;
|
|
4289
4329
|
}
|
|
4290
4330
|
function useAppConfig() {
|
|
4291
|
-
const ctx = (0,
|
|
4331
|
+
const ctx = (0, import_react30.useContext)(DubsContext);
|
|
4292
4332
|
return ctx?.uiConfig || {};
|
|
4293
4333
|
}
|
|
4294
4334
|
|
|
@@ -4346,7 +4386,7 @@ var styles3 = import_react_native9.StyleSheet.create({
|
|
|
4346
4386
|
});
|
|
4347
4387
|
|
|
4348
4388
|
// src/ui/UserProfileCard.tsx
|
|
4349
|
-
var
|
|
4389
|
+
var import_react31 = require("react");
|
|
4350
4390
|
var import_react_native10 = require("react-native");
|
|
4351
4391
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
4352
4392
|
function truncateAddress(address, chars = 4) {
|
|
@@ -4366,7 +4406,7 @@ function UserProfileCard({
|
|
|
4366
4406
|
memberSince
|
|
4367
4407
|
}) {
|
|
4368
4408
|
const t = useDubsTheme();
|
|
4369
|
-
const imageUri = (0,
|
|
4409
|
+
const imageUri = (0, import_react31.useMemo)(
|
|
4370
4410
|
() => ensurePngAvatar(avatarUrl) || `https://api.dicebear.com/9.x/avataaars/png?seed=${walletAddress}&size=128`,
|
|
4371
4411
|
[avatarUrl, walletAddress]
|
|
4372
4412
|
);
|
|
@@ -4559,7 +4599,7 @@ var styles5 = import_react_native11.StyleSheet.create({
|
|
|
4559
4599
|
});
|
|
4560
4600
|
|
|
4561
4601
|
// src/ui/UserProfileSheet.tsx
|
|
4562
|
-
var
|
|
4602
|
+
var import_react32 = require("react");
|
|
4563
4603
|
var import_react_native12 = require("react-native");
|
|
4564
4604
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
4565
4605
|
function truncateAddress3(address, chars = 4) {
|
|
@@ -4577,31 +4617,31 @@ function UserProfileSheet({
|
|
|
4577
4617
|
const { client } = useDubs();
|
|
4578
4618
|
const { refreshUser } = useAuth();
|
|
4579
4619
|
const push = usePushNotifications();
|
|
4580
|
-
const overlayOpacity = (0,
|
|
4581
|
-
const parsed = (0,
|
|
4582
|
-
const [avatarStyle, setAvatarStyle] = (0,
|
|
4583
|
-
const [avatarSeed, setAvatarSeed] = (0,
|
|
4584
|
-
const [bgColor, setBgColor] = (0,
|
|
4585
|
-
const [saving, setSaving] = (0,
|
|
4586
|
-
const [error, setError] = (0,
|
|
4587
|
-
(0,
|
|
4620
|
+
const overlayOpacity = (0, import_react32.useRef)(new import_react_native12.Animated.Value(0)).current;
|
|
4621
|
+
const parsed = (0, import_react32.useMemo)(() => parseAvatarUrl(user.avatar), [user.avatar]);
|
|
4622
|
+
const [avatarStyle, setAvatarStyle] = (0, import_react32.useState)(parsed.style);
|
|
4623
|
+
const [avatarSeed, setAvatarSeed] = (0, import_react32.useState)(parsed.seed);
|
|
4624
|
+
const [bgColor, setBgColor] = (0, import_react32.useState)(parsed.bg);
|
|
4625
|
+
const [saving, setSaving] = (0, import_react32.useState)(false);
|
|
4626
|
+
const [error, setError] = (0, import_react32.useState)(null);
|
|
4627
|
+
(0, import_react32.useEffect)(() => {
|
|
4588
4628
|
const p = parseAvatarUrl(user.avatar);
|
|
4589
4629
|
setAvatarStyle(p.style);
|
|
4590
4630
|
setAvatarSeed(p.seed);
|
|
4591
4631
|
setBgColor(p.bg);
|
|
4592
4632
|
}, [user.avatar]);
|
|
4593
|
-
(0,
|
|
4633
|
+
(0, import_react32.useEffect)(() => {
|
|
4594
4634
|
import_react_native12.Animated.timing(overlayOpacity, {
|
|
4595
4635
|
toValue: visible ? 1 : 0,
|
|
4596
4636
|
duration: 250,
|
|
4597
4637
|
useNativeDriver: true
|
|
4598
4638
|
}).start();
|
|
4599
4639
|
}, [visible, overlayOpacity]);
|
|
4600
|
-
(0,
|
|
4640
|
+
(0, import_react32.useEffect)(() => {
|
|
4601
4641
|
if (visible) setError(null);
|
|
4602
4642
|
}, [visible]);
|
|
4603
4643
|
const currentAvatarUrl = getAvatarUrl(avatarStyle, avatarSeed, bgColor);
|
|
4604
|
-
const saveAvatar = (0,
|
|
4644
|
+
const saveAvatar = (0, import_react32.useCallback)(async (newUrl) => {
|
|
4605
4645
|
setSaving(true);
|
|
4606
4646
|
setError(null);
|
|
4607
4647
|
try {
|
|
@@ -4614,16 +4654,16 @@ function UserProfileSheet({
|
|
|
4614
4654
|
setSaving(false);
|
|
4615
4655
|
}
|
|
4616
4656
|
}, [client, refreshUser, onAvatarUpdated]);
|
|
4617
|
-
const handleStyleChange = (0,
|
|
4657
|
+
const handleStyleChange = (0, import_react32.useCallback)((style) => {
|
|
4618
4658
|
setAvatarStyle(style);
|
|
4619
4659
|
saveAvatar(getAvatarUrl(style, avatarSeed, bgColor));
|
|
4620
4660
|
}, [avatarSeed, bgColor, saveAvatar]);
|
|
4621
|
-
const handleShuffle = (0,
|
|
4661
|
+
const handleShuffle = (0, import_react32.useCallback)(() => {
|
|
4622
4662
|
const newSeed = generateSeed();
|
|
4623
4663
|
setAvatarSeed(newSeed);
|
|
4624
4664
|
saveAvatar(getAvatarUrl(avatarStyle, newSeed, bgColor));
|
|
4625
4665
|
}, [avatarStyle, bgColor, saveAvatar]);
|
|
4626
|
-
const handleBgChange = (0,
|
|
4666
|
+
const handleBgChange = (0, import_react32.useCallback)((color) => {
|
|
4627
4667
|
setBgColor(color);
|
|
4628
4668
|
saveAvatar(getAvatarUrl(avatarStyle, avatarSeed, color));
|
|
4629
4669
|
}, [avatarStyle, avatarSeed, saveAvatar]);
|
|
@@ -4903,7 +4943,7 @@ var styles6 = import_react_native12.StyleSheet.create({
|
|
|
4903
4943
|
});
|
|
4904
4944
|
|
|
4905
4945
|
// src/ui/game/GamePoster.tsx
|
|
4906
|
-
var
|
|
4946
|
+
var import_react33 = require("react");
|
|
4907
4947
|
var import_react_native13 = require("react-native");
|
|
4908
4948
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4909
4949
|
function computeCountdown(lockTimestamp) {
|
|
@@ -4953,7 +4993,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
4953
4993
|
] });
|
|
4954
4994
|
}
|
|
4955
4995
|
function TeamLogoInternal({ url, size, Img }) {
|
|
4956
|
-
const [failed, setFailed] = (0,
|
|
4996
|
+
const [failed, setFailed] = (0, import_react33.useState)(false);
|
|
4957
4997
|
if (!url || failed) {
|
|
4958
4998
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native13.View, { style: [styles7.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
4959
4999
|
}
|
|
@@ -5054,7 +5094,7 @@ var styles7 = import_react_native13.StyleSheet.create({
|
|
|
5054
5094
|
});
|
|
5055
5095
|
|
|
5056
5096
|
// src/ui/game/LivePoolsCard.tsx
|
|
5057
|
-
var
|
|
5097
|
+
var import_react34 = require("react");
|
|
5058
5098
|
var import_react_native14 = require("react-native");
|
|
5059
5099
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
5060
5100
|
function LivePoolsCard({
|
|
@@ -5070,7 +5110,7 @@ function LivePoolsCard({
|
|
|
5070
5110
|
const homePool = game.homePool || 0;
|
|
5071
5111
|
const awayPool = game.awayPool || 0;
|
|
5072
5112
|
const totalPool = game.totalPool || 0;
|
|
5073
|
-
const { homePercent, awayPercent, homeOdds, awayOdds } = (0,
|
|
5113
|
+
const { homePercent, awayPercent, homeOdds, awayOdds } = (0, import_react34.useMemo)(() => {
|
|
5074
5114
|
return {
|
|
5075
5115
|
homePercent: totalPool > 0 ? homePool / totalPool * 100 : 50,
|
|
5076
5116
|
awayPercent: totalPool > 0 ? awayPool / totalPool * 100 : 50,
|
|
@@ -5133,7 +5173,7 @@ var styles8 = import_react_native14.StyleSheet.create({
|
|
|
5133
5173
|
});
|
|
5134
5174
|
|
|
5135
5175
|
// src/ui/game/PickWinnerCard.tsx
|
|
5136
|
-
var
|
|
5176
|
+
var import_react35 = require("react");
|
|
5137
5177
|
var import_react_native15 = require("react-native");
|
|
5138
5178
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
5139
5179
|
function PickWinnerCard({
|
|
@@ -5151,7 +5191,7 @@ function PickWinnerCard({
|
|
|
5151
5191
|
const totalPool = game.totalPool || 0;
|
|
5152
5192
|
const homePool = game.homePool || 0;
|
|
5153
5193
|
const awayPool = game.awayPool || 0;
|
|
5154
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = (0,
|
|
5194
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = (0, import_react35.useMemo)(() => ({
|
|
5155
5195
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
5156
5196
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
5157
5197
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -5204,7 +5244,7 @@ function TeamOption({
|
|
|
5204
5244
|
ImageComponent,
|
|
5205
5245
|
t
|
|
5206
5246
|
}) {
|
|
5207
|
-
const [imgFailed, setImgFailed] = (0,
|
|
5247
|
+
const [imgFailed, setImgFailed] = (0, import_react35.useState)(false);
|
|
5208
5248
|
const Img = ImageComponent || require("react-native").Image;
|
|
5209
5249
|
const showImage = imageUrl && !imgFailed;
|
|
5210
5250
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -5245,7 +5285,7 @@ var styles9 = import_react_native15.StyleSheet.create({
|
|
|
5245
5285
|
});
|
|
5246
5286
|
|
|
5247
5287
|
// src/ui/game/PlayersCard.tsx
|
|
5248
|
-
var
|
|
5288
|
+
var import_react36 = require("react");
|
|
5249
5289
|
var import_react_native16 = require("react-native");
|
|
5250
5290
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
5251
5291
|
function truncateWallet(addr, chars) {
|
|
@@ -5294,7 +5334,7 @@ function BettorRow({
|
|
|
5294
5334
|
ImageComponent,
|
|
5295
5335
|
t
|
|
5296
5336
|
}) {
|
|
5297
|
-
const [imgFailed, setImgFailed] = (0,
|
|
5337
|
+
const [imgFailed, setImgFailed] = (0, import_react36.useState)(false);
|
|
5298
5338
|
const Img = ImageComponent || require("react-native").Image;
|
|
5299
5339
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
5300
5340
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native16.View, { style: [styles10.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -5321,7 +5361,7 @@ var styles10 = import_react_native16.StyleSheet.create({
|
|
|
5321
5361
|
});
|
|
5322
5362
|
|
|
5323
5363
|
// src/ui/game/JoinGameButton.tsx
|
|
5324
|
-
var
|
|
5364
|
+
var import_react37 = require("react");
|
|
5325
5365
|
var import_react_native17 = require("react-native");
|
|
5326
5366
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
5327
5367
|
var STATUS_LABELS = {
|
|
@@ -5332,7 +5372,7 @@ var STATUS_LABELS = {
|
|
|
5332
5372
|
};
|
|
5333
5373
|
function JoinGameButton({ game, walletAddress, selectedTeam, status, onJoin }) {
|
|
5334
5374
|
const t = useDubsTheme();
|
|
5335
|
-
const alreadyJoined = (0,
|
|
5375
|
+
const alreadyJoined = (0, import_react37.useMemo)(() => {
|
|
5336
5376
|
if (!walletAddress) return false;
|
|
5337
5377
|
return (game.bettors || []).some((b) => b.wallet === walletAddress);
|
|
5338
5378
|
}, [game.bettors, walletAddress]);
|
|
@@ -5373,7 +5413,7 @@ var styles11 = import_react_native17.StyleSheet.create({
|
|
|
5373
5413
|
});
|
|
5374
5414
|
|
|
5375
5415
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
5376
|
-
var
|
|
5416
|
+
var import_react38 = require("react");
|
|
5377
5417
|
var import_react_native18 = require("react-native");
|
|
5378
5418
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
5379
5419
|
var STATUS_LABELS2 = {
|
|
@@ -5399,18 +5439,18 @@ function CreateCustomGameSheet({
|
|
|
5399
5439
|
const t = useDubsTheme();
|
|
5400
5440
|
const { wallet } = useDubs();
|
|
5401
5441
|
const mutation = useCreateCustomGame();
|
|
5402
|
-
const [selectedAmount, setSelectedAmount] = (0,
|
|
5403
|
-
const [customAmount, setCustomAmount] = (0,
|
|
5404
|
-
const [isCustom, setIsCustom] = (0,
|
|
5405
|
-
const overlayOpacity = (0,
|
|
5406
|
-
(0,
|
|
5442
|
+
const [selectedAmount, setSelectedAmount] = (0, import_react38.useState)(null);
|
|
5443
|
+
const [customAmount, setCustomAmount] = (0, import_react38.useState)("");
|
|
5444
|
+
const [isCustom, setIsCustom] = (0, import_react38.useState)(false);
|
|
5445
|
+
const overlayOpacity = (0, import_react38.useRef)(new import_react_native18.Animated.Value(0)).current;
|
|
5446
|
+
(0, import_react38.useEffect)(() => {
|
|
5407
5447
|
import_react_native18.Animated.timing(overlayOpacity, {
|
|
5408
5448
|
toValue: visible ? 1 : 0,
|
|
5409
5449
|
duration: 250,
|
|
5410
5450
|
useNativeDriver: true
|
|
5411
5451
|
}).start();
|
|
5412
5452
|
}, [visible, overlayOpacity]);
|
|
5413
|
-
(0,
|
|
5453
|
+
(0, import_react38.useEffect)(() => {
|
|
5414
5454
|
if (visible) {
|
|
5415
5455
|
setSelectedAmount(defaultAmount ?? null);
|
|
5416
5456
|
setCustomAmount("");
|
|
@@ -5418,7 +5458,7 @@ function CreateCustomGameSheet({
|
|
|
5418
5458
|
mutation.reset();
|
|
5419
5459
|
}
|
|
5420
5460
|
}, [visible]);
|
|
5421
|
-
(0,
|
|
5461
|
+
(0, import_react38.useEffect)(() => {
|
|
5422
5462
|
if (mutation.status === "success" && mutation.data) {
|
|
5423
5463
|
onSuccess?.(mutation.data);
|
|
5424
5464
|
const timer = setTimeout(() => {
|
|
@@ -5427,23 +5467,23 @@ function CreateCustomGameSheet({
|
|
|
5427
5467
|
return () => clearTimeout(timer);
|
|
5428
5468
|
}
|
|
5429
5469
|
}, [mutation.status, mutation.data]);
|
|
5430
|
-
(0,
|
|
5470
|
+
(0, import_react38.useEffect)(() => {
|
|
5431
5471
|
if (mutation.status === "error" && mutation.error) {
|
|
5432
5472
|
onError?.(mutation.error);
|
|
5433
5473
|
}
|
|
5434
5474
|
}, [mutation.status, mutation.error]);
|
|
5435
|
-
const handlePresetSelect = (0,
|
|
5475
|
+
const handlePresetSelect = (0, import_react38.useCallback)((amount) => {
|
|
5436
5476
|
setSelectedAmount(amount);
|
|
5437
5477
|
setIsCustom(false);
|
|
5438
5478
|
setCustomAmount("");
|
|
5439
5479
|
onAmountChange?.(amount);
|
|
5440
5480
|
}, [onAmountChange]);
|
|
5441
|
-
const handleCustomSelect = (0,
|
|
5481
|
+
const handleCustomSelect = (0, import_react38.useCallback)(() => {
|
|
5442
5482
|
setIsCustom(true);
|
|
5443
5483
|
setSelectedAmount(null);
|
|
5444
5484
|
onAmountChange?.(null);
|
|
5445
5485
|
}, [onAmountChange]);
|
|
5446
|
-
const handleCustomAmountChange = (0,
|
|
5486
|
+
const handleCustomAmountChange = (0, import_react38.useCallback)((text) => {
|
|
5447
5487
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
5448
5488
|
setCustomAmount(cleaned);
|
|
5449
5489
|
const parsed = parseFloat(cleaned);
|
|
@@ -5458,7 +5498,7 @@ function CreateCustomGameSheet({
|
|
|
5458
5498
|
const winnerTakes = pot * (1 - fee / 100);
|
|
5459
5499
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5460
5500
|
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
5461
|
-
const handleCreate = (0,
|
|
5501
|
+
const handleCreate = (0, import_react38.useCallback)(async () => {
|
|
5462
5502
|
if (!finalAmount || !wallet.publicKey) return;
|
|
5463
5503
|
try {
|
|
5464
5504
|
await mutation.execute({
|
|
@@ -5727,11 +5767,11 @@ var styles12 = import_react_native18.StyleSheet.create({
|
|
|
5727
5767
|
});
|
|
5728
5768
|
|
|
5729
5769
|
// src/ui/game/JoinGameSheet.tsx
|
|
5730
|
-
var
|
|
5770
|
+
var import_react41 = require("react");
|
|
5731
5771
|
var import_react_native21 = require("react-native");
|
|
5732
5772
|
|
|
5733
5773
|
// src/ui/game/SolSlider.tsx
|
|
5734
|
-
var
|
|
5774
|
+
var import_react39 = require("react");
|
|
5735
5775
|
var import_react_native19 = require("react-native");
|
|
5736
5776
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
5737
5777
|
var THUMB_SIZE = 32;
|
|
@@ -5750,9 +5790,9 @@ function SolSlider({
|
|
|
5750
5790
|
}) {
|
|
5751
5791
|
const t = useDubsTheme();
|
|
5752
5792
|
const accent = accentColor || t.accent;
|
|
5753
|
-
const trackRef = (0,
|
|
5754
|
-
const trackWidth = (0,
|
|
5755
|
-
const lastTickValue = (0,
|
|
5793
|
+
const trackRef = (0, import_react39.useRef)(null);
|
|
5794
|
+
const trackWidth = (0, import_react39.useRef)(0);
|
|
5795
|
+
const lastTickValue = (0, import_react39.useRef)(value);
|
|
5756
5796
|
const clamp = (v) => {
|
|
5757
5797
|
const stepped = Math.round(v / step) * step;
|
|
5758
5798
|
return Math.max(min, Math.min(max, parseFloat(stepped.toFixed(4))));
|
|
@@ -5765,7 +5805,7 @@ function SolSlider({
|
|
|
5765
5805
|
const ratio2 = Math.max(0, Math.min(1, x / trackWidth.current));
|
|
5766
5806
|
return clamp(min + ratio2 * (max - min));
|
|
5767
5807
|
};
|
|
5768
|
-
const panResponder = (0,
|
|
5808
|
+
const panResponder = (0, import_react39.useRef)(
|
|
5769
5809
|
import_react_native19.PanResponder.create({
|
|
5770
5810
|
onStartShouldSetPanResponder: () => !disabled,
|
|
5771
5811
|
onMoveShouldSetPanResponder: () => !disabled,
|
|
@@ -5920,7 +5960,7 @@ var styles13 = import_react_native19.StyleSheet.create({
|
|
|
5920
5960
|
});
|
|
5921
5961
|
|
|
5922
5962
|
// src/ui/game/TeamButton.tsx
|
|
5923
|
-
var
|
|
5963
|
+
var import_react40 = require("react");
|
|
5924
5964
|
var import_react_native20 = require("react-native");
|
|
5925
5965
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
5926
5966
|
function TeamButton({
|
|
@@ -5934,7 +5974,7 @@ function TeamButton({
|
|
|
5934
5974
|
ImageComponent,
|
|
5935
5975
|
t
|
|
5936
5976
|
}) {
|
|
5937
|
-
const [imgFailed, setImgFailed] = (0,
|
|
5977
|
+
const [imgFailed, setImgFailed] = (0, import_react40.useState)(false);
|
|
5938
5978
|
const Img = ImageComponent || require("react-native").Image;
|
|
5939
5979
|
const showImage = imageUrl && !imgFailed;
|
|
5940
5980
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
@@ -6038,20 +6078,20 @@ function JoinGameSheet({
|
|
|
6038
6078
|
const { wallet } = useDubs();
|
|
6039
6079
|
const mutation = useJoinGame();
|
|
6040
6080
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
6041
|
-
const [selectedTeam, setSelectedTeam] = (0,
|
|
6042
|
-
const [wager, setWager] = (0,
|
|
6043
|
-
const [showSuccess, setShowSuccess] = (0,
|
|
6044
|
-
const overlayOpacity = (0,
|
|
6045
|
-
const successScale = (0,
|
|
6046
|
-
const successOpacity = (0,
|
|
6047
|
-
(0,
|
|
6081
|
+
const [selectedTeam, setSelectedTeam] = (0, import_react41.useState)(null);
|
|
6082
|
+
const [wager, setWager] = (0, import_react41.useState)(game.buyIn);
|
|
6083
|
+
const [showSuccess, setShowSuccess] = (0, import_react41.useState)(false);
|
|
6084
|
+
const overlayOpacity = (0, import_react41.useRef)(new import_react_native21.Animated.Value(0)).current;
|
|
6085
|
+
const successScale = (0, import_react41.useRef)(new import_react_native21.Animated.Value(0)).current;
|
|
6086
|
+
const successOpacity = (0, import_react41.useRef)(new import_react_native21.Animated.Value(0)).current;
|
|
6087
|
+
(0, import_react41.useEffect)(() => {
|
|
6048
6088
|
import_react_native21.Animated.timing(overlayOpacity, {
|
|
6049
6089
|
toValue: visible ? 1 : 0,
|
|
6050
6090
|
duration: 250,
|
|
6051
6091
|
useNativeDriver: true
|
|
6052
6092
|
}).start();
|
|
6053
6093
|
}, [visible, overlayOpacity]);
|
|
6054
|
-
(0,
|
|
6094
|
+
(0, import_react41.useEffect)(() => {
|
|
6055
6095
|
if (visible) {
|
|
6056
6096
|
setSelectedTeam(isPoolModeEnabled ? "home" : isCustomGame ? "away" : null);
|
|
6057
6097
|
setWager(game.buyIn);
|
|
@@ -6061,7 +6101,7 @@ function JoinGameSheet({
|
|
|
6061
6101
|
mutation.reset();
|
|
6062
6102
|
}
|
|
6063
6103
|
}, [visible]);
|
|
6064
|
-
(0,
|
|
6104
|
+
(0, import_react41.useEffect)(() => {
|
|
6065
6105
|
if (mutation.status === "success" && mutation.data) {
|
|
6066
6106
|
setShowSuccess(true);
|
|
6067
6107
|
onSuccess?.(mutation.data);
|
|
@@ -6078,7 +6118,7 @@ function JoinGameSheet({
|
|
|
6078
6118
|
return () => clearTimeout(timer);
|
|
6079
6119
|
}
|
|
6080
6120
|
}, [mutation.status, mutation.data]);
|
|
6081
|
-
(0,
|
|
6121
|
+
(0, import_react41.useEffect)(() => {
|
|
6082
6122
|
if (mutation.status === "error" && mutation.error) {
|
|
6083
6123
|
onError?.(mutation.error);
|
|
6084
6124
|
}
|
|
@@ -6093,7 +6133,7 @@ function JoinGameSheet({
|
|
|
6093
6133
|
const drawBettors = bettors.filter((b) => b.team === "draw");
|
|
6094
6134
|
const hasDrawOption = drawPool > 0 || drawBettors.length > 0 || game.league && ["English Premier League", "EPL", "MLS", "La Liga", "Serie A", "Bundesliga", "Ligue 1"].some((l) => (game.league || "").includes(l));
|
|
6095
6135
|
const poolAfterJoin = totalPool + wager;
|
|
6096
|
-
const { homeOdds, awayOdds, drawOdds, homeBets, awayBets, drawBets } = (0,
|
|
6136
|
+
const { homeOdds, awayOdds, drawOdds, homeBets, awayBets, drawBets } = (0, import_react41.useMemo)(() => {
|
|
6097
6137
|
const homeBetsCount = bettors.filter((b) => b.team === "home").length;
|
|
6098
6138
|
const awayBetsCount = bettors.filter((b) => b.team === "away").length;
|
|
6099
6139
|
const drawBetsCount = bettors.filter((b) => b.team === "draw").length;
|
|
@@ -6114,7 +6154,7 @@ function JoinGameSheet({
|
|
|
6114
6154
|
const potentialWinnings = selectedOdds !== "\u2014" ? formatSol(parseFloat(selectedOdds) * wager) : "\u2014";
|
|
6115
6155
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
6116
6156
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
6117
|
-
const myBet = (0,
|
|
6157
|
+
const myBet = (0, import_react41.useMemo)(() => {
|
|
6118
6158
|
if (!wallet.publicKey) return null;
|
|
6119
6159
|
const addr = wallet.publicKey.toBase58();
|
|
6120
6160
|
return bettors.find((b) => b.wallet === addr) ?? null;
|
|
@@ -6122,7 +6162,7 @@ function JoinGameSheet({
|
|
|
6122
6162
|
const alreadyJoined = myBet !== null;
|
|
6123
6163
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6124
6164
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
6125
|
-
const handleJoin = (0,
|
|
6165
|
+
const handleJoin = (0, import_react41.useCallback)(async () => {
|
|
6126
6166
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
6127
6167
|
try {
|
|
6128
6168
|
await mutation.execute({
|
|
@@ -6385,7 +6425,7 @@ function PickRow({
|
|
|
6385
6425
|
ImageComponent,
|
|
6386
6426
|
t
|
|
6387
6427
|
}) {
|
|
6388
|
-
const [imgFailed, setImgFailed] = (0,
|
|
6428
|
+
const [imgFailed, setImgFailed] = (0, import_react41.useState)(false);
|
|
6389
6429
|
const Img = ImageComponent || require("react-native").Image;
|
|
6390
6430
|
const showImage = imageUrl && !imgFailed;
|
|
6391
6431
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
@@ -6678,7 +6718,7 @@ var styles15 = import_react_native21.StyleSheet.create({
|
|
|
6678
6718
|
});
|
|
6679
6719
|
|
|
6680
6720
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
6681
|
-
var
|
|
6721
|
+
var import_react42 = require("react");
|
|
6682
6722
|
var import_react_native22 = require("react-native");
|
|
6683
6723
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
6684
6724
|
var STATUS_LABELS4 = {
|
|
@@ -6699,18 +6739,18 @@ function ClaimPrizeSheet({
|
|
|
6699
6739
|
const t = useDubsTheme();
|
|
6700
6740
|
const { wallet } = useDubs();
|
|
6701
6741
|
const mutation = useClaim();
|
|
6702
|
-
const overlayOpacity = (0,
|
|
6703
|
-
const celebrationScale = (0,
|
|
6704
|
-
const celebrationOpacity = (0,
|
|
6705
|
-
const [showCelebration, setShowCelebration] = (0,
|
|
6706
|
-
(0,
|
|
6742
|
+
const overlayOpacity = (0, import_react42.useRef)(new import_react_native22.Animated.Value(0)).current;
|
|
6743
|
+
const celebrationScale = (0, import_react42.useRef)(new import_react_native22.Animated.Value(0)).current;
|
|
6744
|
+
const celebrationOpacity = (0, import_react42.useRef)(new import_react_native22.Animated.Value(0)).current;
|
|
6745
|
+
const [showCelebration, setShowCelebration] = (0, import_react42.useState)(false);
|
|
6746
|
+
(0, import_react42.useEffect)(() => {
|
|
6707
6747
|
import_react_native22.Animated.timing(overlayOpacity, {
|
|
6708
6748
|
toValue: visible ? 1 : 0,
|
|
6709
6749
|
duration: 250,
|
|
6710
6750
|
useNativeDriver: true
|
|
6711
6751
|
}).start();
|
|
6712
6752
|
}, [visible, overlayOpacity]);
|
|
6713
|
-
(0,
|
|
6753
|
+
(0, import_react42.useEffect)(() => {
|
|
6714
6754
|
if (visible) {
|
|
6715
6755
|
mutation.reset();
|
|
6716
6756
|
setShowCelebration(false);
|
|
@@ -6718,7 +6758,7 @@ function ClaimPrizeSheet({
|
|
|
6718
6758
|
celebrationOpacity.setValue(0);
|
|
6719
6759
|
}
|
|
6720
6760
|
}, [visible]);
|
|
6721
|
-
(0,
|
|
6761
|
+
(0, import_react42.useEffect)(() => {
|
|
6722
6762
|
if (mutation.status === "success" && mutation.data) {
|
|
6723
6763
|
setShowCelebration(true);
|
|
6724
6764
|
import_react_native22.Animated.parallel([
|
|
@@ -6741,14 +6781,14 @@ function ClaimPrizeSheet({
|
|
|
6741
6781
|
return () => clearTimeout(timer);
|
|
6742
6782
|
}
|
|
6743
6783
|
}, [mutation.status, mutation.data]);
|
|
6744
|
-
(0,
|
|
6784
|
+
(0, import_react42.useEffect)(() => {
|
|
6745
6785
|
if (mutation.status === "error" && mutation.error) {
|
|
6746
6786
|
onError?.(mutation.error);
|
|
6747
6787
|
}
|
|
6748
6788
|
}, [mutation.status, mutation.error]);
|
|
6749
6789
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6750
6790
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
6751
|
-
const handleClaim = (0,
|
|
6791
|
+
const handleClaim = (0, import_react42.useCallback)(async () => {
|
|
6752
6792
|
if (!wallet.publicKey) return;
|
|
6753
6793
|
try {
|
|
6754
6794
|
await mutation.execute({
|
|
@@ -6981,7 +7021,7 @@ var styles16 = import_react_native22.StyleSheet.create({
|
|
|
6981
7021
|
});
|
|
6982
7022
|
|
|
6983
7023
|
// src/ui/game/ClaimButton.tsx
|
|
6984
|
-
var
|
|
7024
|
+
var import_react43 = require("react");
|
|
6985
7025
|
var import_react_native23 = require("react-native");
|
|
6986
7026
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
6987
7027
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -6989,9 +7029,9 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6989
7029
|
const { wallet } = useDubs();
|
|
6990
7030
|
const game = useGame(gameId);
|
|
6991
7031
|
const claimStatus = useHasClaimed(gameId);
|
|
6992
|
-
const [sheetVisible, setSheetVisible] = (0,
|
|
7032
|
+
const [sheetVisible, setSheetVisible] = (0, import_react43.useState)(false);
|
|
6993
7033
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
6994
|
-
const myBet = (0,
|
|
7034
|
+
const myBet = (0, import_react43.useMemo)(() => {
|
|
6995
7035
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
6996
7036
|
return game.data.bettors.find((b) => b.wallet === walletAddress) ?? null;
|
|
6997
7037
|
}, [walletAddress, game.data?.bettors]);
|
|
@@ -7000,7 +7040,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
7000
7040
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
7001
7041
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
7002
7042
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
7003
|
-
const handleSuccess = (0,
|
|
7043
|
+
const handleSuccess = (0, import_react43.useCallback)(
|
|
7004
7044
|
(result) => {
|
|
7005
7045
|
claimStatus.refetch();
|
|
7006
7046
|
onSuccess?.(result);
|
|
@@ -7087,7 +7127,7 @@ var styles17 = import_react_native23.StyleSheet.create({
|
|
|
7087
7127
|
});
|
|
7088
7128
|
|
|
7089
7129
|
// src/ui/game/EnterArcadePoolSheet.tsx
|
|
7090
|
-
var
|
|
7130
|
+
var import_react44 = require("react");
|
|
7091
7131
|
var import_react_native24 = require("react-native");
|
|
7092
7132
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
7093
7133
|
var STATUS_LABELS5 = {
|
|
@@ -7108,20 +7148,20 @@ function EnterArcadePoolSheet({
|
|
|
7108
7148
|
const t = useDubsTheme();
|
|
7109
7149
|
const { wallet } = useDubs();
|
|
7110
7150
|
const mutation = useEnterArcadePool();
|
|
7111
|
-
const overlayOpacity = (0,
|
|
7112
|
-
(0,
|
|
7151
|
+
const overlayOpacity = (0, import_react44.useRef)(new import_react_native24.Animated.Value(0)).current;
|
|
7152
|
+
(0, import_react44.useEffect)(() => {
|
|
7113
7153
|
import_react_native24.Animated.timing(overlayOpacity, {
|
|
7114
7154
|
toValue: visible ? 1 : 0,
|
|
7115
7155
|
duration: 250,
|
|
7116
7156
|
useNativeDriver: true
|
|
7117
7157
|
}).start();
|
|
7118
7158
|
}, [visible, overlayOpacity]);
|
|
7119
|
-
(0,
|
|
7159
|
+
(0, import_react44.useEffect)(() => {
|
|
7120
7160
|
if (visible) {
|
|
7121
7161
|
mutation.reset();
|
|
7122
7162
|
}
|
|
7123
7163
|
}, [visible]);
|
|
7124
|
-
(0,
|
|
7164
|
+
(0, import_react44.useEffect)(() => {
|
|
7125
7165
|
if (mutation.status === "success" && mutation.data) {
|
|
7126
7166
|
onSuccess?.(mutation.data);
|
|
7127
7167
|
const timer = setTimeout(() => {
|
|
@@ -7130,7 +7170,7 @@ function EnterArcadePoolSheet({
|
|
|
7130
7170
|
return () => clearTimeout(timer);
|
|
7131
7171
|
}
|
|
7132
7172
|
}, [mutation.status, mutation.data]);
|
|
7133
|
-
(0,
|
|
7173
|
+
(0, import_react44.useEffect)(() => {
|
|
7134
7174
|
if (mutation.status === "error" && mutation.error) {
|
|
7135
7175
|
onError?.(mutation.error);
|
|
7136
7176
|
}
|
|
@@ -7142,7 +7182,7 @@ function EnterArcadePoolSheet({
|
|
|
7142
7182
|
const potSol = (pool.buy_in_lamports * Number(totalBuyIns) / 1e9).toFixed(4);
|
|
7143
7183
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
7144
7184
|
const canJoin = !isMutating && mutation.status !== "success";
|
|
7145
|
-
const handleJoin = (0,
|
|
7185
|
+
const handleJoin = (0, import_react44.useCallback)(async () => {
|
|
7146
7186
|
if (!wallet.publicKey) return;
|
|
7147
7187
|
try {
|
|
7148
7188
|
await mutation.execute(pool.id);
|
|
@@ -7293,7 +7333,7 @@ var styles18 = import_react_native24.StyleSheet.create({
|
|
|
7293
7333
|
});
|
|
7294
7334
|
|
|
7295
7335
|
// src/ui/game/ArcadeLeaderboardSheet.tsx
|
|
7296
|
-
var
|
|
7336
|
+
var import_react45 = require("react");
|
|
7297
7337
|
var import_react_native25 = require("react-native");
|
|
7298
7338
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
7299
7339
|
function RankLabel({ index }) {
|
|
@@ -7310,15 +7350,15 @@ function ArcadeLeaderboardSheet({
|
|
|
7310
7350
|
}) {
|
|
7311
7351
|
const t = useDubsTheme();
|
|
7312
7352
|
const { pool, leaderboard, stats, loading, refetch } = useArcadePool(poolId);
|
|
7313
|
-
const overlayOpacity = (0,
|
|
7314
|
-
(0,
|
|
7353
|
+
const overlayOpacity = (0, import_react45.useRef)(new import_react_native25.Animated.Value(0)).current;
|
|
7354
|
+
(0, import_react45.useEffect)(() => {
|
|
7315
7355
|
import_react_native25.Animated.timing(overlayOpacity, {
|
|
7316
7356
|
toValue: visible ? 1 : 0,
|
|
7317
7357
|
duration: 250,
|
|
7318
7358
|
useNativeDriver: true
|
|
7319
7359
|
}).start();
|
|
7320
7360
|
}, [visible, overlayOpacity]);
|
|
7321
|
-
(0,
|
|
7361
|
+
(0, import_react45.useEffect)(() => {
|
|
7322
7362
|
if (visible) refetch();
|
|
7323
7363
|
}, [visible]);
|
|
7324
7364
|
const renderItem = ({ item, index }) => {
|
|
@@ -7465,7 +7505,7 @@ var styles19 = import_react_native25.StyleSheet.create({
|
|
|
7465
7505
|
});
|
|
7466
7506
|
|
|
7467
7507
|
// src/ui/game/CreateGameSheet.tsx
|
|
7468
|
-
var
|
|
7508
|
+
var import_react46 = require("react");
|
|
7469
7509
|
var import_react_native26 = require("react-native");
|
|
7470
7510
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
7471
7511
|
var STATUS_LABELS6 = {
|
|
@@ -7494,20 +7534,20 @@ function CreateGameSheet({
|
|
|
7494
7534
|
const t = useDubsTheme();
|
|
7495
7535
|
const { wallet } = useDubs();
|
|
7496
7536
|
const mutation = useCreateGame();
|
|
7497
|
-
const [selectedTeam, setSelectedTeam] = (0,
|
|
7498
|
-
const [wager, setWager] = (0,
|
|
7499
|
-
const [showSuccess, setShowSuccess] = (0,
|
|
7500
|
-
const overlayOpacity = (0,
|
|
7501
|
-
const successScale = (0,
|
|
7502
|
-
const successOpacity = (0,
|
|
7503
|
-
(0,
|
|
7537
|
+
const [selectedTeam, setSelectedTeam] = (0, import_react46.useState)(null);
|
|
7538
|
+
const [wager, setWager] = (0, import_react46.useState)(0.01);
|
|
7539
|
+
const [showSuccess, setShowSuccess] = (0, import_react46.useState)(false);
|
|
7540
|
+
const overlayOpacity = (0, import_react46.useRef)(new import_react_native26.Animated.Value(0)).current;
|
|
7541
|
+
const successScale = (0, import_react46.useRef)(new import_react_native26.Animated.Value(0)).current;
|
|
7542
|
+
const successOpacity = (0, import_react46.useRef)(new import_react_native26.Animated.Value(0)).current;
|
|
7543
|
+
(0, import_react46.useEffect)(() => {
|
|
7504
7544
|
import_react_native26.Animated.timing(overlayOpacity, {
|
|
7505
7545
|
toValue: visible ? 1 : 0,
|
|
7506
7546
|
duration: 250,
|
|
7507
7547
|
useNativeDriver: true
|
|
7508
7548
|
}).start();
|
|
7509
7549
|
}, [visible]);
|
|
7510
|
-
(0,
|
|
7550
|
+
(0, import_react46.useEffect)(() => {
|
|
7511
7551
|
if (visible) {
|
|
7512
7552
|
setSelectedTeam(null);
|
|
7513
7553
|
setWager(0.01);
|
|
@@ -7517,7 +7557,7 @@ function CreateGameSheet({
|
|
|
7517
7557
|
mutation.reset();
|
|
7518
7558
|
}
|
|
7519
7559
|
}, [visible]);
|
|
7520
|
-
(0,
|
|
7560
|
+
(0, import_react46.useEffect)(() => {
|
|
7521
7561
|
if (mutation.status === "success" && mutation.data) {
|
|
7522
7562
|
setShowSuccess(true);
|
|
7523
7563
|
onSuccess?.(mutation.data);
|
|
@@ -7534,7 +7574,7 @@ function CreateGameSheet({
|
|
|
7534
7574
|
return () => clearTimeout(timer);
|
|
7535
7575
|
}
|
|
7536
7576
|
}, [mutation.status, mutation.data]);
|
|
7537
|
-
(0,
|
|
7577
|
+
(0, import_react46.useEffect)(() => {
|
|
7538
7578
|
if (mutation.status === "error" && mutation.error) {
|
|
7539
7579
|
onError?.(mutation.error);
|
|
7540
7580
|
}
|
|
@@ -7544,7 +7584,7 @@ function CreateGameSheet({
|
|
|
7544
7584
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
7545
7585
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
7546
7586
|
const canCreate = selectedTeam !== null && !isMutating && mutation.status !== "success";
|
|
7547
|
-
const handleCreate = (0,
|
|
7587
|
+
const handleCreate = (0, import_react46.useCallback)(async () => {
|
|
7548
7588
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
7549
7589
|
try {
|
|
7550
7590
|
await mutation.execute({
|
|
@@ -7692,7 +7732,7 @@ var styles20 = import_react_native26.StyleSheet.create({
|
|
|
7692
7732
|
});
|
|
7693
7733
|
|
|
7694
7734
|
// src/ui/jackpot/JackpotCard.tsx
|
|
7695
|
-
var
|
|
7735
|
+
var import_react47 = require("react");
|
|
7696
7736
|
var import_react_native27 = require("react-native");
|
|
7697
7737
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
7698
7738
|
function formatSOL(lamports) {
|
|
@@ -7709,9 +7749,9 @@ function truncateWallet2(addr) {
|
|
|
7709
7749
|
return `${addr.slice(0, 4)}...${addr.slice(-4)}`;
|
|
7710
7750
|
}
|
|
7711
7751
|
function JackpotCard({ round, lastWinner, entries, onPress, style }) {
|
|
7712
|
-
const shimmerAnim = (0,
|
|
7713
|
-
const pulseAnim = (0,
|
|
7714
|
-
(0,
|
|
7752
|
+
const shimmerAnim = (0, import_react47.useRef)(new import_react_native27.Animated.Value(-1)).current;
|
|
7753
|
+
const pulseAnim = (0, import_react47.useRef)(new import_react_native27.Animated.Value(0.4)).current;
|
|
7754
|
+
(0, import_react47.useEffect)(() => {
|
|
7715
7755
|
const shimmer = import_react_native27.Animated.loop(
|
|
7716
7756
|
import_react_native27.Animated.sequence([
|
|
7717
7757
|
import_react_native27.Animated.timing(shimmerAnim, { toValue: 1, duration: 4e3, useNativeDriver: true }),
|
|
@@ -8070,7 +8110,7 @@ var styles21 = import_react_native27.StyleSheet.create({
|
|
|
8070
8110
|
});
|
|
8071
8111
|
|
|
8072
8112
|
// src/ui/jackpot/JackpotSheet.tsx
|
|
8073
|
-
var
|
|
8113
|
+
var import_react48 = require("react");
|
|
8074
8114
|
var import_react_native28 = require("react-native");
|
|
8075
8115
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
8076
8116
|
var STATUS_LABELS7 = {
|
|
@@ -8105,17 +8145,17 @@ function JackpotSheet({
|
|
|
8105
8145
|
const { wallet, client } = useDubs();
|
|
8106
8146
|
const { round, lastWinner, refetch } = useJackpot();
|
|
8107
8147
|
const mutation = useEnterJackpot();
|
|
8108
|
-
const [betAmount, setBetAmount] = (0,
|
|
8109
|
-
const [entries, setEntries] = (0,
|
|
8110
|
-
const overlayOpacity = (0,
|
|
8111
|
-
(0,
|
|
8148
|
+
const [betAmount, setBetAmount] = (0, import_react48.useState)("0.1");
|
|
8149
|
+
const [entries, setEntries] = (0, import_react48.useState)([]);
|
|
8150
|
+
const overlayOpacity = (0, import_react48.useRef)(new import_react_native28.Animated.Value(0)).current;
|
|
8151
|
+
(0, import_react48.useEffect)(() => {
|
|
8112
8152
|
import_react_native28.Animated.timing(overlayOpacity, {
|
|
8113
8153
|
toValue: visible ? 1 : 0,
|
|
8114
8154
|
duration: 250,
|
|
8115
8155
|
useNativeDriver: true
|
|
8116
8156
|
}).start();
|
|
8117
8157
|
}, [visible, overlayOpacity]);
|
|
8118
|
-
(0,
|
|
8158
|
+
(0, import_react48.useEffect)(() => {
|
|
8119
8159
|
if (visible) {
|
|
8120
8160
|
mutation.reset();
|
|
8121
8161
|
setBetAmount("0.1");
|
|
@@ -8124,7 +8164,7 @@ function JackpotSheet({
|
|
|
8124
8164
|
});
|
|
8125
8165
|
}
|
|
8126
8166
|
}, [visible]);
|
|
8127
|
-
(0,
|
|
8167
|
+
(0, import_react48.useEffect)(() => {
|
|
8128
8168
|
if (mutation.status === "success" && mutation.data) {
|
|
8129
8169
|
onSuccess?.(mutation.data);
|
|
8130
8170
|
refetch();
|
|
@@ -8134,7 +8174,7 @@ function JackpotSheet({
|
|
|
8134
8174
|
return () => clearTimeout(timer);
|
|
8135
8175
|
}
|
|
8136
8176
|
}, [mutation.status, mutation.data]);
|
|
8137
|
-
(0,
|
|
8177
|
+
(0, import_react48.useEffect)(() => {
|
|
8138
8178
|
if (mutation.status === "error" && mutation.error) {
|
|
8139
8179
|
onError?.(mutation.error);
|
|
8140
8180
|
}
|
|
@@ -8146,14 +8186,14 @@ function JackpotSheet({
|
|
|
8146
8186
|
const userOdds = totalWeight > 0 ? (entryLamports / (totalWeight + entryLamports) * 100).toFixed(1) : entries.length === 0 ? "100.0" : "0.0";
|
|
8147
8187
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
8148
8188
|
const canEnter = !isMutating && mutation.status !== "success" && round?.status === "Open" && betSol >= minEntry;
|
|
8149
|
-
const handleQuickAdd = (0,
|
|
8189
|
+
const handleQuickAdd = (0, import_react48.useCallback)((amount) => {
|
|
8150
8190
|
setBetAmount((prev) => {
|
|
8151
8191
|
const current = parseFloat(prev) || 0;
|
|
8152
8192
|
const next = Math.min(current + amount, maxEntry);
|
|
8153
8193
|
return next.toFixed(2);
|
|
8154
8194
|
});
|
|
8155
8195
|
}, [maxEntry]);
|
|
8156
|
-
const handleEnter = (0,
|
|
8196
|
+
const handleEnter = (0, import_react48.useCallback)(async () => {
|
|
8157
8197
|
if (!wallet.publicKey || entryLamports < 1e4) return;
|
|
8158
8198
|
try {
|
|
8159
8199
|
await mutation.execute(entryLamports);
|
|
@@ -8672,7 +8712,7 @@ var styles22 = import_react_native28.StyleSheet.create({
|
|
|
8672
8712
|
});
|
|
8673
8713
|
|
|
8674
8714
|
// src/ui/jackpot/JackpotWidget.tsx
|
|
8675
|
-
var
|
|
8715
|
+
var import_react49 = require("react");
|
|
8676
8716
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
8677
8717
|
function JackpotWidget({
|
|
8678
8718
|
style,
|
|
@@ -8681,11 +8721,11 @@ function JackpotWidget({
|
|
|
8681
8721
|
onEntry,
|
|
8682
8722
|
onError
|
|
8683
8723
|
}) {
|
|
8684
|
-
const [sheetVisible, setSheetVisible] = (0,
|
|
8724
|
+
const [sheetVisible, setSheetVisible] = (0, import_react49.useState)(false);
|
|
8685
8725
|
const { round, lastWinner } = useJackpot();
|
|
8686
8726
|
const { client } = useDubs();
|
|
8687
|
-
const [entries, setEntries] = (0,
|
|
8688
|
-
(0,
|
|
8727
|
+
const [entries, setEntries] = (0, import_react49.useState)([]);
|
|
8728
|
+
(0, import_react49.useEffect)(() => {
|
|
8689
8729
|
client.getJackpotEntries().then((res) => setEntries(res.entries)).catch(() => {
|
|
8690
8730
|
});
|
|
8691
8731
|
}, [client, round?.entryCount]);
|
|
@@ -8719,7 +8759,7 @@ function JackpotWidget({
|
|
|
8719
8759
|
}
|
|
8720
8760
|
|
|
8721
8761
|
// src/chat/provider.tsx
|
|
8722
|
-
var
|
|
8762
|
+
var import_react50 = require("react");
|
|
8723
8763
|
var import_react_native29 = require("react-native");
|
|
8724
8764
|
|
|
8725
8765
|
// src/chat/socket.ts
|
|
@@ -8829,22 +8869,22 @@ var ChatSocket = class {
|
|
|
8829
8869
|
|
|
8830
8870
|
// src/chat/provider.tsx
|
|
8831
8871
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
8832
|
-
var ChatContext = (0,
|
|
8872
|
+
var ChatContext = (0, import_react50.createContext)(null);
|
|
8833
8873
|
function ChatProvider({ children, autoConnect = true }) {
|
|
8834
8874
|
const { client } = useDubs();
|
|
8835
|
-
const socketRef = (0,
|
|
8836
|
-
const [status, setStatus] = (0,
|
|
8837
|
-
const [messages, setMessages] = (0,
|
|
8838
|
-
const [onlineUsers, setOnlineUsers] = (0,
|
|
8839
|
-
const [onlineCount, setOnlineCount] = (0,
|
|
8840
|
-
const [unreadCount, setUnreadCount] = (0,
|
|
8841
|
-
const [conversations, setConversations] = (0,
|
|
8842
|
-
const [friends, setFriends] = (0,
|
|
8843
|
-
const [pendingRequests, setPendingRequests] = (0,
|
|
8844
|
-
const [sentFriendRequests, setSentFriendRequests] = (0,
|
|
8845
|
-
const [whatsNewPosts, setWhatsNewPosts] = (0,
|
|
8846
|
-
const [whatsNewUnreadCount, setWhatsNewUnreadCount] = (0,
|
|
8847
|
-
const refreshMessages = (0,
|
|
8875
|
+
const socketRef = (0, import_react50.useRef)(new ChatSocket());
|
|
8876
|
+
const [status, setStatus] = (0, import_react50.useState)("disconnected");
|
|
8877
|
+
const [messages, setMessages] = (0, import_react50.useState)([]);
|
|
8878
|
+
const [onlineUsers, setOnlineUsers] = (0, import_react50.useState)([]);
|
|
8879
|
+
const [onlineCount, setOnlineCount] = (0, import_react50.useState)(0);
|
|
8880
|
+
const [unreadCount, setUnreadCount] = (0, import_react50.useState)(0);
|
|
8881
|
+
const [conversations, setConversations] = (0, import_react50.useState)([]);
|
|
8882
|
+
const [friends, setFriends] = (0, import_react50.useState)([]);
|
|
8883
|
+
const [pendingRequests, setPendingRequests] = (0, import_react50.useState)([]);
|
|
8884
|
+
const [sentFriendRequests, setSentFriendRequests] = (0, import_react50.useState)([]);
|
|
8885
|
+
const [whatsNewPosts, setWhatsNewPosts] = (0, import_react50.useState)([]);
|
|
8886
|
+
const [whatsNewUnreadCount, setWhatsNewUnreadCount] = (0, import_react50.useState)(0);
|
|
8887
|
+
const refreshMessages = (0, import_react50.useCallback)(async () => {
|
|
8848
8888
|
try {
|
|
8849
8889
|
const res = await client.getChatMessages({ limit: 30 });
|
|
8850
8890
|
setMessages([...res.messages].reverse());
|
|
@@ -8852,35 +8892,35 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8852
8892
|
console.error("[Dubs:ChatProvider] Failed to load messages:", err);
|
|
8853
8893
|
}
|
|
8854
8894
|
}, [client]);
|
|
8855
|
-
const refreshConversations = (0,
|
|
8895
|
+
const refreshConversations = (0, import_react50.useCallback)(async () => {
|
|
8856
8896
|
try {
|
|
8857
8897
|
const res = await client.getConversations();
|
|
8858
8898
|
setConversations(res.conversations);
|
|
8859
8899
|
} catch (_) {
|
|
8860
8900
|
}
|
|
8861
8901
|
}, [client]);
|
|
8862
|
-
const refreshFriends = (0,
|
|
8902
|
+
const refreshFriends = (0, import_react50.useCallback)(async () => {
|
|
8863
8903
|
try {
|
|
8864
8904
|
const res = await client.getFriends();
|
|
8865
8905
|
setFriends(res.friends);
|
|
8866
8906
|
} catch (_) {
|
|
8867
8907
|
}
|
|
8868
8908
|
}, [client]);
|
|
8869
|
-
const refreshPendingRequests = (0,
|
|
8909
|
+
const refreshPendingRequests = (0, import_react50.useCallback)(async () => {
|
|
8870
8910
|
try {
|
|
8871
8911
|
const res = await client.getPendingFriendRequests();
|
|
8872
8912
|
setPendingRequests(res.requests);
|
|
8873
8913
|
} catch (_) {
|
|
8874
8914
|
}
|
|
8875
8915
|
}, [client]);
|
|
8876
|
-
const refreshSentFriendRequests = (0,
|
|
8916
|
+
const refreshSentFriendRequests = (0, import_react50.useCallback)(async () => {
|
|
8877
8917
|
try {
|
|
8878
8918
|
const res = await client.getSentFriendRequests();
|
|
8879
8919
|
setSentFriendRequests(res.requests);
|
|
8880
8920
|
} catch (_) {
|
|
8881
8921
|
}
|
|
8882
8922
|
}, [client]);
|
|
8883
|
-
const refreshWhatsNew = (0,
|
|
8923
|
+
const refreshWhatsNew = (0, import_react50.useCallback)(async () => {
|
|
8884
8924
|
try {
|
|
8885
8925
|
const res = await client.getWhatsNewPosts();
|
|
8886
8926
|
setWhatsNewPosts(res.posts);
|
|
@@ -8889,7 +8929,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8889
8929
|
} catch (_) {
|
|
8890
8930
|
}
|
|
8891
8931
|
}, [client]);
|
|
8892
|
-
(0,
|
|
8932
|
+
(0, import_react50.useEffect)(() => {
|
|
8893
8933
|
const token = client.getToken();
|
|
8894
8934
|
if (!autoConnect || !token) return;
|
|
8895
8935
|
const chatSocket = socketRef.current;
|
|
@@ -8967,7 +9007,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8967
9007
|
chatSocket.disconnect();
|
|
8968
9008
|
};
|
|
8969
9009
|
}, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8970
|
-
(0,
|
|
9010
|
+
(0, import_react50.useEffect)(() => {
|
|
8971
9011
|
const handleAppState = (nextState) => {
|
|
8972
9012
|
if (nextState === "active") {
|
|
8973
9013
|
const chatSocket = socketRef.current;
|
|
@@ -8995,7 +9035,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8995
9035
|
const sub = import_react_native29.AppState.addEventListener("change", handleAppState);
|
|
8996
9036
|
return () => sub.remove();
|
|
8997
9037
|
}, [client, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8998
|
-
const value = (0,
|
|
9038
|
+
const value = (0, import_react50.useMemo)(
|
|
8999
9039
|
() => ({
|
|
9000
9040
|
socket: socketRef.current,
|
|
9001
9041
|
status,
|
|
@@ -9021,7 +9061,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
9021
9061
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ChatContext.Provider, { value, children });
|
|
9022
9062
|
}
|
|
9023
9063
|
function useChatContext() {
|
|
9024
|
-
const ctx = (0,
|
|
9064
|
+
const ctx = (0, import_react50.useContext)(ChatContext);
|
|
9025
9065
|
if (!ctx) {
|
|
9026
9066
|
throw new Error("useChatContext must be used inside a <ChatProvider>");
|
|
9027
9067
|
}
|
|
@@ -9029,14 +9069,14 @@ function useChatContext() {
|
|
|
9029
9069
|
}
|
|
9030
9070
|
|
|
9031
9071
|
// src/chat/hooks.ts
|
|
9032
|
-
var
|
|
9072
|
+
var import_react51 = require("react");
|
|
9033
9073
|
function useChatStatus() {
|
|
9034
9074
|
return useChatContext().status;
|
|
9035
9075
|
}
|
|
9036
9076
|
function useChatMessages() {
|
|
9037
9077
|
const { messages, refreshMessages } = useChatContext();
|
|
9038
|
-
const [loading, setLoading] = (0,
|
|
9039
|
-
const refetch = (0,
|
|
9078
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9079
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9040
9080
|
setLoading(true);
|
|
9041
9081
|
await refreshMessages();
|
|
9042
9082
|
setLoading(false);
|
|
@@ -9046,13 +9086,13 @@ function useChatMessages() {
|
|
|
9046
9086
|
function useSendMessage() {
|
|
9047
9087
|
const { socket } = useChatContext();
|
|
9048
9088
|
const { client } = useDubs();
|
|
9049
|
-
const send = (0,
|
|
9089
|
+
const send = (0, import_react51.useCallback)(
|
|
9050
9090
|
(params) => {
|
|
9051
9091
|
socket.sendMessage(params);
|
|
9052
9092
|
},
|
|
9053
9093
|
[socket]
|
|
9054
9094
|
);
|
|
9055
|
-
const sendViaREST = (0,
|
|
9095
|
+
const sendViaREST = (0, import_react51.useCallback)(
|
|
9056
9096
|
async (params) => {
|
|
9057
9097
|
await client.sendChatMessage(params);
|
|
9058
9098
|
},
|
|
@@ -9069,8 +9109,8 @@ function useUnreadCount() {
|
|
|
9069
9109
|
}
|
|
9070
9110
|
function useConversations() {
|
|
9071
9111
|
const { conversations, refreshConversations } = useChatContext();
|
|
9072
|
-
const [loading, setLoading] = (0,
|
|
9073
|
-
const refetch = (0,
|
|
9112
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9113
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9074
9114
|
setLoading(true);
|
|
9075
9115
|
await refreshConversations();
|
|
9076
9116
|
setLoading(false);
|
|
@@ -9080,10 +9120,10 @@ function useConversations() {
|
|
|
9080
9120
|
function useDirectMessages(recipientWallet) {
|
|
9081
9121
|
const { client } = useDubs();
|
|
9082
9122
|
const { socket, refreshConversations } = useChatContext();
|
|
9083
|
-
const [messages, setMessages] = (0,
|
|
9084
|
-
const [otherUser, setOtherUser] = (0,
|
|
9085
|
-
const [loading, setLoading] = (0,
|
|
9086
|
-
const refetch = (0,
|
|
9123
|
+
const [messages, setMessages] = (0, import_react51.useState)([]);
|
|
9124
|
+
const [otherUser, setOtherUser] = (0, import_react51.useState)(null);
|
|
9125
|
+
const [loading, setLoading] = (0, import_react51.useState)(true);
|
|
9126
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9087
9127
|
try {
|
|
9088
9128
|
setLoading(true);
|
|
9089
9129
|
const res = await client.getConversation(recipientWallet);
|
|
@@ -9095,16 +9135,16 @@ function useDirectMessages(recipientWallet) {
|
|
|
9095
9135
|
setLoading(false);
|
|
9096
9136
|
}
|
|
9097
9137
|
}, [client, recipientWallet]);
|
|
9098
|
-
(0,
|
|
9138
|
+
(0, import_react51.useEffect)(() => {
|
|
9099
9139
|
refetch();
|
|
9100
9140
|
socket.joinDM(recipientWallet);
|
|
9101
9141
|
return () => {
|
|
9102
9142
|
socket.leaveDM(recipientWallet);
|
|
9103
9143
|
};
|
|
9104
9144
|
}, [recipientWallet, refetch, socket]);
|
|
9105
|
-
const socketRef = (0,
|
|
9145
|
+
const socketRef = (0, import_react51.useRef)(socket);
|
|
9106
9146
|
socketRef.current = socket;
|
|
9107
|
-
(0,
|
|
9147
|
+
(0, import_react51.useEffect)(() => {
|
|
9108
9148
|
const currentSocket = socketRef.current;
|
|
9109
9149
|
const prevListeners = currentSocket.listeners;
|
|
9110
9150
|
const originalOnDMNew = prevListeners?.onDMNewMessage;
|
|
@@ -9127,13 +9167,13 @@ function useDirectMessages(recipientWallet) {
|
|
|
9127
9167
|
}
|
|
9128
9168
|
});
|
|
9129
9169
|
}, [recipientWallet]);
|
|
9130
|
-
const send = (0,
|
|
9170
|
+
const send = (0, import_react51.useCallback)(
|
|
9131
9171
|
(message) => {
|
|
9132
9172
|
socket.sendDM({ recipientWallet, message });
|
|
9133
9173
|
},
|
|
9134
9174
|
[socket, recipientWallet]
|
|
9135
9175
|
);
|
|
9136
|
-
const sendViaREST = (0,
|
|
9176
|
+
const sendViaREST = (0, import_react51.useCallback)(
|
|
9137
9177
|
async (message) => {
|
|
9138
9178
|
await client.sendDirectMessage({ recipientWallet, message });
|
|
9139
9179
|
await refetch();
|
|
@@ -9141,15 +9181,15 @@ function useDirectMessages(recipientWallet) {
|
|
|
9141
9181
|
},
|
|
9142
9182
|
[client, recipientWallet, refetch, refreshConversations]
|
|
9143
9183
|
);
|
|
9144
|
-
const markRead = (0,
|
|
9184
|
+
const markRead = (0, import_react51.useCallback)(() => {
|
|
9145
9185
|
socket.markDMRead(recipientWallet);
|
|
9146
9186
|
}, [socket, recipientWallet]);
|
|
9147
9187
|
return { messages, loading, otherUser, send, sendViaREST, markRead, refetch };
|
|
9148
9188
|
}
|
|
9149
9189
|
function useFriends() {
|
|
9150
9190
|
const { friends, refreshFriends } = useChatContext();
|
|
9151
|
-
const [loading, setLoading] = (0,
|
|
9152
|
-
const refetch = (0,
|
|
9191
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9192
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9153
9193
|
setLoading(true);
|
|
9154
9194
|
await refreshFriends();
|
|
9155
9195
|
setLoading(false);
|
|
@@ -9158,8 +9198,8 @@ function useFriends() {
|
|
|
9158
9198
|
}
|
|
9159
9199
|
function useFriendRequests() {
|
|
9160
9200
|
const { pendingRequests, refreshPendingRequests } = useChatContext();
|
|
9161
|
-
const [loading, setLoading] = (0,
|
|
9162
|
-
const refetch = (0,
|
|
9201
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9202
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9163
9203
|
setLoading(true);
|
|
9164
9204
|
await refreshPendingRequests();
|
|
9165
9205
|
setLoading(false);
|
|
@@ -9168,8 +9208,8 @@ function useFriendRequests() {
|
|
|
9168
9208
|
}
|
|
9169
9209
|
function useSentFriendRequests() {
|
|
9170
9210
|
const { sentFriendRequests, refreshSentFriendRequests } = useChatContext();
|
|
9171
|
-
const [loading, setLoading] = (0,
|
|
9172
|
-
const refetch = (0,
|
|
9211
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9212
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9173
9213
|
setLoading(true);
|
|
9174
9214
|
await refreshSentFriendRequests();
|
|
9175
9215
|
setLoading(false);
|
|
@@ -9179,8 +9219,8 @@ function useSentFriendRequests() {
|
|
|
9179
9219
|
function useCancelFriendRequest() {
|
|
9180
9220
|
const { client } = useDubs();
|
|
9181
9221
|
const { refreshSentFriendRequests } = useChatContext();
|
|
9182
|
-
const [loading, setLoading] = (0,
|
|
9183
|
-
const cancel = (0,
|
|
9222
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9223
|
+
const cancel = (0, import_react51.useCallback)(
|
|
9184
9224
|
async (requestId) => {
|
|
9185
9225
|
setLoading(true);
|
|
9186
9226
|
try {
|
|
@@ -9196,9 +9236,9 @@ function useCancelFriendRequest() {
|
|
|
9196
9236
|
}
|
|
9197
9237
|
function useSearchUsers() {
|
|
9198
9238
|
const { client } = useDubs();
|
|
9199
|
-
const [results, setResults] = (0,
|
|
9200
|
-
const [loading, setLoading] = (0,
|
|
9201
|
-
const search = (0,
|
|
9239
|
+
const [results, setResults] = (0, import_react51.useState)([]);
|
|
9240
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9241
|
+
const search = (0, import_react51.useCallback)(
|
|
9202
9242
|
async (query) => {
|
|
9203
9243
|
setLoading(true);
|
|
9204
9244
|
try {
|
|
@@ -9212,14 +9252,14 @@ function useSearchUsers() {
|
|
|
9212
9252
|
},
|
|
9213
9253
|
[client]
|
|
9214
9254
|
);
|
|
9215
|
-
const clear = (0,
|
|
9255
|
+
const clear = (0, import_react51.useCallback)(() => setResults([]), []);
|
|
9216
9256
|
return { results, loading, search, clear };
|
|
9217
9257
|
}
|
|
9218
9258
|
function useSendFriendRequest() {
|
|
9219
9259
|
const { client } = useDubs();
|
|
9220
9260
|
const { refreshPendingRequests } = useChatContext();
|
|
9221
|
-
const [loading, setLoading] = (0,
|
|
9222
|
-
const send = (0,
|
|
9261
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9262
|
+
const send = (0, import_react51.useCallback)(
|
|
9223
9263
|
async (targetUserId) => {
|
|
9224
9264
|
setLoading(true);
|
|
9225
9265
|
try {
|
|
@@ -9235,8 +9275,8 @@ function useSendFriendRequest() {
|
|
|
9235
9275
|
function useRespondToFriendRequest() {
|
|
9236
9276
|
const { client } = useDubs();
|
|
9237
9277
|
const { refreshFriends, refreshPendingRequests } = useChatContext();
|
|
9238
|
-
const [loading, setLoading] = (0,
|
|
9239
|
-
const accept = (0,
|
|
9278
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9279
|
+
const accept = (0, import_react51.useCallback)(
|
|
9240
9280
|
async (requestId) => {
|
|
9241
9281
|
setLoading(true);
|
|
9242
9282
|
try {
|
|
@@ -9248,7 +9288,7 @@ function useRespondToFriendRequest() {
|
|
|
9248
9288
|
},
|
|
9249
9289
|
[client, refreshFriends, refreshPendingRequests]
|
|
9250
9290
|
);
|
|
9251
|
-
const reject = (0,
|
|
9291
|
+
const reject = (0, import_react51.useCallback)(
|
|
9252
9292
|
async (requestId) => {
|
|
9253
9293
|
setLoading(true);
|
|
9254
9294
|
try {
|
|
@@ -9265,8 +9305,8 @@ function useRespondToFriendRequest() {
|
|
|
9265
9305
|
function useWhatsNew() {
|
|
9266
9306
|
const { client } = useDubs();
|
|
9267
9307
|
const { whatsNewPosts, whatsNewUnreadCount, refreshWhatsNew } = useChatContext();
|
|
9268
|
-
const [loading, setLoading] = (0,
|
|
9269
|
-
const refetch = (0,
|
|
9308
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9309
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9270
9310
|
setLoading(true);
|
|
9271
9311
|
try {
|
|
9272
9312
|
await refreshWhatsNew();
|
|
@@ -9274,7 +9314,7 @@ function useWhatsNew() {
|
|
|
9274
9314
|
setLoading(false);
|
|
9275
9315
|
}
|
|
9276
9316
|
}, [refreshWhatsNew]);
|
|
9277
|
-
const markRead = (0,
|
|
9317
|
+
const markRead = (0, import_react51.useCallback)(
|
|
9278
9318
|
async (postIds) => {
|
|
9279
9319
|
if (postIds.length === 0) return;
|
|
9280
9320
|
try {
|
|
@@ -9286,7 +9326,7 @@ function useWhatsNew() {
|
|
|
9286
9326
|
},
|
|
9287
9327
|
[client, refreshWhatsNew]
|
|
9288
9328
|
);
|
|
9289
|
-
const markAllRead = (0,
|
|
9329
|
+
const markAllRead = (0, import_react51.useCallback)(async () => {
|
|
9290
9330
|
try {
|
|
9291
9331
|
await client.markAllWhatsNewRead();
|
|
9292
9332
|
await refreshWhatsNew();
|
|
@@ -9361,6 +9401,7 @@ function useWhatsNew() {
|
|
|
9361
9401
|
useConversations,
|
|
9362
9402
|
useCreateCustomGame,
|
|
9363
9403
|
useCreateGame,
|
|
9404
|
+
useCredits,
|
|
9364
9405
|
useDirectMessages,
|
|
9365
9406
|
useDubs,
|
|
9366
9407
|
useDubsTheme,
|