@dubsdotapp/expo 0.5.30 → 0.5.31
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 +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +236 -223
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +186 -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 +1 -0
- package/src/types.ts +15 -0
package/dist/index.js
CHANGED
|
@@ -715,6 +715,16 @@ var DubsClient = class {
|
|
|
715
715
|
);
|
|
716
716
|
return { round: res.round, lastWinner: res.lastWinner };
|
|
717
717
|
}
|
|
718
|
+
/**
|
|
719
|
+
* List the authenticated user's active promo credits — codes that
|
|
720
|
+
* have been reserved to them but not yet used in a game. Includes
|
|
721
|
+
* streak-milestone unlocks (auto-minted at each 1000-dub crossing)
|
|
722
|
+
* and any manually-reserved Twitter giveaway codes.
|
|
723
|
+
*/
|
|
724
|
+
async getCredits() {
|
|
725
|
+
const res = await this.request("GET", "/me/credits");
|
|
726
|
+
return { credits: res.credits, totalLamports: res.totalLamports, totalSOL: res.totalSOL };
|
|
727
|
+
}
|
|
718
728
|
/** Get current round entries with odds */
|
|
719
729
|
async getJackpotEntries() {
|
|
720
730
|
const res = await this.request(
|
|
@@ -936,7 +946,7 @@ function createSecureStoreStorage() {
|
|
|
936
946
|
}
|
|
937
947
|
|
|
938
948
|
// src/provider.tsx
|
|
939
|
-
var
|
|
949
|
+
var import_react30 = require("react");
|
|
940
950
|
|
|
941
951
|
// src/ui/theme.ts
|
|
942
952
|
var import_react = require("react");
|
|
@@ -1994,7 +2004,7 @@ function ManagedWalletProvider({
|
|
|
1994
2004
|
}
|
|
1995
2005
|
|
|
1996
2006
|
// src/ui/AuthGate.tsx
|
|
1997
|
-
var
|
|
2007
|
+
var import_react29 = __toESM(require("react"));
|
|
1998
2008
|
var import_react_native8 = require("react-native");
|
|
1999
2009
|
|
|
2000
2010
|
// src/hooks/useEvents.ts
|
|
@@ -3351,6 +3361,9 @@ function useEnterJackpot() {
|
|
|
3351
3361
|
return { execute, status, error, data, reset };
|
|
3352
3362
|
}
|
|
3353
3363
|
|
|
3364
|
+
// src/hooks/useCredits.ts
|
|
3365
|
+
var import_react28 = require("react");
|
|
3366
|
+
|
|
3354
3367
|
// src/ui/AvatarEditor.tsx
|
|
3355
3368
|
var import_react_native7 = require("react-native");
|
|
3356
3369
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -3512,11 +3525,11 @@ function AuthGate({
|
|
|
3512
3525
|
}) {
|
|
3513
3526
|
const { client, pushEnabled, uiConfig } = useDubs();
|
|
3514
3527
|
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,
|
|
3528
|
+
const [phase, setPhase] = (0, import_react29.useState)("init");
|
|
3529
|
+
const [registrationPhase, setRegistrationPhase] = (0, import_react29.useState)(false);
|
|
3530
|
+
const [showPushSetup, setShowPushSetup] = (0, import_react29.useState)(false);
|
|
3531
|
+
const [isRestoredSession, setIsRestoredSession] = (0, import_react29.useState)(false);
|
|
3532
|
+
(0, import_react29.useEffect)(() => {
|
|
3520
3533
|
let cancelled = false;
|
|
3521
3534
|
(async () => {
|
|
3522
3535
|
try {
|
|
@@ -3543,23 +3556,23 @@ function AuthGate({
|
|
|
3543
3556
|
cancelled = true;
|
|
3544
3557
|
};
|
|
3545
3558
|
}, []);
|
|
3546
|
-
(0,
|
|
3559
|
+
(0, import_react29.useEffect)(() => {
|
|
3547
3560
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
3548
3561
|
}, [auth.status]);
|
|
3549
|
-
(0,
|
|
3562
|
+
(0, import_react29.useEffect)(() => {
|
|
3550
3563
|
if (pushEnabled && uiConfig.pushConfigured?.android && auth.status === "authenticated" && registrationPhase && !isRestoredSession) {
|
|
3551
3564
|
setShowPushSetup(true);
|
|
3552
3565
|
}
|
|
3553
3566
|
}, [pushEnabled, uiConfig.pushConfigured?.android, auth.status, registrationPhase, isRestoredSession]);
|
|
3554
|
-
(0,
|
|
3567
|
+
(0, import_react29.useEffect)(() => {
|
|
3555
3568
|
if (auth.token) onSaveToken(auth.token);
|
|
3556
3569
|
}, [auth.token]);
|
|
3557
|
-
const retry = (0,
|
|
3570
|
+
const retry = (0, import_react29.useCallback)(() => {
|
|
3558
3571
|
setRegistrationPhase(false);
|
|
3559
3572
|
auth.reset();
|
|
3560
3573
|
auth.authenticate();
|
|
3561
3574
|
}, [auth]);
|
|
3562
|
-
const handleRegister = (0,
|
|
3575
|
+
const handleRegister = (0, import_react29.useCallback)(
|
|
3563
3576
|
(username, referralCode, avatarUrl) => {
|
|
3564
3577
|
auth.register(username, referralCode, avatarUrl);
|
|
3565
3578
|
},
|
|
@@ -3652,7 +3665,7 @@ function DefaultErrorScreen({ error, onRetry, appName, accentColor }) {
|
|
|
3652
3665
|
function StepIndicator({ currentStep }) {
|
|
3653
3666
|
const t = useDubsTheme();
|
|
3654
3667
|
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)(
|
|
3668
|
+
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
3669
|
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native8.View, { style: [s.stepLine, { backgroundColor: i <= currentStep ? t.success : t.border }] }),
|
|
3657
3670
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3658
3671
|
import_react_native8.View,
|
|
@@ -3679,20 +3692,20 @@ function DefaultRegistrationScreen({
|
|
|
3679
3692
|
const t = useDubsTheme();
|
|
3680
3693
|
const accent = accentColor || t.accent;
|
|
3681
3694
|
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,
|
|
3695
|
+
const [step, setStep] = (0, import_react29.useState)(0);
|
|
3696
|
+
const [avatarSeed, setAvatarSeed] = (0, import_react29.useState)(generateSeed);
|
|
3697
|
+
const [avatarStyle, setAvatarStyle] = (0, import_react29.useState)("adventurer");
|
|
3698
|
+
const [avatarBg, setAvatarBg] = (0, import_react29.useState)("1a1a2e");
|
|
3699
|
+
const [showStyles, setShowStyles] = (0, import_react29.useState)(false);
|
|
3700
|
+
const [username, setUsername] = (0, import_react29.useState)("");
|
|
3701
|
+
const [referralCode, setReferralCode] = (0, import_react29.useState)("");
|
|
3702
|
+
const [checking, setChecking] = (0, import_react29.useState)(false);
|
|
3703
|
+
const [availability, setAvailability] = (0, import_react29.useState)(null);
|
|
3704
|
+
const debounceRef = (0, import_react29.useRef)(null);
|
|
3705
|
+
const fadeAnim = (0, import_react29.useRef)(new import_react_native8.Animated.Value(1)).current;
|
|
3706
|
+
const slideAnim = (0, import_react29.useRef)(new import_react_native8.Animated.Value(0)).current;
|
|
3694
3707
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed, avatarBg);
|
|
3695
|
-
(0,
|
|
3708
|
+
(0, import_react29.useEffect)(() => {
|
|
3696
3709
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3697
3710
|
const trimmed = username.trim();
|
|
3698
3711
|
if (trimmed.length < 3) {
|
|
@@ -3715,7 +3728,7 @@ function DefaultRegistrationScreen({
|
|
|
3715
3728
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3716
3729
|
};
|
|
3717
3730
|
}, [username, client]);
|
|
3718
|
-
const animateToStep = (0,
|
|
3731
|
+
const animateToStep = (0, import_react29.useCallback)((newStep) => {
|
|
3719
3732
|
const dir = newStep > step ? 1 : -1;
|
|
3720
3733
|
import_react_native8.Keyboard.dismiss();
|
|
3721
3734
|
import_react_native8.Animated.parallel([
|
|
@@ -3914,7 +3927,7 @@ function DefaultRegistrationScreen({
|
|
|
3914
3927
|
)
|
|
3915
3928
|
] })
|
|
3916
3929
|
] });
|
|
3917
|
-
(0,
|
|
3930
|
+
(0, import_react29.useEffect)(() => {
|
|
3918
3931
|
if (pushStepActive && step !== 3) {
|
|
3919
3932
|
animateToStep(3);
|
|
3920
3933
|
}
|
|
@@ -4008,8 +4021,8 @@ function DefaultRegistrationScreen({
|
|
|
4008
4021
|
}
|
|
4009
4022
|
function PushTokenRestorer() {
|
|
4010
4023
|
const push = usePushNotifications();
|
|
4011
|
-
const restored = (0,
|
|
4012
|
-
(0,
|
|
4024
|
+
const restored = (0, import_react29.useRef)(false);
|
|
4025
|
+
(0, import_react29.useEffect)(() => {
|
|
4013
4026
|
if (restored.current) return;
|
|
4014
4027
|
restored.current = true;
|
|
4015
4028
|
push.restoreIfGranted();
|
|
@@ -4091,7 +4104,7 @@ var s = import_react_native8.StyleSheet.create({
|
|
|
4091
4104
|
|
|
4092
4105
|
// src/provider.tsx
|
|
4093
4106
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
4094
|
-
var DubsContext = (0,
|
|
4107
|
+
var DubsContext = (0, import_react30.createContext)(null);
|
|
4095
4108
|
function DubsProvider({
|
|
4096
4109
|
apiKey,
|
|
4097
4110
|
children,
|
|
@@ -4113,11 +4126,11 @@ function DubsProvider({
|
|
|
4113
4126
|
const config = NETWORK_CONFIG[network];
|
|
4114
4127
|
const baseUrl = baseUrlOverride || config.baseUrl;
|
|
4115
4128
|
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,
|
|
4129
|
+
const client = (0, import_react30.useMemo)(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
4130
|
+
const storage = (0, import_react30.useMemo)(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
4131
|
+
const [uiConfig, setUiConfig] = (0, import_react30.useState)(null);
|
|
4132
|
+
const [resolvedNetwork, setResolvedNetwork] = (0, import_react30.useState)(network);
|
|
4133
|
+
(0, import_react30.useEffect)(() => {
|
|
4121
4134
|
client.getAppConfig().then((cfg) => {
|
|
4122
4135
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
|
|
4123
4136
|
setUiConfig(cfg);
|
|
@@ -4133,7 +4146,7 @@ function DubsProvider({
|
|
|
4133
4146
|
const resolvedConfig = NETWORK_CONFIG[resolvedNetwork];
|
|
4134
4147
|
const resolvedRpcUrl = rpcUrlOverride || resolvedConfig.rpcUrl;
|
|
4135
4148
|
const cluster = resolvedConfig.cluster;
|
|
4136
|
-
const connection = (0,
|
|
4149
|
+
const connection = (0, import_react30.useMemo)(() => new import_web34.Connection(resolvedRpcUrl, { commitment: "confirmed" }), [resolvedRpcUrl]);
|
|
4137
4150
|
if (uiConfig === null) return null;
|
|
4138
4151
|
const themeOverrides = {};
|
|
4139
4152
|
if (uiConfig.accentColor) {
|
|
@@ -4209,11 +4222,11 @@ function ManagedInner({
|
|
|
4209
4222
|
children
|
|
4210
4223
|
}) {
|
|
4211
4224
|
const managedDisconnect = useDisconnect();
|
|
4212
|
-
const disconnect = (0,
|
|
4225
|
+
const disconnect = (0, import_react30.useCallback)(async () => {
|
|
4213
4226
|
client.setToken(null);
|
|
4214
4227
|
await managedDisconnect?.();
|
|
4215
4228
|
}, [client, managedDisconnect]);
|
|
4216
|
-
const value = (0,
|
|
4229
|
+
const value = (0, import_react30.useMemo)(
|
|
4217
4230
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled }),
|
|
4218
4231
|
[client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled]
|
|
4219
4232
|
);
|
|
@@ -4250,13 +4263,13 @@ function ExternalWalletProvider({
|
|
|
4250
4263
|
pushEnabled,
|
|
4251
4264
|
children
|
|
4252
4265
|
}) {
|
|
4253
|
-
const disconnect = (0,
|
|
4266
|
+
const disconnect = (0, import_react30.useCallback)(async () => {
|
|
4254
4267
|
client.setToken(null);
|
|
4255
4268
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
4256
4269
|
});
|
|
4257
4270
|
await wallet.disconnect?.();
|
|
4258
4271
|
}, [client, storage, wallet]);
|
|
4259
|
-
const value = (0,
|
|
4272
|
+
const value = (0, import_react30.useMemo)(
|
|
4260
4273
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled }),
|
|
4261
4274
|
[client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled]
|
|
4262
4275
|
);
|
|
@@ -4281,14 +4294,14 @@ function ExternalWalletProvider({
|
|
|
4281
4294
|
) });
|
|
4282
4295
|
}
|
|
4283
4296
|
function useDubs() {
|
|
4284
|
-
const ctx = (0,
|
|
4297
|
+
const ctx = (0, import_react30.useContext)(DubsContext);
|
|
4285
4298
|
if (!ctx) {
|
|
4286
4299
|
throw new Error("useDubs must be used within a <DubsProvider>");
|
|
4287
4300
|
}
|
|
4288
4301
|
return ctx;
|
|
4289
4302
|
}
|
|
4290
4303
|
function useAppConfig() {
|
|
4291
|
-
const ctx = (0,
|
|
4304
|
+
const ctx = (0, import_react30.useContext)(DubsContext);
|
|
4292
4305
|
return ctx?.uiConfig || {};
|
|
4293
4306
|
}
|
|
4294
4307
|
|
|
@@ -4346,7 +4359,7 @@ var styles3 = import_react_native9.StyleSheet.create({
|
|
|
4346
4359
|
});
|
|
4347
4360
|
|
|
4348
4361
|
// src/ui/UserProfileCard.tsx
|
|
4349
|
-
var
|
|
4362
|
+
var import_react31 = require("react");
|
|
4350
4363
|
var import_react_native10 = require("react-native");
|
|
4351
4364
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
4352
4365
|
function truncateAddress(address, chars = 4) {
|
|
@@ -4366,7 +4379,7 @@ function UserProfileCard({
|
|
|
4366
4379
|
memberSince
|
|
4367
4380
|
}) {
|
|
4368
4381
|
const t = useDubsTheme();
|
|
4369
|
-
const imageUri = (0,
|
|
4382
|
+
const imageUri = (0, import_react31.useMemo)(
|
|
4370
4383
|
() => ensurePngAvatar(avatarUrl) || `https://api.dicebear.com/9.x/avataaars/png?seed=${walletAddress}&size=128`,
|
|
4371
4384
|
[avatarUrl, walletAddress]
|
|
4372
4385
|
);
|
|
@@ -4559,7 +4572,7 @@ var styles5 = import_react_native11.StyleSheet.create({
|
|
|
4559
4572
|
});
|
|
4560
4573
|
|
|
4561
4574
|
// src/ui/UserProfileSheet.tsx
|
|
4562
|
-
var
|
|
4575
|
+
var import_react32 = require("react");
|
|
4563
4576
|
var import_react_native12 = require("react-native");
|
|
4564
4577
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
4565
4578
|
function truncateAddress3(address, chars = 4) {
|
|
@@ -4577,31 +4590,31 @@ function UserProfileSheet({
|
|
|
4577
4590
|
const { client } = useDubs();
|
|
4578
4591
|
const { refreshUser } = useAuth();
|
|
4579
4592
|
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,
|
|
4593
|
+
const overlayOpacity = (0, import_react32.useRef)(new import_react_native12.Animated.Value(0)).current;
|
|
4594
|
+
const parsed = (0, import_react32.useMemo)(() => parseAvatarUrl(user.avatar), [user.avatar]);
|
|
4595
|
+
const [avatarStyle, setAvatarStyle] = (0, import_react32.useState)(parsed.style);
|
|
4596
|
+
const [avatarSeed, setAvatarSeed] = (0, import_react32.useState)(parsed.seed);
|
|
4597
|
+
const [bgColor, setBgColor] = (0, import_react32.useState)(parsed.bg);
|
|
4598
|
+
const [saving, setSaving] = (0, import_react32.useState)(false);
|
|
4599
|
+
const [error, setError] = (0, import_react32.useState)(null);
|
|
4600
|
+
(0, import_react32.useEffect)(() => {
|
|
4588
4601
|
const p = parseAvatarUrl(user.avatar);
|
|
4589
4602
|
setAvatarStyle(p.style);
|
|
4590
4603
|
setAvatarSeed(p.seed);
|
|
4591
4604
|
setBgColor(p.bg);
|
|
4592
4605
|
}, [user.avatar]);
|
|
4593
|
-
(0,
|
|
4606
|
+
(0, import_react32.useEffect)(() => {
|
|
4594
4607
|
import_react_native12.Animated.timing(overlayOpacity, {
|
|
4595
4608
|
toValue: visible ? 1 : 0,
|
|
4596
4609
|
duration: 250,
|
|
4597
4610
|
useNativeDriver: true
|
|
4598
4611
|
}).start();
|
|
4599
4612
|
}, [visible, overlayOpacity]);
|
|
4600
|
-
(0,
|
|
4613
|
+
(0, import_react32.useEffect)(() => {
|
|
4601
4614
|
if (visible) setError(null);
|
|
4602
4615
|
}, [visible]);
|
|
4603
4616
|
const currentAvatarUrl = getAvatarUrl(avatarStyle, avatarSeed, bgColor);
|
|
4604
|
-
const saveAvatar = (0,
|
|
4617
|
+
const saveAvatar = (0, import_react32.useCallback)(async (newUrl) => {
|
|
4605
4618
|
setSaving(true);
|
|
4606
4619
|
setError(null);
|
|
4607
4620
|
try {
|
|
@@ -4614,16 +4627,16 @@ function UserProfileSheet({
|
|
|
4614
4627
|
setSaving(false);
|
|
4615
4628
|
}
|
|
4616
4629
|
}, [client, refreshUser, onAvatarUpdated]);
|
|
4617
|
-
const handleStyleChange = (0,
|
|
4630
|
+
const handleStyleChange = (0, import_react32.useCallback)((style) => {
|
|
4618
4631
|
setAvatarStyle(style);
|
|
4619
4632
|
saveAvatar(getAvatarUrl(style, avatarSeed, bgColor));
|
|
4620
4633
|
}, [avatarSeed, bgColor, saveAvatar]);
|
|
4621
|
-
const handleShuffle = (0,
|
|
4634
|
+
const handleShuffle = (0, import_react32.useCallback)(() => {
|
|
4622
4635
|
const newSeed = generateSeed();
|
|
4623
4636
|
setAvatarSeed(newSeed);
|
|
4624
4637
|
saveAvatar(getAvatarUrl(avatarStyle, newSeed, bgColor));
|
|
4625
4638
|
}, [avatarStyle, bgColor, saveAvatar]);
|
|
4626
|
-
const handleBgChange = (0,
|
|
4639
|
+
const handleBgChange = (0, import_react32.useCallback)((color) => {
|
|
4627
4640
|
setBgColor(color);
|
|
4628
4641
|
saveAvatar(getAvatarUrl(avatarStyle, avatarSeed, color));
|
|
4629
4642
|
}, [avatarStyle, avatarSeed, saveAvatar]);
|
|
@@ -4903,7 +4916,7 @@ var styles6 = import_react_native12.StyleSheet.create({
|
|
|
4903
4916
|
});
|
|
4904
4917
|
|
|
4905
4918
|
// src/ui/game/GamePoster.tsx
|
|
4906
|
-
var
|
|
4919
|
+
var import_react33 = require("react");
|
|
4907
4920
|
var import_react_native13 = require("react-native");
|
|
4908
4921
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4909
4922
|
function computeCountdown(lockTimestamp) {
|
|
@@ -4953,7 +4966,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
4953
4966
|
] });
|
|
4954
4967
|
}
|
|
4955
4968
|
function TeamLogoInternal({ url, size, Img }) {
|
|
4956
|
-
const [failed, setFailed] = (0,
|
|
4969
|
+
const [failed, setFailed] = (0, import_react33.useState)(false);
|
|
4957
4970
|
if (!url || failed) {
|
|
4958
4971
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native13.View, { style: [styles7.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
4959
4972
|
}
|
|
@@ -5054,7 +5067,7 @@ var styles7 = import_react_native13.StyleSheet.create({
|
|
|
5054
5067
|
});
|
|
5055
5068
|
|
|
5056
5069
|
// src/ui/game/LivePoolsCard.tsx
|
|
5057
|
-
var
|
|
5070
|
+
var import_react34 = require("react");
|
|
5058
5071
|
var import_react_native14 = require("react-native");
|
|
5059
5072
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
5060
5073
|
function LivePoolsCard({
|
|
@@ -5070,7 +5083,7 @@ function LivePoolsCard({
|
|
|
5070
5083
|
const homePool = game.homePool || 0;
|
|
5071
5084
|
const awayPool = game.awayPool || 0;
|
|
5072
5085
|
const totalPool = game.totalPool || 0;
|
|
5073
|
-
const { homePercent, awayPercent, homeOdds, awayOdds } = (0,
|
|
5086
|
+
const { homePercent, awayPercent, homeOdds, awayOdds } = (0, import_react34.useMemo)(() => {
|
|
5074
5087
|
return {
|
|
5075
5088
|
homePercent: totalPool > 0 ? homePool / totalPool * 100 : 50,
|
|
5076
5089
|
awayPercent: totalPool > 0 ? awayPool / totalPool * 100 : 50,
|
|
@@ -5133,7 +5146,7 @@ var styles8 = import_react_native14.StyleSheet.create({
|
|
|
5133
5146
|
});
|
|
5134
5147
|
|
|
5135
5148
|
// src/ui/game/PickWinnerCard.tsx
|
|
5136
|
-
var
|
|
5149
|
+
var import_react35 = require("react");
|
|
5137
5150
|
var import_react_native15 = require("react-native");
|
|
5138
5151
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
5139
5152
|
function PickWinnerCard({
|
|
@@ -5151,7 +5164,7 @@ function PickWinnerCard({
|
|
|
5151
5164
|
const totalPool = game.totalPool || 0;
|
|
5152
5165
|
const homePool = game.homePool || 0;
|
|
5153
5166
|
const awayPool = game.awayPool || 0;
|
|
5154
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = (0,
|
|
5167
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = (0, import_react35.useMemo)(() => ({
|
|
5155
5168
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
5156
5169
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
5157
5170
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -5204,7 +5217,7 @@ function TeamOption({
|
|
|
5204
5217
|
ImageComponent,
|
|
5205
5218
|
t
|
|
5206
5219
|
}) {
|
|
5207
|
-
const [imgFailed, setImgFailed] = (0,
|
|
5220
|
+
const [imgFailed, setImgFailed] = (0, import_react35.useState)(false);
|
|
5208
5221
|
const Img = ImageComponent || require("react-native").Image;
|
|
5209
5222
|
const showImage = imageUrl && !imgFailed;
|
|
5210
5223
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -5245,7 +5258,7 @@ var styles9 = import_react_native15.StyleSheet.create({
|
|
|
5245
5258
|
});
|
|
5246
5259
|
|
|
5247
5260
|
// src/ui/game/PlayersCard.tsx
|
|
5248
|
-
var
|
|
5261
|
+
var import_react36 = require("react");
|
|
5249
5262
|
var import_react_native16 = require("react-native");
|
|
5250
5263
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
5251
5264
|
function truncateWallet(addr, chars) {
|
|
@@ -5294,7 +5307,7 @@ function BettorRow({
|
|
|
5294
5307
|
ImageComponent,
|
|
5295
5308
|
t
|
|
5296
5309
|
}) {
|
|
5297
|
-
const [imgFailed, setImgFailed] = (0,
|
|
5310
|
+
const [imgFailed, setImgFailed] = (0, import_react36.useState)(false);
|
|
5298
5311
|
const Img = ImageComponent || require("react-native").Image;
|
|
5299
5312
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
5300
5313
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native16.View, { style: [styles10.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -5321,7 +5334,7 @@ var styles10 = import_react_native16.StyleSheet.create({
|
|
|
5321
5334
|
});
|
|
5322
5335
|
|
|
5323
5336
|
// src/ui/game/JoinGameButton.tsx
|
|
5324
|
-
var
|
|
5337
|
+
var import_react37 = require("react");
|
|
5325
5338
|
var import_react_native17 = require("react-native");
|
|
5326
5339
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
5327
5340
|
var STATUS_LABELS = {
|
|
@@ -5332,7 +5345,7 @@ var STATUS_LABELS = {
|
|
|
5332
5345
|
};
|
|
5333
5346
|
function JoinGameButton({ game, walletAddress, selectedTeam, status, onJoin }) {
|
|
5334
5347
|
const t = useDubsTheme();
|
|
5335
|
-
const alreadyJoined = (0,
|
|
5348
|
+
const alreadyJoined = (0, import_react37.useMemo)(() => {
|
|
5336
5349
|
if (!walletAddress) return false;
|
|
5337
5350
|
return (game.bettors || []).some((b) => b.wallet === walletAddress);
|
|
5338
5351
|
}, [game.bettors, walletAddress]);
|
|
@@ -5373,7 +5386,7 @@ var styles11 = import_react_native17.StyleSheet.create({
|
|
|
5373
5386
|
});
|
|
5374
5387
|
|
|
5375
5388
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
5376
|
-
var
|
|
5389
|
+
var import_react38 = require("react");
|
|
5377
5390
|
var import_react_native18 = require("react-native");
|
|
5378
5391
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
5379
5392
|
var STATUS_LABELS2 = {
|
|
@@ -5399,18 +5412,18 @@ function CreateCustomGameSheet({
|
|
|
5399
5412
|
const t = useDubsTheme();
|
|
5400
5413
|
const { wallet } = useDubs();
|
|
5401
5414
|
const mutation = useCreateCustomGame();
|
|
5402
|
-
const [selectedAmount, setSelectedAmount] = (0,
|
|
5403
|
-
const [customAmount, setCustomAmount] = (0,
|
|
5404
|
-
const [isCustom, setIsCustom] = (0,
|
|
5405
|
-
const overlayOpacity = (0,
|
|
5406
|
-
(0,
|
|
5415
|
+
const [selectedAmount, setSelectedAmount] = (0, import_react38.useState)(null);
|
|
5416
|
+
const [customAmount, setCustomAmount] = (0, import_react38.useState)("");
|
|
5417
|
+
const [isCustom, setIsCustom] = (0, import_react38.useState)(false);
|
|
5418
|
+
const overlayOpacity = (0, import_react38.useRef)(new import_react_native18.Animated.Value(0)).current;
|
|
5419
|
+
(0, import_react38.useEffect)(() => {
|
|
5407
5420
|
import_react_native18.Animated.timing(overlayOpacity, {
|
|
5408
5421
|
toValue: visible ? 1 : 0,
|
|
5409
5422
|
duration: 250,
|
|
5410
5423
|
useNativeDriver: true
|
|
5411
5424
|
}).start();
|
|
5412
5425
|
}, [visible, overlayOpacity]);
|
|
5413
|
-
(0,
|
|
5426
|
+
(0, import_react38.useEffect)(() => {
|
|
5414
5427
|
if (visible) {
|
|
5415
5428
|
setSelectedAmount(defaultAmount ?? null);
|
|
5416
5429
|
setCustomAmount("");
|
|
@@ -5418,7 +5431,7 @@ function CreateCustomGameSheet({
|
|
|
5418
5431
|
mutation.reset();
|
|
5419
5432
|
}
|
|
5420
5433
|
}, [visible]);
|
|
5421
|
-
(0,
|
|
5434
|
+
(0, import_react38.useEffect)(() => {
|
|
5422
5435
|
if (mutation.status === "success" && mutation.data) {
|
|
5423
5436
|
onSuccess?.(mutation.data);
|
|
5424
5437
|
const timer = setTimeout(() => {
|
|
@@ -5427,23 +5440,23 @@ function CreateCustomGameSheet({
|
|
|
5427
5440
|
return () => clearTimeout(timer);
|
|
5428
5441
|
}
|
|
5429
5442
|
}, [mutation.status, mutation.data]);
|
|
5430
|
-
(0,
|
|
5443
|
+
(0, import_react38.useEffect)(() => {
|
|
5431
5444
|
if (mutation.status === "error" && mutation.error) {
|
|
5432
5445
|
onError?.(mutation.error);
|
|
5433
5446
|
}
|
|
5434
5447
|
}, [mutation.status, mutation.error]);
|
|
5435
|
-
const handlePresetSelect = (0,
|
|
5448
|
+
const handlePresetSelect = (0, import_react38.useCallback)((amount) => {
|
|
5436
5449
|
setSelectedAmount(amount);
|
|
5437
5450
|
setIsCustom(false);
|
|
5438
5451
|
setCustomAmount("");
|
|
5439
5452
|
onAmountChange?.(amount);
|
|
5440
5453
|
}, [onAmountChange]);
|
|
5441
|
-
const handleCustomSelect = (0,
|
|
5454
|
+
const handleCustomSelect = (0, import_react38.useCallback)(() => {
|
|
5442
5455
|
setIsCustom(true);
|
|
5443
5456
|
setSelectedAmount(null);
|
|
5444
5457
|
onAmountChange?.(null);
|
|
5445
5458
|
}, [onAmountChange]);
|
|
5446
|
-
const handleCustomAmountChange = (0,
|
|
5459
|
+
const handleCustomAmountChange = (0, import_react38.useCallback)((text) => {
|
|
5447
5460
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
5448
5461
|
setCustomAmount(cleaned);
|
|
5449
5462
|
const parsed = parseFloat(cleaned);
|
|
@@ -5458,7 +5471,7 @@ function CreateCustomGameSheet({
|
|
|
5458
5471
|
const winnerTakes = pot * (1 - fee / 100);
|
|
5459
5472
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5460
5473
|
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
5461
|
-
const handleCreate = (0,
|
|
5474
|
+
const handleCreate = (0, import_react38.useCallback)(async () => {
|
|
5462
5475
|
if (!finalAmount || !wallet.publicKey) return;
|
|
5463
5476
|
try {
|
|
5464
5477
|
await mutation.execute({
|
|
@@ -5727,11 +5740,11 @@ var styles12 = import_react_native18.StyleSheet.create({
|
|
|
5727
5740
|
});
|
|
5728
5741
|
|
|
5729
5742
|
// src/ui/game/JoinGameSheet.tsx
|
|
5730
|
-
var
|
|
5743
|
+
var import_react41 = require("react");
|
|
5731
5744
|
var import_react_native21 = require("react-native");
|
|
5732
5745
|
|
|
5733
5746
|
// src/ui/game/SolSlider.tsx
|
|
5734
|
-
var
|
|
5747
|
+
var import_react39 = require("react");
|
|
5735
5748
|
var import_react_native19 = require("react-native");
|
|
5736
5749
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
5737
5750
|
var THUMB_SIZE = 32;
|
|
@@ -5750,9 +5763,9 @@ function SolSlider({
|
|
|
5750
5763
|
}) {
|
|
5751
5764
|
const t = useDubsTheme();
|
|
5752
5765
|
const accent = accentColor || t.accent;
|
|
5753
|
-
const trackRef = (0,
|
|
5754
|
-
const trackWidth = (0,
|
|
5755
|
-
const lastTickValue = (0,
|
|
5766
|
+
const trackRef = (0, import_react39.useRef)(null);
|
|
5767
|
+
const trackWidth = (0, import_react39.useRef)(0);
|
|
5768
|
+
const lastTickValue = (0, import_react39.useRef)(value);
|
|
5756
5769
|
const clamp = (v) => {
|
|
5757
5770
|
const stepped = Math.round(v / step) * step;
|
|
5758
5771
|
return Math.max(min, Math.min(max, parseFloat(stepped.toFixed(4))));
|
|
@@ -5765,7 +5778,7 @@ function SolSlider({
|
|
|
5765
5778
|
const ratio2 = Math.max(0, Math.min(1, x / trackWidth.current));
|
|
5766
5779
|
return clamp(min + ratio2 * (max - min));
|
|
5767
5780
|
};
|
|
5768
|
-
const panResponder = (0,
|
|
5781
|
+
const panResponder = (0, import_react39.useRef)(
|
|
5769
5782
|
import_react_native19.PanResponder.create({
|
|
5770
5783
|
onStartShouldSetPanResponder: () => !disabled,
|
|
5771
5784
|
onMoveShouldSetPanResponder: () => !disabled,
|
|
@@ -5920,7 +5933,7 @@ var styles13 = import_react_native19.StyleSheet.create({
|
|
|
5920
5933
|
});
|
|
5921
5934
|
|
|
5922
5935
|
// src/ui/game/TeamButton.tsx
|
|
5923
|
-
var
|
|
5936
|
+
var import_react40 = require("react");
|
|
5924
5937
|
var import_react_native20 = require("react-native");
|
|
5925
5938
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
5926
5939
|
function TeamButton({
|
|
@@ -5934,7 +5947,7 @@ function TeamButton({
|
|
|
5934
5947
|
ImageComponent,
|
|
5935
5948
|
t
|
|
5936
5949
|
}) {
|
|
5937
|
-
const [imgFailed, setImgFailed] = (0,
|
|
5950
|
+
const [imgFailed, setImgFailed] = (0, import_react40.useState)(false);
|
|
5938
5951
|
const Img = ImageComponent || require("react-native").Image;
|
|
5939
5952
|
const showImage = imageUrl && !imgFailed;
|
|
5940
5953
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
@@ -6038,20 +6051,20 @@ function JoinGameSheet({
|
|
|
6038
6051
|
const { wallet } = useDubs();
|
|
6039
6052
|
const mutation = useJoinGame();
|
|
6040
6053
|
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,
|
|
6054
|
+
const [selectedTeam, setSelectedTeam] = (0, import_react41.useState)(null);
|
|
6055
|
+
const [wager, setWager] = (0, import_react41.useState)(game.buyIn);
|
|
6056
|
+
const [showSuccess, setShowSuccess] = (0, import_react41.useState)(false);
|
|
6057
|
+
const overlayOpacity = (0, import_react41.useRef)(new import_react_native21.Animated.Value(0)).current;
|
|
6058
|
+
const successScale = (0, import_react41.useRef)(new import_react_native21.Animated.Value(0)).current;
|
|
6059
|
+
const successOpacity = (0, import_react41.useRef)(new import_react_native21.Animated.Value(0)).current;
|
|
6060
|
+
(0, import_react41.useEffect)(() => {
|
|
6048
6061
|
import_react_native21.Animated.timing(overlayOpacity, {
|
|
6049
6062
|
toValue: visible ? 1 : 0,
|
|
6050
6063
|
duration: 250,
|
|
6051
6064
|
useNativeDriver: true
|
|
6052
6065
|
}).start();
|
|
6053
6066
|
}, [visible, overlayOpacity]);
|
|
6054
|
-
(0,
|
|
6067
|
+
(0, import_react41.useEffect)(() => {
|
|
6055
6068
|
if (visible) {
|
|
6056
6069
|
setSelectedTeam(isPoolModeEnabled ? "home" : isCustomGame ? "away" : null);
|
|
6057
6070
|
setWager(game.buyIn);
|
|
@@ -6061,7 +6074,7 @@ function JoinGameSheet({
|
|
|
6061
6074
|
mutation.reset();
|
|
6062
6075
|
}
|
|
6063
6076
|
}, [visible]);
|
|
6064
|
-
(0,
|
|
6077
|
+
(0, import_react41.useEffect)(() => {
|
|
6065
6078
|
if (mutation.status === "success" && mutation.data) {
|
|
6066
6079
|
setShowSuccess(true);
|
|
6067
6080
|
onSuccess?.(mutation.data);
|
|
@@ -6078,7 +6091,7 @@ function JoinGameSheet({
|
|
|
6078
6091
|
return () => clearTimeout(timer);
|
|
6079
6092
|
}
|
|
6080
6093
|
}, [mutation.status, mutation.data]);
|
|
6081
|
-
(0,
|
|
6094
|
+
(0, import_react41.useEffect)(() => {
|
|
6082
6095
|
if (mutation.status === "error" && mutation.error) {
|
|
6083
6096
|
onError?.(mutation.error);
|
|
6084
6097
|
}
|
|
@@ -6093,7 +6106,7 @@ function JoinGameSheet({
|
|
|
6093
6106
|
const drawBettors = bettors.filter((b) => b.team === "draw");
|
|
6094
6107
|
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
6108
|
const poolAfterJoin = totalPool + wager;
|
|
6096
|
-
const { homeOdds, awayOdds, drawOdds, homeBets, awayBets, drawBets } = (0,
|
|
6109
|
+
const { homeOdds, awayOdds, drawOdds, homeBets, awayBets, drawBets } = (0, import_react41.useMemo)(() => {
|
|
6097
6110
|
const homeBetsCount = bettors.filter((b) => b.team === "home").length;
|
|
6098
6111
|
const awayBetsCount = bettors.filter((b) => b.team === "away").length;
|
|
6099
6112
|
const drawBetsCount = bettors.filter((b) => b.team === "draw").length;
|
|
@@ -6114,7 +6127,7 @@ function JoinGameSheet({
|
|
|
6114
6127
|
const potentialWinnings = selectedOdds !== "\u2014" ? formatSol(parseFloat(selectedOdds) * wager) : "\u2014";
|
|
6115
6128
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
6116
6129
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
6117
|
-
const myBet = (0,
|
|
6130
|
+
const myBet = (0, import_react41.useMemo)(() => {
|
|
6118
6131
|
if (!wallet.publicKey) return null;
|
|
6119
6132
|
const addr = wallet.publicKey.toBase58();
|
|
6120
6133
|
return bettors.find((b) => b.wallet === addr) ?? null;
|
|
@@ -6122,7 +6135,7 @@ function JoinGameSheet({
|
|
|
6122
6135
|
const alreadyJoined = myBet !== null;
|
|
6123
6136
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6124
6137
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
6125
|
-
const handleJoin = (0,
|
|
6138
|
+
const handleJoin = (0, import_react41.useCallback)(async () => {
|
|
6126
6139
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
6127
6140
|
try {
|
|
6128
6141
|
await mutation.execute({
|
|
@@ -6385,7 +6398,7 @@ function PickRow({
|
|
|
6385
6398
|
ImageComponent,
|
|
6386
6399
|
t
|
|
6387
6400
|
}) {
|
|
6388
|
-
const [imgFailed, setImgFailed] = (0,
|
|
6401
|
+
const [imgFailed, setImgFailed] = (0, import_react41.useState)(false);
|
|
6389
6402
|
const Img = ImageComponent || require("react-native").Image;
|
|
6390
6403
|
const showImage = imageUrl && !imgFailed;
|
|
6391
6404
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
@@ -6678,7 +6691,7 @@ var styles15 = import_react_native21.StyleSheet.create({
|
|
|
6678
6691
|
});
|
|
6679
6692
|
|
|
6680
6693
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
6681
|
-
var
|
|
6694
|
+
var import_react42 = require("react");
|
|
6682
6695
|
var import_react_native22 = require("react-native");
|
|
6683
6696
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
6684
6697
|
var STATUS_LABELS4 = {
|
|
@@ -6699,18 +6712,18 @@ function ClaimPrizeSheet({
|
|
|
6699
6712
|
const t = useDubsTheme();
|
|
6700
6713
|
const { wallet } = useDubs();
|
|
6701
6714
|
const mutation = useClaim();
|
|
6702
|
-
const overlayOpacity = (0,
|
|
6703
|
-
const celebrationScale = (0,
|
|
6704
|
-
const celebrationOpacity = (0,
|
|
6705
|
-
const [showCelebration, setShowCelebration] = (0,
|
|
6706
|
-
(0,
|
|
6715
|
+
const overlayOpacity = (0, import_react42.useRef)(new import_react_native22.Animated.Value(0)).current;
|
|
6716
|
+
const celebrationScale = (0, import_react42.useRef)(new import_react_native22.Animated.Value(0)).current;
|
|
6717
|
+
const celebrationOpacity = (0, import_react42.useRef)(new import_react_native22.Animated.Value(0)).current;
|
|
6718
|
+
const [showCelebration, setShowCelebration] = (0, import_react42.useState)(false);
|
|
6719
|
+
(0, import_react42.useEffect)(() => {
|
|
6707
6720
|
import_react_native22.Animated.timing(overlayOpacity, {
|
|
6708
6721
|
toValue: visible ? 1 : 0,
|
|
6709
6722
|
duration: 250,
|
|
6710
6723
|
useNativeDriver: true
|
|
6711
6724
|
}).start();
|
|
6712
6725
|
}, [visible, overlayOpacity]);
|
|
6713
|
-
(0,
|
|
6726
|
+
(0, import_react42.useEffect)(() => {
|
|
6714
6727
|
if (visible) {
|
|
6715
6728
|
mutation.reset();
|
|
6716
6729
|
setShowCelebration(false);
|
|
@@ -6718,7 +6731,7 @@ function ClaimPrizeSheet({
|
|
|
6718
6731
|
celebrationOpacity.setValue(0);
|
|
6719
6732
|
}
|
|
6720
6733
|
}, [visible]);
|
|
6721
|
-
(0,
|
|
6734
|
+
(0, import_react42.useEffect)(() => {
|
|
6722
6735
|
if (mutation.status === "success" && mutation.data) {
|
|
6723
6736
|
setShowCelebration(true);
|
|
6724
6737
|
import_react_native22.Animated.parallel([
|
|
@@ -6741,14 +6754,14 @@ function ClaimPrizeSheet({
|
|
|
6741
6754
|
return () => clearTimeout(timer);
|
|
6742
6755
|
}
|
|
6743
6756
|
}, [mutation.status, mutation.data]);
|
|
6744
|
-
(0,
|
|
6757
|
+
(0, import_react42.useEffect)(() => {
|
|
6745
6758
|
if (mutation.status === "error" && mutation.error) {
|
|
6746
6759
|
onError?.(mutation.error);
|
|
6747
6760
|
}
|
|
6748
6761
|
}, [mutation.status, mutation.error]);
|
|
6749
6762
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6750
6763
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
6751
|
-
const handleClaim = (0,
|
|
6764
|
+
const handleClaim = (0, import_react42.useCallback)(async () => {
|
|
6752
6765
|
if (!wallet.publicKey) return;
|
|
6753
6766
|
try {
|
|
6754
6767
|
await mutation.execute({
|
|
@@ -6981,7 +6994,7 @@ var styles16 = import_react_native22.StyleSheet.create({
|
|
|
6981
6994
|
});
|
|
6982
6995
|
|
|
6983
6996
|
// src/ui/game/ClaimButton.tsx
|
|
6984
|
-
var
|
|
6997
|
+
var import_react43 = require("react");
|
|
6985
6998
|
var import_react_native23 = require("react-native");
|
|
6986
6999
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
6987
7000
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -6989,9 +7002,9 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6989
7002
|
const { wallet } = useDubs();
|
|
6990
7003
|
const game = useGame(gameId);
|
|
6991
7004
|
const claimStatus = useHasClaimed(gameId);
|
|
6992
|
-
const [sheetVisible, setSheetVisible] = (0,
|
|
7005
|
+
const [sheetVisible, setSheetVisible] = (0, import_react43.useState)(false);
|
|
6993
7006
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
6994
|
-
const myBet = (0,
|
|
7007
|
+
const myBet = (0, import_react43.useMemo)(() => {
|
|
6995
7008
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
6996
7009
|
return game.data.bettors.find((b) => b.wallet === walletAddress) ?? null;
|
|
6997
7010
|
}, [walletAddress, game.data?.bettors]);
|
|
@@ -7000,7 +7013,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
7000
7013
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
7001
7014
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
7002
7015
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
7003
|
-
const handleSuccess = (0,
|
|
7016
|
+
const handleSuccess = (0, import_react43.useCallback)(
|
|
7004
7017
|
(result) => {
|
|
7005
7018
|
claimStatus.refetch();
|
|
7006
7019
|
onSuccess?.(result);
|
|
@@ -7087,7 +7100,7 @@ var styles17 = import_react_native23.StyleSheet.create({
|
|
|
7087
7100
|
});
|
|
7088
7101
|
|
|
7089
7102
|
// src/ui/game/EnterArcadePoolSheet.tsx
|
|
7090
|
-
var
|
|
7103
|
+
var import_react44 = require("react");
|
|
7091
7104
|
var import_react_native24 = require("react-native");
|
|
7092
7105
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
7093
7106
|
var STATUS_LABELS5 = {
|
|
@@ -7108,20 +7121,20 @@ function EnterArcadePoolSheet({
|
|
|
7108
7121
|
const t = useDubsTheme();
|
|
7109
7122
|
const { wallet } = useDubs();
|
|
7110
7123
|
const mutation = useEnterArcadePool();
|
|
7111
|
-
const overlayOpacity = (0,
|
|
7112
|
-
(0,
|
|
7124
|
+
const overlayOpacity = (0, import_react44.useRef)(new import_react_native24.Animated.Value(0)).current;
|
|
7125
|
+
(0, import_react44.useEffect)(() => {
|
|
7113
7126
|
import_react_native24.Animated.timing(overlayOpacity, {
|
|
7114
7127
|
toValue: visible ? 1 : 0,
|
|
7115
7128
|
duration: 250,
|
|
7116
7129
|
useNativeDriver: true
|
|
7117
7130
|
}).start();
|
|
7118
7131
|
}, [visible, overlayOpacity]);
|
|
7119
|
-
(0,
|
|
7132
|
+
(0, import_react44.useEffect)(() => {
|
|
7120
7133
|
if (visible) {
|
|
7121
7134
|
mutation.reset();
|
|
7122
7135
|
}
|
|
7123
7136
|
}, [visible]);
|
|
7124
|
-
(0,
|
|
7137
|
+
(0, import_react44.useEffect)(() => {
|
|
7125
7138
|
if (mutation.status === "success" && mutation.data) {
|
|
7126
7139
|
onSuccess?.(mutation.data);
|
|
7127
7140
|
const timer = setTimeout(() => {
|
|
@@ -7130,7 +7143,7 @@ function EnterArcadePoolSheet({
|
|
|
7130
7143
|
return () => clearTimeout(timer);
|
|
7131
7144
|
}
|
|
7132
7145
|
}, [mutation.status, mutation.data]);
|
|
7133
|
-
(0,
|
|
7146
|
+
(0, import_react44.useEffect)(() => {
|
|
7134
7147
|
if (mutation.status === "error" && mutation.error) {
|
|
7135
7148
|
onError?.(mutation.error);
|
|
7136
7149
|
}
|
|
@@ -7142,7 +7155,7 @@ function EnterArcadePoolSheet({
|
|
|
7142
7155
|
const potSol = (pool.buy_in_lamports * Number(totalBuyIns) / 1e9).toFixed(4);
|
|
7143
7156
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
7144
7157
|
const canJoin = !isMutating && mutation.status !== "success";
|
|
7145
|
-
const handleJoin = (0,
|
|
7158
|
+
const handleJoin = (0, import_react44.useCallback)(async () => {
|
|
7146
7159
|
if (!wallet.publicKey) return;
|
|
7147
7160
|
try {
|
|
7148
7161
|
await mutation.execute(pool.id);
|
|
@@ -7293,7 +7306,7 @@ var styles18 = import_react_native24.StyleSheet.create({
|
|
|
7293
7306
|
});
|
|
7294
7307
|
|
|
7295
7308
|
// src/ui/game/ArcadeLeaderboardSheet.tsx
|
|
7296
|
-
var
|
|
7309
|
+
var import_react45 = require("react");
|
|
7297
7310
|
var import_react_native25 = require("react-native");
|
|
7298
7311
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
7299
7312
|
function RankLabel({ index }) {
|
|
@@ -7310,15 +7323,15 @@ function ArcadeLeaderboardSheet({
|
|
|
7310
7323
|
}) {
|
|
7311
7324
|
const t = useDubsTheme();
|
|
7312
7325
|
const { pool, leaderboard, stats, loading, refetch } = useArcadePool(poolId);
|
|
7313
|
-
const overlayOpacity = (0,
|
|
7314
|
-
(0,
|
|
7326
|
+
const overlayOpacity = (0, import_react45.useRef)(new import_react_native25.Animated.Value(0)).current;
|
|
7327
|
+
(0, import_react45.useEffect)(() => {
|
|
7315
7328
|
import_react_native25.Animated.timing(overlayOpacity, {
|
|
7316
7329
|
toValue: visible ? 1 : 0,
|
|
7317
7330
|
duration: 250,
|
|
7318
7331
|
useNativeDriver: true
|
|
7319
7332
|
}).start();
|
|
7320
7333
|
}, [visible, overlayOpacity]);
|
|
7321
|
-
(0,
|
|
7334
|
+
(0, import_react45.useEffect)(() => {
|
|
7322
7335
|
if (visible) refetch();
|
|
7323
7336
|
}, [visible]);
|
|
7324
7337
|
const renderItem = ({ item, index }) => {
|
|
@@ -7465,7 +7478,7 @@ var styles19 = import_react_native25.StyleSheet.create({
|
|
|
7465
7478
|
});
|
|
7466
7479
|
|
|
7467
7480
|
// src/ui/game/CreateGameSheet.tsx
|
|
7468
|
-
var
|
|
7481
|
+
var import_react46 = require("react");
|
|
7469
7482
|
var import_react_native26 = require("react-native");
|
|
7470
7483
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
7471
7484
|
var STATUS_LABELS6 = {
|
|
@@ -7494,20 +7507,20 @@ function CreateGameSheet({
|
|
|
7494
7507
|
const t = useDubsTheme();
|
|
7495
7508
|
const { wallet } = useDubs();
|
|
7496
7509
|
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,
|
|
7510
|
+
const [selectedTeam, setSelectedTeam] = (0, import_react46.useState)(null);
|
|
7511
|
+
const [wager, setWager] = (0, import_react46.useState)(0.01);
|
|
7512
|
+
const [showSuccess, setShowSuccess] = (0, import_react46.useState)(false);
|
|
7513
|
+
const overlayOpacity = (0, import_react46.useRef)(new import_react_native26.Animated.Value(0)).current;
|
|
7514
|
+
const successScale = (0, import_react46.useRef)(new import_react_native26.Animated.Value(0)).current;
|
|
7515
|
+
const successOpacity = (0, import_react46.useRef)(new import_react_native26.Animated.Value(0)).current;
|
|
7516
|
+
(0, import_react46.useEffect)(() => {
|
|
7504
7517
|
import_react_native26.Animated.timing(overlayOpacity, {
|
|
7505
7518
|
toValue: visible ? 1 : 0,
|
|
7506
7519
|
duration: 250,
|
|
7507
7520
|
useNativeDriver: true
|
|
7508
7521
|
}).start();
|
|
7509
7522
|
}, [visible]);
|
|
7510
|
-
(0,
|
|
7523
|
+
(0, import_react46.useEffect)(() => {
|
|
7511
7524
|
if (visible) {
|
|
7512
7525
|
setSelectedTeam(null);
|
|
7513
7526
|
setWager(0.01);
|
|
@@ -7517,7 +7530,7 @@ function CreateGameSheet({
|
|
|
7517
7530
|
mutation.reset();
|
|
7518
7531
|
}
|
|
7519
7532
|
}, [visible]);
|
|
7520
|
-
(0,
|
|
7533
|
+
(0, import_react46.useEffect)(() => {
|
|
7521
7534
|
if (mutation.status === "success" && mutation.data) {
|
|
7522
7535
|
setShowSuccess(true);
|
|
7523
7536
|
onSuccess?.(mutation.data);
|
|
@@ -7534,7 +7547,7 @@ function CreateGameSheet({
|
|
|
7534
7547
|
return () => clearTimeout(timer);
|
|
7535
7548
|
}
|
|
7536
7549
|
}, [mutation.status, mutation.data]);
|
|
7537
|
-
(0,
|
|
7550
|
+
(0, import_react46.useEffect)(() => {
|
|
7538
7551
|
if (mutation.status === "error" && mutation.error) {
|
|
7539
7552
|
onError?.(mutation.error);
|
|
7540
7553
|
}
|
|
@@ -7544,7 +7557,7 @@ function CreateGameSheet({
|
|
|
7544
7557
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
7545
7558
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
7546
7559
|
const canCreate = selectedTeam !== null && !isMutating && mutation.status !== "success";
|
|
7547
|
-
const handleCreate = (0,
|
|
7560
|
+
const handleCreate = (0, import_react46.useCallback)(async () => {
|
|
7548
7561
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
7549
7562
|
try {
|
|
7550
7563
|
await mutation.execute({
|
|
@@ -7692,7 +7705,7 @@ var styles20 = import_react_native26.StyleSheet.create({
|
|
|
7692
7705
|
});
|
|
7693
7706
|
|
|
7694
7707
|
// src/ui/jackpot/JackpotCard.tsx
|
|
7695
|
-
var
|
|
7708
|
+
var import_react47 = require("react");
|
|
7696
7709
|
var import_react_native27 = require("react-native");
|
|
7697
7710
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
7698
7711
|
function formatSOL(lamports) {
|
|
@@ -7709,9 +7722,9 @@ function truncateWallet2(addr) {
|
|
|
7709
7722
|
return `${addr.slice(0, 4)}...${addr.slice(-4)}`;
|
|
7710
7723
|
}
|
|
7711
7724
|
function JackpotCard({ round, lastWinner, entries, onPress, style }) {
|
|
7712
|
-
const shimmerAnim = (0,
|
|
7713
|
-
const pulseAnim = (0,
|
|
7714
|
-
(0,
|
|
7725
|
+
const shimmerAnim = (0, import_react47.useRef)(new import_react_native27.Animated.Value(-1)).current;
|
|
7726
|
+
const pulseAnim = (0, import_react47.useRef)(new import_react_native27.Animated.Value(0.4)).current;
|
|
7727
|
+
(0, import_react47.useEffect)(() => {
|
|
7715
7728
|
const shimmer = import_react_native27.Animated.loop(
|
|
7716
7729
|
import_react_native27.Animated.sequence([
|
|
7717
7730
|
import_react_native27.Animated.timing(shimmerAnim, { toValue: 1, duration: 4e3, useNativeDriver: true }),
|
|
@@ -8070,7 +8083,7 @@ var styles21 = import_react_native27.StyleSheet.create({
|
|
|
8070
8083
|
});
|
|
8071
8084
|
|
|
8072
8085
|
// src/ui/jackpot/JackpotSheet.tsx
|
|
8073
|
-
var
|
|
8086
|
+
var import_react48 = require("react");
|
|
8074
8087
|
var import_react_native28 = require("react-native");
|
|
8075
8088
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
8076
8089
|
var STATUS_LABELS7 = {
|
|
@@ -8105,17 +8118,17 @@ function JackpotSheet({
|
|
|
8105
8118
|
const { wallet, client } = useDubs();
|
|
8106
8119
|
const { round, lastWinner, refetch } = useJackpot();
|
|
8107
8120
|
const mutation = useEnterJackpot();
|
|
8108
|
-
const [betAmount, setBetAmount] = (0,
|
|
8109
|
-
const [entries, setEntries] = (0,
|
|
8110
|
-
const overlayOpacity = (0,
|
|
8111
|
-
(0,
|
|
8121
|
+
const [betAmount, setBetAmount] = (0, import_react48.useState)("0.1");
|
|
8122
|
+
const [entries, setEntries] = (0, import_react48.useState)([]);
|
|
8123
|
+
const overlayOpacity = (0, import_react48.useRef)(new import_react_native28.Animated.Value(0)).current;
|
|
8124
|
+
(0, import_react48.useEffect)(() => {
|
|
8112
8125
|
import_react_native28.Animated.timing(overlayOpacity, {
|
|
8113
8126
|
toValue: visible ? 1 : 0,
|
|
8114
8127
|
duration: 250,
|
|
8115
8128
|
useNativeDriver: true
|
|
8116
8129
|
}).start();
|
|
8117
8130
|
}, [visible, overlayOpacity]);
|
|
8118
|
-
(0,
|
|
8131
|
+
(0, import_react48.useEffect)(() => {
|
|
8119
8132
|
if (visible) {
|
|
8120
8133
|
mutation.reset();
|
|
8121
8134
|
setBetAmount("0.1");
|
|
@@ -8124,7 +8137,7 @@ function JackpotSheet({
|
|
|
8124
8137
|
});
|
|
8125
8138
|
}
|
|
8126
8139
|
}, [visible]);
|
|
8127
|
-
(0,
|
|
8140
|
+
(0, import_react48.useEffect)(() => {
|
|
8128
8141
|
if (mutation.status === "success" && mutation.data) {
|
|
8129
8142
|
onSuccess?.(mutation.data);
|
|
8130
8143
|
refetch();
|
|
@@ -8134,7 +8147,7 @@ function JackpotSheet({
|
|
|
8134
8147
|
return () => clearTimeout(timer);
|
|
8135
8148
|
}
|
|
8136
8149
|
}, [mutation.status, mutation.data]);
|
|
8137
|
-
(0,
|
|
8150
|
+
(0, import_react48.useEffect)(() => {
|
|
8138
8151
|
if (mutation.status === "error" && mutation.error) {
|
|
8139
8152
|
onError?.(mutation.error);
|
|
8140
8153
|
}
|
|
@@ -8146,14 +8159,14 @@ function JackpotSheet({
|
|
|
8146
8159
|
const userOdds = totalWeight > 0 ? (entryLamports / (totalWeight + entryLamports) * 100).toFixed(1) : entries.length === 0 ? "100.0" : "0.0";
|
|
8147
8160
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
8148
8161
|
const canEnter = !isMutating && mutation.status !== "success" && round?.status === "Open" && betSol >= minEntry;
|
|
8149
|
-
const handleQuickAdd = (0,
|
|
8162
|
+
const handleQuickAdd = (0, import_react48.useCallback)((amount) => {
|
|
8150
8163
|
setBetAmount((prev) => {
|
|
8151
8164
|
const current = parseFloat(prev) || 0;
|
|
8152
8165
|
const next = Math.min(current + amount, maxEntry);
|
|
8153
8166
|
return next.toFixed(2);
|
|
8154
8167
|
});
|
|
8155
8168
|
}, [maxEntry]);
|
|
8156
|
-
const handleEnter = (0,
|
|
8169
|
+
const handleEnter = (0, import_react48.useCallback)(async () => {
|
|
8157
8170
|
if (!wallet.publicKey || entryLamports < 1e4) return;
|
|
8158
8171
|
try {
|
|
8159
8172
|
await mutation.execute(entryLamports);
|
|
@@ -8672,7 +8685,7 @@ var styles22 = import_react_native28.StyleSheet.create({
|
|
|
8672
8685
|
});
|
|
8673
8686
|
|
|
8674
8687
|
// src/ui/jackpot/JackpotWidget.tsx
|
|
8675
|
-
var
|
|
8688
|
+
var import_react49 = require("react");
|
|
8676
8689
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
8677
8690
|
function JackpotWidget({
|
|
8678
8691
|
style,
|
|
@@ -8681,11 +8694,11 @@ function JackpotWidget({
|
|
|
8681
8694
|
onEntry,
|
|
8682
8695
|
onError
|
|
8683
8696
|
}) {
|
|
8684
|
-
const [sheetVisible, setSheetVisible] = (0,
|
|
8697
|
+
const [sheetVisible, setSheetVisible] = (0, import_react49.useState)(false);
|
|
8685
8698
|
const { round, lastWinner } = useJackpot();
|
|
8686
8699
|
const { client } = useDubs();
|
|
8687
|
-
const [entries, setEntries] = (0,
|
|
8688
|
-
(0,
|
|
8700
|
+
const [entries, setEntries] = (0, import_react49.useState)([]);
|
|
8701
|
+
(0, import_react49.useEffect)(() => {
|
|
8689
8702
|
client.getJackpotEntries().then((res) => setEntries(res.entries)).catch(() => {
|
|
8690
8703
|
});
|
|
8691
8704
|
}, [client, round?.entryCount]);
|
|
@@ -8719,7 +8732,7 @@ function JackpotWidget({
|
|
|
8719
8732
|
}
|
|
8720
8733
|
|
|
8721
8734
|
// src/chat/provider.tsx
|
|
8722
|
-
var
|
|
8735
|
+
var import_react50 = require("react");
|
|
8723
8736
|
var import_react_native29 = require("react-native");
|
|
8724
8737
|
|
|
8725
8738
|
// src/chat/socket.ts
|
|
@@ -8829,22 +8842,22 @@ var ChatSocket = class {
|
|
|
8829
8842
|
|
|
8830
8843
|
// src/chat/provider.tsx
|
|
8831
8844
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
8832
|
-
var ChatContext = (0,
|
|
8845
|
+
var ChatContext = (0, import_react50.createContext)(null);
|
|
8833
8846
|
function ChatProvider({ children, autoConnect = true }) {
|
|
8834
8847
|
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,
|
|
8848
|
+
const socketRef = (0, import_react50.useRef)(new ChatSocket());
|
|
8849
|
+
const [status, setStatus] = (0, import_react50.useState)("disconnected");
|
|
8850
|
+
const [messages, setMessages] = (0, import_react50.useState)([]);
|
|
8851
|
+
const [onlineUsers, setOnlineUsers] = (0, import_react50.useState)([]);
|
|
8852
|
+
const [onlineCount, setOnlineCount] = (0, import_react50.useState)(0);
|
|
8853
|
+
const [unreadCount, setUnreadCount] = (0, import_react50.useState)(0);
|
|
8854
|
+
const [conversations, setConversations] = (0, import_react50.useState)([]);
|
|
8855
|
+
const [friends, setFriends] = (0, import_react50.useState)([]);
|
|
8856
|
+
const [pendingRequests, setPendingRequests] = (0, import_react50.useState)([]);
|
|
8857
|
+
const [sentFriendRequests, setSentFriendRequests] = (0, import_react50.useState)([]);
|
|
8858
|
+
const [whatsNewPosts, setWhatsNewPosts] = (0, import_react50.useState)([]);
|
|
8859
|
+
const [whatsNewUnreadCount, setWhatsNewUnreadCount] = (0, import_react50.useState)(0);
|
|
8860
|
+
const refreshMessages = (0, import_react50.useCallback)(async () => {
|
|
8848
8861
|
try {
|
|
8849
8862
|
const res = await client.getChatMessages({ limit: 30 });
|
|
8850
8863
|
setMessages([...res.messages].reverse());
|
|
@@ -8852,35 +8865,35 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8852
8865
|
console.error("[Dubs:ChatProvider] Failed to load messages:", err);
|
|
8853
8866
|
}
|
|
8854
8867
|
}, [client]);
|
|
8855
|
-
const refreshConversations = (0,
|
|
8868
|
+
const refreshConversations = (0, import_react50.useCallback)(async () => {
|
|
8856
8869
|
try {
|
|
8857
8870
|
const res = await client.getConversations();
|
|
8858
8871
|
setConversations(res.conversations);
|
|
8859
8872
|
} catch (_) {
|
|
8860
8873
|
}
|
|
8861
8874
|
}, [client]);
|
|
8862
|
-
const refreshFriends = (0,
|
|
8875
|
+
const refreshFriends = (0, import_react50.useCallback)(async () => {
|
|
8863
8876
|
try {
|
|
8864
8877
|
const res = await client.getFriends();
|
|
8865
8878
|
setFriends(res.friends);
|
|
8866
8879
|
} catch (_) {
|
|
8867
8880
|
}
|
|
8868
8881
|
}, [client]);
|
|
8869
|
-
const refreshPendingRequests = (0,
|
|
8882
|
+
const refreshPendingRequests = (0, import_react50.useCallback)(async () => {
|
|
8870
8883
|
try {
|
|
8871
8884
|
const res = await client.getPendingFriendRequests();
|
|
8872
8885
|
setPendingRequests(res.requests);
|
|
8873
8886
|
} catch (_) {
|
|
8874
8887
|
}
|
|
8875
8888
|
}, [client]);
|
|
8876
|
-
const refreshSentFriendRequests = (0,
|
|
8889
|
+
const refreshSentFriendRequests = (0, import_react50.useCallback)(async () => {
|
|
8877
8890
|
try {
|
|
8878
8891
|
const res = await client.getSentFriendRequests();
|
|
8879
8892
|
setSentFriendRequests(res.requests);
|
|
8880
8893
|
} catch (_) {
|
|
8881
8894
|
}
|
|
8882
8895
|
}, [client]);
|
|
8883
|
-
const refreshWhatsNew = (0,
|
|
8896
|
+
const refreshWhatsNew = (0, import_react50.useCallback)(async () => {
|
|
8884
8897
|
try {
|
|
8885
8898
|
const res = await client.getWhatsNewPosts();
|
|
8886
8899
|
setWhatsNewPosts(res.posts);
|
|
@@ -8889,7 +8902,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8889
8902
|
} catch (_) {
|
|
8890
8903
|
}
|
|
8891
8904
|
}, [client]);
|
|
8892
|
-
(0,
|
|
8905
|
+
(0, import_react50.useEffect)(() => {
|
|
8893
8906
|
const token = client.getToken();
|
|
8894
8907
|
if (!autoConnect || !token) return;
|
|
8895
8908
|
const chatSocket = socketRef.current;
|
|
@@ -8967,7 +8980,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8967
8980
|
chatSocket.disconnect();
|
|
8968
8981
|
};
|
|
8969
8982
|
}, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8970
|
-
(0,
|
|
8983
|
+
(0, import_react50.useEffect)(() => {
|
|
8971
8984
|
const handleAppState = (nextState) => {
|
|
8972
8985
|
if (nextState === "active") {
|
|
8973
8986
|
const chatSocket = socketRef.current;
|
|
@@ -8995,7 +9008,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8995
9008
|
const sub = import_react_native29.AppState.addEventListener("change", handleAppState);
|
|
8996
9009
|
return () => sub.remove();
|
|
8997
9010
|
}, [client, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8998
|
-
const value = (0,
|
|
9011
|
+
const value = (0, import_react50.useMemo)(
|
|
8999
9012
|
() => ({
|
|
9000
9013
|
socket: socketRef.current,
|
|
9001
9014
|
status,
|
|
@@ -9021,7 +9034,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
9021
9034
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ChatContext.Provider, { value, children });
|
|
9022
9035
|
}
|
|
9023
9036
|
function useChatContext() {
|
|
9024
|
-
const ctx = (0,
|
|
9037
|
+
const ctx = (0, import_react50.useContext)(ChatContext);
|
|
9025
9038
|
if (!ctx) {
|
|
9026
9039
|
throw new Error("useChatContext must be used inside a <ChatProvider>");
|
|
9027
9040
|
}
|
|
@@ -9029,14 +9042,14 @@ function useChatContext() {
|
|
|
9029
9042
|
}
|
|
9030
9043
|
|
|
9031
9044
|
// src/chat/hooks.ts
|
|
9032
|
-
var
|
|
9045
|
+
var import_react51 = require("react");
|
|
9033
9046
|
function useChatStatus() {
|
|
9034
9047
|
return useChatContext().status;
|
|
9035
9048
|
}
|
|
9036
9049
|
function useChatMessages() {
|
|
9037
9050
|
const { messages, refreshMessages } = useChatContext();
|
|
9038
|
-
const [loading, setLoading] = (0,
|
|
9039
|
-
const refetch = (0,
|
|
9051
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9052
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9040
9053
|
setLoading(true);
|
|
9041
9054
|
await refreshMessages();
|
|
9042
9055
|
setLoading(false);
|
|
@@ -9046,13 +9059,13 @@ function useChatMessages() {
|
|
|
9046
9059
|
function useSendMessage() {
|
|
9047
9060
|
const { socket } = useChatContext();
|
|
9048
9061
|
const { client } = useDubs();
|
|
9049
|
-
const send = (0,
|
|
9062
|
+
const send = (0, import_react51.useCallback)(
|
|
9050
9063
|
(params) => {
|
|
9051
9064
|
socket.sendMessage(params);
|
|
9052
9065
|
},
|
|
9053
9066
|
[socket]
|
|
9054
9067
|
);
|
|
9055
|
-
const sendViaREST = (0,
|
|
9068
|
+
const sendViaREST = (0, import_react51.useCallback)(
|
|
9056
9069
|
async (params) => {
|
|
9057
9070
|
await client.sendChatMessage(params);
|
|
9058
9071
|
},
|
|
@@ -9069,8 +9082,8 @@ function useUnreadCount() {
|
|
|
9069
9082
|
}
|
|
9070
9083
|
function useConversations() {
|
|
9071
9084
|
const { conversations, refreshConversations } = useChatContext();
|
|
9072
|
-
const [loading, setLoading] = (0,
|
|
9073
|
-
const refetch = (0,
|
|
9085
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9086
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9074
9087
|
setLoading(true);
|
|
9075
9088
|
await refreshConversations();
|
|
9076
9089
|
setLoading(false);
|
|
@@ -9080,10 +9093,10 @@ function useConversations() {
|
|
|
9080
9093
|
function useDirectMessages(recipientWallet) {
|
|
9081
9094
|
const { client } = useDubs();
|
|
9082
9095
|
const { socket, refreshConversations } = useChatContext();
|
|
9083
|
-
const [messages, setMessages] = (0,
|
|
9084
|
-
const [otherUser, setOtherUser] = (0,
|
|
9085
|
-
const [loading, setLoading] = (0,
|
|
9086
|
-
const refetch = (0,
|
|
9096
|
+
const [messages, setMessages] = (0, import_react51.useState)([]);
|
|
9097
|
+
const [otherUser, setOtherUser] = (0, import_react51.useState)(null);
|
|
9098
|
+
const [loading, setLoading] = (0, import_react51.useState)(true);
|
|
9099
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9087
9100
|
try {
|
|
9088
9101
|
setLoading(true);
|
|
9089
9102
|
const res = await client.getConversation(recipientWallet);
|
|
@@ -9095,16 +9108,16 @@ function useDirectMessages(recipientWallet) {
|
|
|
9095
9108
|
setLoading(false);
|
|
9096
9109
|
}
|
|
9097
9110
|
}, [client, recipientWallet]);
|
|
9098
|
-
(0,
|
|
9111
|
+
(0, import_react51.useEffect)(() => {
|
|
9099
9112
|
refetch();
|
|
9100
9113
|
socket.joinDM(recipientWallet);
|
|
9101
9114
|
return () => {
|
|
9102
9115
|
socket.leaveDM(recipientWallet);
|
|
9103
9116
|
};
|
|
9104
9117
|
}, [recipientWallet, refetch, socket]);
|
|
9105
|
-
const socketRef = (0,
|
|
9118
|
+
const socketRef = (0, import_react51.useRef)(socket);
|
|
9106
9119
|
socketRef.current = socket;
|
|
9107
|
-
(0,
|
|
9120
|
+
(0, import_react51.useEffect)(() => {
|
|
9108
9121
|
const currentSocket = socketRef.current;
|
|
9109
9122
|
const prevListeners = currentSocket.listeners;
|
|
9110
9123
|
const originalOnDMNew = prevListeners?.onDMNewMessage;
|
|
@@ -9127,13 +9140,13 @@ function useDirectMessages(recipientWallet) {
|
|
|
9127
9140
|
}
|
|
9128
9141
|
});
|
|
9129
9142
|
}, [recipientWallet]);
|
|
9130
|
-
const send = (0,
|
|
9143
|
+
const send = (0, import_react51.useCallback)(
|
|
9131
9144
|
(message) => {
|
|
9132
9145
|
socket.sendDM({ recipientWallet, message });
|
|
9133
9146
|
},
|
|
9134
9147
|
[socket, recipientWallet]
|
|
9135
9148
|
);
|
|
9136
|
-
const sendViaREST = (0,
|
|
9149
|
+
const sendViaREST = (0, import_react51.useCallback)(
|
|
9137
9150
|
async (message) => {
|
|
9138
9151
|
await client.sendDirectMessage({ recipientWallet, message });
|
|
9139
9152
|
await refetch();
|
|
@@ -9141,15 +9154,15 @@ function useDirectMessages(recipientWallet) {
|
|
|
9141
9154
|
},
|
|
9142
9155
|
[client, recipientWallet, refetch, refreshConversations]
|
|
9143
9156
|
);
|
|
9144
|
-
const markRead = (0,
|
|
9157
|
+
const markRead = (0, import_react51.useCallback)(() => {
|
|
9145
9158
|
socket.markDMRead(recipientWallet);
|
|
9146
9159
|
}, [socket, recipientWallet]);
|
|
9147
9160
|
return { messages, loading, otherUser, send, sendViaREST, markRead, refetch };
|
|
9148
9161
|
}
|
|
9149
9162
|
function useFriends() {
|
|
9150
9163
|
const { friends, refreshFriends } = useChatContext();
|
|
9151
|
-
const [loading, setLoading] = (0,
|
|
9152
|
-
const refetch = (0,
|
|
9164
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9165
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9153
9166
|
setLoading(true);
|
|
9154
9167
|
await refreshFriends();
|
|
9155
9168
|
setLoading(false);
|
|
@@ -9158,8 +9171,8 @@ function useFriends() {
|
|
|
9158
9171
|
}
|
|
9159
9172
|
function useFriendRequests() {
|
|
9160
9173
|
const { pendingRequests, refreshPendingRequests } = useChatContext();
|
|
9161
|
-
const [loading, setLoading] = (0,
|
|
9162
|
-
const refetch = (0,
|
|
9174
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9175
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9163
9176
|
setLoading(true);
|
|
9164
9177
|
await refreshPendingRequests();
|
|
9165
9178
|
setLoading(false);
|
|
@@ -9168,8 +9181,8 @@ function useFriendRequests() {
|
|
|
9168
9181
|
}
|
|
9169
9182
|
function useSentFriendRequests() {
|
|
9170
9183
|
const { sentFriendRequests, refreshSentFriendRequests } = useChatContext();
|
|
9171
|
-
const [loading, setLoading] = (0,
|
|
9172
|
-
const refetch = (0,
|
|
9184
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9185
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9173
9186
|
setLoading(true);
|
|
9174
9187
|
await refreshSentFriendRequests();
|
|
9175
9188
|
setLoading(false);
|
|
@@ -9179,8 +9192,8 @@ function useSentFriendRequests() {
|
|
|
9179
9192
|
function useCancelFriendRequest() {
|
|
9180
9193
|
const { client } = useDubs();
|
|
9181
9194
|
const { refreshSentFriendRequests } = useChatContext();
|
|
9182
|
-
const [loading, setLoading] = (0,
|
|
9183
|
-
const cancel = (0,
|
|
9195
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9196
|
+
const cancel = (0, import_react51.useCallback)(
|
|
9184
9197
|
async (requestId) => {
|
|
9185
9198
|
setLoading(true);
|
|
9186
9199
|
try {
|
|
@@ -9196,9 +9209,9 @@ function useCancelFriendRequest() {
|
|
|
9196
9209
|
}
|
|
9197
9210
|
function useSearchUsers() {
|
|
9198
9211
|
const { client } = useDubs();
|
|
9199
|
-
const [results, setResults] = (0,
|
|
9200
|
-
const [loading, setLoading] = (0,
|
|
9201
|
-
const search = (0,
|
|
9212
|
+
const [results, setResults] = (0, import_react51.useState)([]);
|
|
9213
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9214
|
+
const search = (0, import_react51.useCallback)(
|
|
9202
9215
|
async (query) => {
|
|
9203
9216
|
setLoading(true);
|
|
9204
9217
|
try {
|
|
@@ -9212,14 +9225,14 @@ function useSearchUsers() {
|
|
|
9212
9225
|
},
|
|
9213
9226
|
[client]
|
|
9214
9227
|
);
|
|
9215
|
-
const clear = (0,
|
|
9228
|
+
const clear = (0, import_react51.useCallback)(() => setResults([]), []);
|
|
9216
9229
|
return { results, loading, search, clear };
|
|
9217
9230
|
}
|
|
9218
9231
|
function useSendFriendRequest() {
|
|
9219
9232
|
const { client } = useDubs();
|
|
9220
9233
|
const { refreshPendingRequests } = useChatContext();
|
|
9221
|
-
const [loading, setLoading] = (0,
|
|
9222
|
-
const send = (0,
|
|
9234
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9235
|
+
const send = (0, import_react51.useCallback)(
|
|
9223
9236
|
async (targetUserId) => {
|
|
9224
9237
|
setLoading(true);
|
|
9225
9238
|
try {
|
|
@@ -9235,8 +9248,8 @@ function useSendFriendRequest() {
|
|
|
9235
9248
|
function useRespondToFriendRequest() {
|
|
9236
9249
|
const { client } = useDubs();
|
|
9237
9250
|
const { refreshFriends, refreshPendingRequests } = useChatContext();
|
|
9238
|
-
const [loading, setLoading] = (0,
|
|
9239
|
-
const accept = (0,
|
|
9251
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9252
|
+
const accept = (0, import_react51.useCallback)(
|
|
9240
9253
|
async (requestId) => {
|
|
9241
9254
|
setLoading(true);
|
|
9242
9255
|
try {
|
|
@@ -9248,7 +9261,7 @@ function useRespondToFriendRequest() {
|
|
|
9248
9261
|
},
|
|
9249
9262
|
[client, refreshFriends, refreshPendingRequests]
|
|
9250
9263
|
);
|
|
9251
|
-
const reject = (0,
|
|
9264
|
+
const reject = (0, import_react51.useCallback)(
|
|
9252
9265
|
async (requestId) => {
|
|
9253
9266
|
setLoading(true);
|
|
9254
9267
|
try {
|
|
@@ -9265,8 +9278,8 @@ function useRespondToFriendRequest() {
|
|
|
9265
9278
|
function useWhatsNew() {
|
|
9266
9279
|
const { client } = useDubs();
|
|
9267
9280
|
const { whatsNewPosts, whatsNewUnreadCount, refreshWhatsNew } = useChatContext();
|
|
9268
|
-
const [loading, setLoading] = (0,
|
|
9269
|
-
const refetch = (0,
|
|
9281
|
+
const [loading, setLoading] = (0, import_react51.useState)(false);
|
|
9282
|
+
const refetch = (0, import_react51.useCallback)(async () => {
|
|
9270
9283
|
setLoading(true);
|
|
9271
9284
|
try {
|
|
9272
9285
|
await refreshWhatsNew();
|
|
@@ -9274,7 +9287,7 @@ function useWhatsNew() {
|
|
|
9274
9287
|
setLoading(false);
|
|
9275
9288
|
}
|
|
9276
9289
|
}, [refreshWhatsNew]);
|
|
9277
|
-
const markRead = (0,
|
|
9290
|
+
const markRead = (0, import_react51.useCallback)(
|
|
9278
9291
|
async (postIds) => {
|
|
9279
9292
|
if (postIds.length === 0) return;
|
|
9280
9293
|
try {
|
|
@@ -9286,7 +9299,7 @@ function useWhatsNew() {
|
|
|
9286
9299
|
},
|
|
9287
9300
|
[client, refreshWhatsNew]
|
|
9288
9301
|
);
|
|
9289
|
-
const markAllRead = (0,
|
|
9302
|
+
const markAllRead = (0, import_react51.useCallback)(async () => {
|
|
9290
9303
|
try {
|
|
9291
9304
|
await client.markAllWhatsNewRead();
|
|
9292
9305
|
await refreshWhatsNew();
|