@hipnation-truth/sdk 0.26.6 → 0.26.8
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 +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +8 -1
- package/dist/react.js +71 -64
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -1245,8 +1245,15 @@ type Environment = (typeof ENVIRONMENTS)[keyof typeof ENVIRONMENTS];
|
|
|
1245
1245
|
* your identity provider's Clerk JWT template named "convex"
|
|
1246
1246
|
* (e.g. `getToken({ template: "convex" })` from `@clerk/expo`), or
|
|
1247
1247
|
* `null` when no user is signed in.
|
|
1248
|
+
*
|
|
1249
|
+
* Convex invokes this with `{ forceRefreshToken: true }` when the cached
|
|
1250
|
+
* token has expired — forward it to your provider (e.g. Clerk's
|
|
1251
|
+
* `getToken({ template: "convex", skipCache: opts?.forceRefreshToken })`)
|
|
1252
|
+
* so the refresh returns a fresh token rather than a stale cached one.
|
|
1248
1253
|
*/
|
|
1249
|
-
type AuthTokenFetcher = (
|
|
1254
|
+
type AuthTokenFetcher = (opts?: {
|
|
1255
|
+
forceRefreshToken?: boolean;
|
|
1256
|
+
}) => Promise<string | null | undefined>;
|
|
1250
1257
|
/**
|
|
1251
1258
|
* Configuration for initializing a TruthClient.
|
|
1252
1259
|
*/
|
package/dist/react.js
CHANGED
|
@@ -122,7 +122,6 @@ __export(react_exports, {
|
|
|
122
122
|
module.exports = __toCommonJS(react_exports);
|
|
123
123
|
|
|
124
124
|
// src/react/calls.ts
|
|
125
|
-
var import_react3 = require("convex/react");
|
|
126
125
|
var import_server2 = require("convex/server");
|
|
127
126
|
|
|
128
127
|
// src/react/offline/use-persistent-query.ts
|
|
@@ -2296,26 +2295,34 @@ function TruthProvider({
|
|
|
2296
2295
|
getAuthTokenRef.current = getAuthToken;
|
|
2297
2296
|
const hasAuthFetcher = Boolean(getAuthToken);
|
|
2298
2297
|
const stableGetAuthToken = (0, import_react2.useMemo)(
|
|
2299
|
-
() => hasAuthFetcher ? () => __async(null, null, function* () {
|
|
2298
|
+
() => hasAuthFetcher ? (opts) => __async(null, null, function* () {
|
|
2300
2299
|
var _a2, _b2;
|
|
2301
|
-
return (_b2 = yield (_a2 = getAuthTokenRef.current) == null ? void 0 : _a2.call(getAuthTokenRef)) != null ? _b2 : null;
|
|
2300
|
+
return (_b2 = yield (_a2 = getAuthTokenRef.current) == null ? void 0 : _a2.call(getAuthTokenRef, opts)) != null ? _b2 : null;
|
|
2302
2301
|
}) : void 0,
|
|
2303
2302
|
[hasAuthFetcher]
|
|
2304
2303
|
);
|
|
2305
2304
|
const [convexAuthed, setConvexAuthed] = (0, import_react2.useState)(false);
|
|
2306
2305
|
(0, import_react2.useEffect)(() => {
|
|
2307
|
-
if (stableGetAuthToken) {
|
|
2308
|
-
convexClient.setAuth(
|
|
2309
|
-
() => __async(null, null, function* () {
|
|
2310
|
-
var _a2;
|
|
2311
|
-
return (_a2 = yield stableGetAuthToken()) != null ? _a2 : null;
|
|
2312
|
-
}),
|
|
2313
|
-
(isAuthenticated) => setConvexAuthed(isAuthenticated)
|
|
2314
|
-
);
|
|
2315
|
-
} else {
|
|
2306
|
+
if (!stableGetAuthToken) {
|
|
2316
2307
|
convexClient.clearAuth();
|
|
2317
2308
|
setConvexAuthed(false);
|
|
2309
|
+
return;
|
|
2318
2310
|
}
|
|
2311
|
+
const fetchToken = (opts) => __async(null, null, function* () {
|
|
2312
|
+
for (let attempt = 0; attempt < 6; attempt++) {
|
|
2313
|
+
try {
|
|
2314
|
+
const token = yield stableGetAuthToken(opts);
|
|
2315
|
+
if (token) return token;
|
|
2316
|
+
} catch (e) {
|
|
2317
|
+
}
|
|
2318
|
+
yield new Promise((resolve) => setTimeout(resolve, 200 + attempt * 150));
|
|
2319
|
+
}
|
|
2320
|
+
return null;
|
|
2321
|
+
});
|
|
2322
|
+
convexClient.setAuth(
|
|
2323
|
+
fetchToken,
|
|
2324
|
+
(isAuthenticated) => setConvexAuthed(isAuthenticated)
|
|
2325
|
+
);
|
|
2319
2326
|
}, [convexClient, stableGetAuthToken]);
|
|
2320
2327
|
const convexQueryClient = (0, import_react2.useMemo)(
|
|
2321
2328
|
() => new import_react_query.ConvexQueryClient(convexClient),
|
|
@@ -2497,7 +2504,7 @@ function toResult(value, skipped) {
|
|
|
2497
2504
|
}
|
|
2498
2505
|
function useActiveCalls(options) {
|
|
2499
2506
|
const ready = useConvexQueriesReady();
|
|
2500
|
-
const result = (
|
|
2507
|
+
const result = usePersistentQuery(listActiveRef, ready ? options != null ? options : {} : "skip");
|
|
2501
2508
|
return toResult(result, false);
|
|
2502
2509
|
}
|
|
2503
2510
|
function useDialpadCallsForConversation(conversationId, options) {
|
|
@@ -2549,7 +2556,7 @@ function useConversationById(id) {
|
|
|
2549
2556
|
|
|
2550
2557
|
// src/react/conversations.ts
|
|
2551
2558
|
var import_server4 = require("convex/server");
|
|
2552
|
-
var
|
|
2559
|
+
var import_react3 = require("react");
|
|
2553
2560
|
var conversationsListForUserRef = (0, import_server4.makeFunctionReference)("conversations:listForUser");
|
|
2554
2561
|
var conversationsSearchForUserRef = (0, import_server4.makeFunctionReference)("conversations:searchForUser");
|
|
2555
2562
|
var conversationsGetUnreadTotalForUserRef = (0, import_server4.makeFunctionReference)("conversations:getUnreadTotalForUser");
|
|
@@ -2636,7 +2643,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
2636
2643
|
}
|
|
2637
2644
|
function useMemoizedPhones(phones) {
|
|
2638
2645
|
const key = phones ? [...phones].sort().join("|") : "";
|
|
2639
|
-
return (0,
|
|
2646
|
+
return (0, import_react3.useMemo)(
|
|
2640
2647
|
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
2641
2648
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2642
2649
|
[key]
|
|
@@ -2684,7 +2691,7 @@ function useConversationTasksByPhonePair(phonePair) {
|
|
|
2684
2691
|
}
|
|
2685
2692
|
|
|
2686
2693
|
// src/react/hooks.ts
|
|
2687
|
-
var
|
|
2694
|
+
var import_react4 = require("react");
|
|
2688
2695
|
var import_server5 = require("convex/server");
|
|
2689
2696
|
var patientsListRef = (0, import_server5.makeFunctionReference)("patients:list");
|
|
2690
2697
|
var patientsGetRef = (0, import_server5.makeFunctionReference)("patients:get");
|
|
@@ -2784,7 +2791,7 @@ function usePatientMedical(elationId, options) {
|
|
|
2784
2791
|
appointmentsByPatientRef,
|
|
2785
2792
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2786
2793
|
);
|
|
2787
|
-
(0,
|
|
2794
|
+
(0, import_react4.useEffect)(() => {
|
|
2788
2795
|
if (elationId === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
2789
2796
|
return;
|
|
2790
2797
|
}
|
|
@@ -2822,7 +2829,7 @@ function usePatientBasic(input, options) {
|
|
|
2822
2829
|
hintPatientByIdRef,
|
|
2823
2830
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
2824
2831
|
);
|
|
2825
|
-
(0,
|
|
2832
|
+
(0, import_react4.useEffect)(() => {
|
|
2826
2833
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2827
2834
|
return;
|
|
2828
2835
|
}
|
|
@@ -2878,7 +2885,7 @@ function usePatientPhoto(elationId, options) {
|
|
|
2878
2885
|
patientPhotoByIdRef,
|
|
2879
2886
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2880
2887
|
);
|
|
2881
|
-
(0,
|
|
2888
|
+
(0, import_react4.useEffect)(() => {
|
|
2882
2889
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2883
2890
|
return;
|
|
2884
2891
|
}
|
|
@@ -2921,7 +2928,7 @@ function useConversationMessages(input, options) {
|
|
|
2921
2928
|
}
|
|
2922
2929
|
|
|
2923
2930
|
// src/react/notifications.ts
|
|
2924
|
-
var
|
|
2931
|
+
var import_react5 = require("react");
|
|
2925
2932
|
function loadExpo() {
|
|
2926
2933
|
return __async(this, null, function* () {
|
|
2927
2934
|
try {
|
|
@@ -2936,12 +2943,12 @@ function useNotifications(options) {
|
|
|
2936
2943
|
const sdkContext = useTruthSdkContext();
|
|
2937
2944
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
2938
2945
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
2939
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
2940
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
2941
|
-
const expoRef = (0,
|
|
2942
|
-
const isWebRef = (0,
|
|
2943
|
-
const vapidKeyRef = (0,
|
|
2944
|
-
(0,
|
|
2946
|
+
const [permissionStatus, setPermissionStatus] = (0, import_react5.useState)("unknown");
|
|
2947
|
+
const [devicePushToken, setDevicePushToken] = (0, import_react5.useState)(null);
|
|
2948
|
+
const expoRef = (0, import_react5.useRef)(null);
|
|
2949
|
+
const isWebRef = (0, import_react5.useRef)(false);
|
|
2950
|
+
const vapidKeyRef = (0, import_react5.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
|
|
2951
|
+
(0, import_react5.useEffect)(() => {
|
|
2945
2952
|
let mounted = true;
|
|
2946
2953
|
void (() => __async(null, null, function* () {
|
|
2947
2954
|
var _a2;
|
|
@@ -2997,7 +3004,7 @@ function useNotifications(options) {
|
|
|
2997
3004
|
mounted = false;
|
|
2998
3005
|
};
|
|
2999
3006
|
}, [apiBaseUrl, apiKey]);
|
|
3000
|
-
const register = (0,
|
|
3007
|
+
const register = (0, import_react5.useCallback)(() => __async(null, null, function* () {
|
|
3001
3008
|
var _a2, _b2;
|
|
3002
3009
|
if (!options.userId) {
|
|
3003
3010
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3110,7 +3117,7 @@ function useNotifications(options) {
|
|
|
3110
3117
|
options.appVersion,
|
|
3111
3118
|
options.serviceWorkerPath
|
|
3112
3119
|
]);
|
|
3113
|
-
const unregister = (0,
|
|
3120
|
+
const unregister = (0, import_react5.useCallback)(() => __async(null, null, function* () {
|
|
3114
3121
|
if (!devicePushToken) {
|
|
3115
3122
|
return;
|
|
3116
3123
|
}
|
|
@@ -3125,7 +3132,7 @@ function useNotifications(options) {
|
|
|
3125
3132
|
});
|
|
3126
3133
|
setDevicePushToken(null);
|
|
3127
3134
|
}), [apiBaseUrl, apiKey, devicePushToken]);
|
|
3128
|
-
const addReceivedListener = (0,
|
|
3135
|
+
const addReceivedListener = (0, import_react5.useCallback)(
|
|
3129
3136
|
(listener) => {
|
|
3130
3137
|
if (isWebRef.current) {
|
|
3131
3138
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3154,7 +3161,7 @@ function useNotifications(options) {
|
|
|
3154
3161
|
},
|
|
3155
3162
|
[]
|
|
3156
3163
|
);
|
|
3157
|
-
const addResponseListener = (0,
|
|
3164
|
+
const addResponseListener = (0, import_react5.useCallback)(
|
|
3158
3165
|
(listener) => {
|
|
3159
3166
|
if (isWebRef.current) {
|
|
3160
3167
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3183,7 +3190,7 @@ function useNotifications(options) {
|
|
|
3183
3190
|
},
|
|
3184
3191
|
[]
|
|
3185
3192
|
);
|
|
3186
|
-
const getBadgeCount = (0,
|
|
3193
|
+
const getBadgeCount = (0, import_react5.useCallback)(() => __async(null, null, function* () {
|
|
3187
3194
|
var _a2;
|
|
3188
3195
|
const expo = expoRef.current;
|
|
3189
3196
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -3191,7 +3198,7 @@ function useNotifications(options) {
|
|
|
3191
3198
|
}
|
|
3192
3199
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
3193
3200
|
}), []);
|
|
3194
|
-
const setBadgeCount = (0,
|
|
3201
|
+
const setBadgeCount = (0, import_react5.useCallback)((count) => __async(null, null, function* () {
|
|
3195
3202
|
const expo = expoRef.current;
|
|
3196
3203
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
3197
3204
|
return;
|
|
@@ -3199,7 +3206,7 @@ function useNotifications(options) {
|
|
|
3199
3206
|
yield expo.setBadgeCountAsync(count);
|
|
3200
3207
|
}), []);
|
|
3201
3208
|
const autoRegister = options.autoRegister !== false;
|
|
3202
|
-
(0,
|
|
3209
|
+
(0, import_react5.useEffect)(() => {
|
|
3203
3210
|
if (!autoRegister) {
|
|
3204
3211
|
return;
|
|
3205
3212
|
}
|
|
@@ -3236,7 +3243,7 @@ function useNotificationsActions() {
|
|
|
3236
3243
|
const sdkContext = useTruthSdkContext();
|
|
3237
3244
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
3238
3245
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
3239
|
-
const post = (0,
|
|
3246
|
+
const post = (0, import_react5.useCallback)(
|
|
3240
3247
|
(path, body) => __async(null, null, function* () {
|
|
3241
3248
|
if (!apiBaseUrl || !apiKey) {
|
|
3242
3249
|
throw new Error(
|
|
@@ -3262,7 +3269,7 @@ function useNotificationsActions() {
|
|
|
3262
3269
|
}),
|
|
3263
3270
|
[apiBaseUrl, apiKey]
|
|
3264
3271
|
);
|
|
3265
|
-
const get = (0,
|
|
3272
|
+
const get = (0, import_react5.useCallback)(
|
|
3266
3273
|
(path) => __async(null, null, function* () {
|
|
3267
3274
|
const res = yield fetch(`${apiBaseUrl}/api${path}`, {
|
|
3268
3275
|
method: "GET",
|
|
@@ -3278,21 +3285,21 @@ function useNotificationsActions() {
|
|
|
3278
3285
|
}),
|
|
3279
3286
|
[apiBaseUrl, apiKey]
|
|
3280
3287
|
);
|
|
3281
|
-
const send = (0,
|
|
3288
|
+
const send = (0, import_react5.useCallback)(
|
|
3282
3289
|
(input) => post("/notifications/send", input),
|
|
3283
3290
|
[post]
|
|
3284
3291
|
);
|
|
3285
|
-
const schedule = (0,
|
|
3292
|
+
const schedule = (0, import_react5.useCallback)(
|
|
3286
3293
|
(input) => post("/notifications/schedule", input),
|
|
3287
3294
|
[post]
|
|
3288
3295
|
);
|
|
3289
|
-
const getPreferences = (0,
|
|
3296
|
+
const getPreferences = (0, import_react5.useCallback)(
|
|
3290
3297
|
(userId) => get(
|
|
3291
3298
|
`/notifications/preferences/${encodeURIComponent(userId)}`
|
|
3292
3299
|
),
|
|
3293
3300
|
[get]
|
|
3294
3301
|
);
|
|
3295
|
-
const updatePreferences = (0,
|
|
3302
|
+
const updatePreferences = (0, import_react5.useCallback)(
|
|
3296
3303
|
(userId, prefs) => post(
|
|
3297
3304
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3298
3305
|
prefs
|
|
@@ -3375,12 +3382,12 @@ function usePatientSearch(options) {
|
|
|
3375
3382
|
|
|
3376
3383
|
// src/react/patients-bulk.ts
|
|
3377
3384
|
var import_server8 = require("convex/server");
|
|
3378
|
-
var
|
|
3385
|
+
var import_react6 = require("react");
|
|
3379
3386
|
var patientsGetByIdsRef = (0, import_server8.makeFunctionReference)("patients:getByIds");
|
|
3380
3387
|
var patientsGetByPhonesRef = (0, import_server8.makeFunctionReference)("patients:getByPhones");
|
|
3381
3388
|
var SKIP5 = "skip";
|
|
3382
3389
|
function usePatientsByIds(ids) {
|
|
3383
|
-
const stableIds = (0,
|
|
3390
|
+
const stableIds = (0, import_react6.useMemo)(() => {
|
|
3384
3391
|
const arr = ids != null ? ids : [];
|
|
3385
3392
|
return [...new Set(arr)].sort();
|
|
3386
3393
|
}, [ids]);
|
|
@@ -3389,7 +3396,7 @@ function usePatientsByIds(ids) {
|
|
|
3389
3396
|
patientsGetByIdsRef,
|
|
3390
3397
|
skipped ? SKIP5 : { ids: stableIds }
|
|
3391
3398
|
);
|
|
3392
|
-
const mapped = (0,
|
|
3399
|
+
const mapped = (0, import_react6.useMemo)(() => {
|
|
3393
3400
|
if (result === void 0) {
|
|
3394
3401
|
return void 0;
|
|
3395
3402
|
}
|
|
@@ -3411,7 +3418,7 @@ function usePatientsByIds(ids) {
|
|
|
3411
3418
|
};
|
|
3412
3419
|
}
|
|
3413
3420
|
function usePatientsByPhones(phones) {
|
|
3414
|
-
const stableDigits = (0,
|
|
3421
|
+
const stableDigits = (0, import_react6.useMemo)(() => {
|
|
3415
3422
|
const arr = phones != null ? phones : [];
|
|
3416
3423
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3417
3424
|
return [...new Set(digits)].sort();
|
|
@@ -3421,7 +3428,7 @@ function usePatientsByPhones(phones) {
|
|
|
3421
3428
|
patientsGetByPhonesRef,
|
|
3422
3429
|
skipped ? SKIP5 : { phoneDigits: stableDigits }
|
|
3423
3430
|
);
|
|
3424
|
-
const mapped = (0,
|
|
3431
|
+
const mapped = (0, import_react6.useMemo)(() => {
|
|
3425
3432
|
if (result === void 0) {
|
|
3426
3433
|
return void 0;
|
|
3427
3434
|
}
|
|
@@ -3460,23 +3467,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3460
3467
|
}
|
|
3461
3468
|
|
|
3462
3469
|
// src/react/tasks.ts
|
|
3463
|
-
var
|
|
3470
|
+
var import_react7 = require("convex/react");
|
|
3464
3471
|
var import_server10 = require("convex/server");
|
|
3465
|
-
var
|
|
3472
|
+
var import_react8 = require("react");
|
|
3466
3473
|
var conversationTasksMarkSeenRef = (0, import_server10.makeFunctionReference)("conversationTasks:markSeen");
|
|
3467
3474
|
function useConversationTaskMarkSeen() {
|
|
3468
|
-
const mutate = (0,
|
|
3475
|
+
const mutate = (0, import_react7.useMutation)(
|
|
3469
3476
|
conversationTasksMarkSeenRef
|
|
3470
3477
|
);
|
|
3471
|
-
return (0,
|
|
3478
|
+
return (0, import_react8.useCallback)(
|
|
3472
3479
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3473
3480
|
[mutate]
|
|
3474
3481
|
);
|
|
3475
3482
|
}
|
|
3476
3483
|
|
|
3477
3484
|
// src/react/tracking.ts
|
|
3478
|
-
var
|
|
3479
|
-
var TruthTrackingContext = (0,
|
|
3485
|
+
var import_react9 = require("react");
|
|
3486
|
+
var TruthTrackingContext = (0, import_react9.createContext)(
|
|
3480
3487
|
null
|
|
3481
3488
|
);
|
|
3482
3489
|
function TruthTrackingProvider({
|
|
@@ -3489,7 +3496,7 @@ function TruthTrackingProvider({
|
|
|
3489
3496
|
}) {
|
|
3490
3497
|
var _a, _b;
|
|
3491
3498
|
const resolvedApiKey = (_b = apiKey != null ? apiKey : typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.EXPO_PUBLIC_TRUTH_API_KEY : void 0) != null ? _b : "";
|
|
3492
|
-
const value = (0,
|
|
3499
|
+
const value = (0, import_react9.useMemo)(() => {
|
|
3493
3500
|
const tracker = new Tracker({
|
|
3494
3501
|
apiKey: resolvedApiKey,
|
|
3495
3502
|
environment,
|
|
@@ -3508,10 +3515,10 @@ function TruthTrackingProvider({
|
|
|
3508
3515
|
}
|
|
3509
3516
|
};
|
|
3510
3517
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3511
|
-
return (0,
|
|
3518
|
+
return (0, import_react9.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3512
3519
|
}
|
|
3513
3520
|
function useTruth() {
|
|
3514
|
-
const ctx = (0,
|
|
3521
|
+
const ctx = (0, import_react9.useContext)(TruthTrackingContext);
|
|
3515
3522
|
if (!ctx) {
|
|
3516
3523
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3517
3524
|
}
|
|
@@ -3539,15 +3546,15 @@ function useUserSettings(userId) {
|
|
|
3539
3546
|
}
|
|
3540
3547
|
|
|
3541
3548
|
// src/react/users.ts
|
|
3542
|
-
var
|
|
3549
|
+
var import_react10 = require("react");
|
|
3543
3550
|
function useUserSync(input) {
|
|
3544
3551
|
var _a, _b, _c, _d;
|
|
3545
3552
|
const sdkContext = useTruthSdkContext();
|
|
3546
3553
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3547
3554
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3548
|
-
const [status, setStatus] = (0,
|
|
3549
|
-
const [error, setError] = (0,
|
|
3550
|
-
const lastKeyRef = (0,
|
|
3555
|
+
const [status, setStatus] = (0, import_react10.useState)("idle");
|
|
3556
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
3557
|
+
const lastKeyRef = (0, import_react10.useRef)(null);
|
|
3551
3558
|
const sync = () => __async(null, null, function* () {
|
|
3552
3559
|
if (!input.userId) {
|
|
3553
3560
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3590,7 +3597,7 @@ function useUserSync(input) {
|
|
|
3590
3597
|
return { ok: false, reason: message };
|
|
3591
3598
|
}
|
|
3592
3599
|
});
|
|
3593
|
-
(0,
|
|
3600
|
+
(0, import_react10.useEffect)(() => {
|
|
3594
3601
|
var _a2, _b2, _c2, _d2, _e;
|
|
3595
3602
|
if (!input.userId) {
|
|
3596
3603
|
return;
|
|
@@ -3629,13 +3636,13 @@ function useUserSync(input) {
|
|
|
3629
3636
|
}
|
|
3630
3637
|
|
|
3631
3638
|
// src/react/voicemail.ts
|
|
3632
|
-
var
|
|
3639
|
+
var import_react11 = require("react");
|
|
3633
3640
|
function useVoicemailUrl(client) {
|
|
3634
|
-
const [url, setUrl] = (0,
|
|
3635
|
-
const [isLoading, setIsLoading] = (0,
|
|
3636
|
-
const [error, setError] = (0,
|
|
3637
|
-
const inFlightRef = (0,
|
|
3638
|
-
const fetchUrl = (0,
|
|
3641
|
+
const [url, setUrl] = (0, import_react11.useState)(null);
|
|
3642
|
+
const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
|
|
3643
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
3644
|
+
const inFlightRef = (0, import_react11.useRef)(false);
|
|
3645
|
+
const fetchUrl = (0, import_react11.useCallback)(
|
|
3639
3646
|
(voicemailLink) => __async(null, null, function* () {
|
|
3640
3647
|
if (inFlightRef.current) {
|
|
3641
3648
|
return null;
|