@hipnation-truth/sdk 0.26.3 → 0.26.4
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/react.d.ts +5 -0
- package/dist/react.js +71 -66
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -2784,6 +2784,11 @@ interface TruthSdkContextValue {
|
|
|
2784
2784
|
* (legacy behavior).
|
|
2785
2785
|
*/
|
|
2786
2786
|
authGated: boolean;
|
|
2787
|
+
/**
|
|
2788
|
+
* Whether Convex currently considers the caller authenticated (driven
|
|
2789
|
+
* by `setAuth`'s onChange). Only meaningful when `authGated` is true.
|
|
2790
|
+
*/
|
|
2791
|
+
authReady: boolean;
|
|
2787
2792
|
}
|
|
2788
2793
|
/**
|
|
2789
2794
|
* Read the Truth REST API base URL + API key + shared client from
|
package/dist/react.js
CHANGED
|
@@ -122,16 +122,13 @@ __export(react_exports, {
|
|
|
122
122
|
module.exports = __toCommonJS(react_exports);
|
|
123
123
|
|
|
124
124
|
// src/react/calls.ts
|
|
125
|
-
var
|
|
125
|
+
var import_react3 = require("convex/react");
|
|
126
126
|
var import_server2 = require("convex/server");
|
|
127
127
|
|
|
128
128
|
// src/react/offline/use-persistent-query.ts
|
|
129
129
|
var import_react_query3 = require("@convex-dev/react-query");
|
|
130
130
|
var import_react_query4 = require("@tanstack/react-query");
|
|
131
131
|
|
|
132
|
-
// src/react/queries-ready.ts
|
|
133
|
-
var import_react3 = require("convex/react");
|
|
134
|
-
|
|
135
132
|
// src/react/provider.ts
|
|
136
133
|
var import_react_query = require("@convex-dev/react-query");
|
|
137
134
|
var import_react_query2 = require("@tanstack/react-query");
|
|
@@ -2305,14 +2302,19 @@ function TruthProvider({
|
|
|
2305
2302
|
}) : void 0,
|
|
2306
2303
|
[hasAuthFetcher]
|
|
2307
2304
|
);
|
|
2305
|
+
const [convexAuthed, setConvexAuthed] = (0, import_react2.useState)(false);
|
|
2308
2306
|
(0, import_react2.useEffect)(() => {
|
|
2309
2307
|
if (stableGetAuthToken) {
|
|
2310
|
-
convexClient.setAuth(
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
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
|
+
);
|
|
2314
2315
|
} else {
|
|
2315
2316
|
convexClient.clearAuth();
|
|
2317
|
+
setConvexAuthed(false);
|
|
2316
2318
|
}
|
|
2317
2319
|
}, [convexClient, stableGetAuthToken]);
|
|
2318
2320
|
const convexQueryClient = (0, import_react2.useMemo)(
|
|
@@ -2388,7 +2390,8 @@ function TruthProvider({
|
|
|
2388
2390
|
client: truthClient,
|
|
2389
2391
|
offlineStore,
|
|
2390
2392
|
offlineEnabled,
|
|
2391
|
-
authGated: hasAuthFetcher
|
|
2393
|
+
authGated: hasAuthFetcher,
|
|
2394
|
+
authReady: convexAuthed
|
|
2392
2395
|
}),
|
|
2393
2396
|
[
|
|
2394
2397
|
resolvedApiBaseUrl,
|
|
@@ -2397,7 +2400,8 @@ function TruthProvider({
|
|
|
2397
2400
|
truthClient,
|
|
2398
2401
|
offlineStore,
|
|
2399
2402
|
offlineEnabled,
|
|
2400
|
-
hasAuthFetcher
|
|
2403
|
+
hasAuthFetcher,
|
|
2404
|
+
convexAuthed
|
|
2401
2405
|
]
|
|
2402
2406
|
);
|
|
2403
2407
|
const convexTree = (0, import_react2.createElement)(
|
|
@@ -2428,10 +2432,11 @@ function TruthProvider({
|
|
|
2428
2432
|
|
|
2429
2433
|
// src/react/queries-ready.ts
|
|
2430
2434
|
function useConvexQueriesReady() {
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
+
const ctx = useTruthSdkContext();
|
|
2436
|
+
if (!(ctx == null ? void 0 : ctx.authGated)) {
|
|
2437
|
+
return true;
|
|
2438
|
+
}
|
|
2439
|
+
return ctx.authReady;
|
|
2435
2440
|
}
|
|
2436
2441
|
|
|
2437
2442
|
// src/react/offline/use-persistent-query.ts
|
|
@@ -2490,7 +2495,7 @@ function toResult(value, skipped) {
|
|
|
2490
2495
|
}
|
|
2491
2496
|
function useActiveCalls(options) {
|
|
2492
2497
|
const ready = useConvexQueriesReady();
|
|
2493
|
-
const result = (0,
|
|
2498
|
+
const result = (0, import_react3.useQuery)(listActiveRef, ready ? options != null ? options : {} : "skip");
|
|
2494
2499
|
return toResult(result, false);
|
|
2495
2500
|
}
|
|
2496
2501
|
function useDialpadCallsForConversation(conversationId, options) {
|
|
@@ -2542,7 +2547,7 @@ function useConversationById(id) {
|
|
|
2542
2547
|
|
|
2543
2548
|
// src/react/conversations.ts
|
|
2544
2549
|
var import_server4 = require("convex/server");
|
|
2545
|
-
var
|
|
2550
|
+
var import_react4 = require("react");
|
|
2546
2551
|
var conversationsListForUserRef = (0, import_server4.makeFunctionReference)("conversations:listForUser");
|
|
2547
2552
|
var conversationsSearchForUserRef = (0, import_server4.makeFunctionReference)("conversations:searchForUser");
|
|
2548
2553
|
var conversationsGetUnreadTotalForUserRef = (0, import_server4.makeFunctionReference)("conversations:getUnreadTotalForUser");
|
|
@@ -2629,7 +2634,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
2629
2634
|
}
|
|
2630
2635
|
function useMemoizedPhones(phones) {
|
|
2631
2636
|
const key = phones ? [...phones].sort().join("|") : "";
|
|
2632
|
-
return (0,
|
|
2637
|
+
return (0, import_react4.useMemo)(
|
|
2633
2638
|
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
2634
2639
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2635
2640
|
[key]
|
|
@@ -2677,7 +2682,7 @@ function useConversationTasksByPhonePair(phonePair) {
|
|
|
2677
2682
|
}
|
|
2678
2683
|
|
|
2679
2684
|
// src/react/hooks.ts
|
|
2680
|
-
var
|
|
2685
|
+
var import_react5 = require("react");
|
|
2681
2686
|
var import_server5 = require("convex/server");
|
|
2682
2687
|
var patientsListRef = (0, import_server5.makeFunctionReference)("patients:list");
|
|
2683
2688
|
var patientsGetRef = (0, import_server5.makeFunctionReference)("patients:get");
|
|
@@ -2755,7 +2760,7 @@ function usePatientMedical(elationId, options) {
|
|
|
2755
2760
|
appointmentsByPatientRef,
|
|
2756
2761
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2757
2762
|
);
|
|
2758
|
-
(0,
|
|
2763
|
+
(0, import_react5.useEffect)(() => {
|
|
2759
2764
|
if (elationId === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
2760
2765
|
return;
|
|
2761
2766
|
}
|
|
@@ -2794,7 +2799,7 @@ function usePatientBasic(input, options) {
|
|
|
2794
2799
|
hintPatientByIdRef,
|
|
2795
2800
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
2796
2801
|
);
|
|
2797
|
-
(0,
|
|
2802
|
+
(0, import_react5.useEffect)(() => {
|
|
2798
2803
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2799
2804
|
return;
|
|
2800
2805
|
}
|
|
@@ -2847,7 +2852,7 @@ function usePatientPhoto(elationId, options) {
|
|
|
2847
2852
|
patientPhotoByIdRef,
|
|
2848
2853
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2849
2854
|
);
|
|
2850
|
-
(0,
|
|
2855
|
+
(0, import_react5.useEffect)(() => {
|
|
2851
2856
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2852
2857
|
return;
|
|
2853
2858
|
}
|
|
@@ -2892,7 +2897,7 @@ function useConversationMessages(input, options) {
|
|
|
2892
2897
|
}
|
|
2893
2898
|
|
|
2894
2899
|
// src/react/notifications.ts
|
|
2895
|
-
var
|
|
2900
|
+
var import_react6 = require("react");
|
|
2896
2901
|
function loadExpo() {
|
|
2897
2902
|
return __async(this, null, function* () {
|
|
2898
2903
|
try {
|
|
@@ -2907,12 +2912,12 @@ function useNotifications(options) {
|
|
|
2907
2912
|
const sdkContext = useTruthSdkContext();
|
|
2908
2913
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
2909
2914
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
2910
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
2911
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
2912
|
-
const expoRef = (0,
|
|
2913
|
-
const isWebRef = (0,
|
|
2914
|
-
const vapidKeyRef = (0,
|
|
2915
|
-
(0,
|
|
2915
|
+
const [permissionStatus, setPermissionStatus] = (0, import_react6.useState)("unknown");
|
|
2916
|
+
const [devicePushToken, setDevicePushToken] = (0, import_react6.useState)(null);
|
|
2917
|
+
const expoRef = (0, import_react6.useRef)(null);
|
|
2918
|
+
const isWebRef = (0, import_react6.useRef)(false);
|
|
2919
|
+
const vapidKeyRef = (0, import_react6.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
|
|
2920
|
+
(0, import_react6.useEffect)(() => {
|
|
2916
2921
|
let mounted = true;
|
|
2917
2922
|
void (() => __async(null, null, function* () {
|
|
2918
2923
|
var _a2;
|
|
@@ -2968,7 +2973,7 @@ function useNotifications(options) {
|
|
|
2968
2973
|
mounted = false;
|
|
2969
2974
|
};
|
|
2970
2975
|
}, [apiBaseUrl, apiKey]);
|
|
2971
|
-
const register = (0,
|
|
2976
|
+
const register = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
2972
2977
|
var _a2, _b2;
|
|
2973
2978
|
if (!options.userId) {
|
|
2974
2979
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3081,7 +3086,7 @@ function useNotifications(options) {
|
|
|
3081
3086
|
options.appVersion,
|
|
3082
3087
|
options.serviceWorkerPath
|
|
3083
3088
|
]);
|
|
3084
|
-
const unregister = (0,
|
|
3089
|
+
const unregister = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
3085
3090
|
if (!devicePushToken) {
|
|
3086
3091
|
return;
|
|
3087
3092
|
}
|
|
@@ -3096,7 +3101,7 @@ function useNotifications(options) {
|
|
|
3096
3101
|
});
|
|
3097
3102
|
setDevicePushToken(null);
|
|
3098
3103
|
}), [apiBaseUrl, apiKey, devicePushToken]);
|
|
3099
|
-
const addReceivedListener = (0,
|
|
3104
|
+
const addReceivedListener = (0, import_react6.useCallback)(
|
|
3100
3105
|
(listener) => {
|
|
3101
3106
|
if (isWebRef.current) {
|
|
3102
3107
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3125,7 +3130,7 @@ function useNotifications(options) {
|
|
|
3125
3130
|
},
|
|
3126
3131
|
[]
|
|
3127
3132
|
);
|
|
3128
|
-
const addResponseListener = (0,
|
|
3133
|
+
const addResponseListener = (0, import_react6.useCallback)(
|
|
3129
3134
|
(listener) => {
|
|
3130
3135
|
if (isWebRef.current) {
|
|
3131
3136
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3154,7 +3159,7 @@ function useNotifications(options) {
|
|
|
3154
3159
|
},
|
|
3155
3160
|
[]
|
|
3156
3161
|
);
|
|
3157
|
-
const getBadgeCount = (0,
|
|
3162
|
+
const getBadgeCount = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
3158
3163
|
var _a2;
|
|
3159
3164
|
const expo = expoRef.current;
|
|
3160
3165
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -3162,7 +3167,7 @@ function useNotifications(options) {
|
|
|
3162
3167
|
}
|
|
3163
3168
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
3164
3169
|
}), []);
|
|
3165
|
-
const setBadgeCount = (0,
|
|
3170
|
+
const setBadgeCount = (0, import_react6.useCallback)((count) => __async(null, null, function* () {
|
|
3166
3171
|
const expo = expoRef.current;
|
|
3167
3172
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
3168
3173
|
return;
|
|
@@ -3170,7 +3175,7 @@ function useNotifications(options) {
|
|
|
3170
3175
|
yield expo.setBadgeCountAsync(count);
|
|
3171
3176
|
}), []);
|
|
3172
3177
|
const autoRegister = options.autoRegister !== false;
|
|
3173
|
-
(0,
|
|
3178
|
+
(0, import_react6.useEffect)(() => {
|
|
3174
3179
|
if (!autoRegister) {
|
|
3175
3180
|
return;
|
|
3176
3181
|
}
|
|
@@ -3207,7 +3212,7 @@ function useNotificationsActions() {
|
|
|
3207
3212
|
const sdkContext = useTruthSdkContext();
|
|
3208
3213
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
3209
3214
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
3210
|
-
const post = (0,
|
|
3215
|
+
const post = (0, import_react6.useCallback)(
|
|
3211
3216
|
(path, body) => __async(null, null, function* () {
|
|
3212
3217
|
if (!apiBaseUrl || !apiKey) {
|
|
3213
3218
|
throw new Error(
|
|
@@ -3233,7 +3238,7 @@ function useNotificationsActions() {
|
|
|
3233
3238
|
}),
|
|
3234
3239
|
[apiBaseUrl, apiKey]
|
|
3235
3240
|
);
|
|
3236
|
-
const get = (0,
|
|
3241
|
+
const get = (0, import_react6.useCallback)(
|
|
3237
3242
|
(path) => __async(null, null, function* () {
|
|
3238
3243
|
const res = yield fetch(`${apiBaseUrl}/api${path}`, {
|
|
3239
3244
|
method: "GET",
|
|
@@ -3249,21 +3254,21 @@ function useNotificationsActions() {
|
|
|
3249
3254
|
}),
|
|
3250
3255
|
[apiBaseUrl, apiKey]
|
|
3251
3256
|
);
|
|
3252
|
-
const send = (0,
|
|
3257
|
+
const send = (0, import_react6.useCallback)(
|
|
3253
3258
|
(input) => post("/notifications/send", input),
|
|
3254
3259
|
[post]
|
|
3255
3260
|
);
|
|
3256
|
-
const schedule = (0,
|
|
3261
|
+
const schedule = (0, import_react6.useCallback)(
|
|
3257
3262
|
(input) => post("/notifications/schedule", input),
|
|
3258
3263
|
[post]
|
|
3259
3264
|
);
|
|
3260
|
-
const getPreferences = (0,
|
|
3265
|
+
const getPreferences = (0, import_react6.useCallback)(
|
|
3261
3266
|
(userId) => get(
|
|
3262
3267
|
`/notifications/preferences/${encodeURIComponent(userId)}`
|
|
3263
3268
|
),
|
|
3264
3269
|
[get]
|
|
3265
3270
|
);
|
|
3266
|
-
const updatePreferences = (0,
|
|
3271
|
+
const updatePreferences = (0, import_react6.useCallback)(
|
|
3267
3272
|
(userId, prefs) => post(
|
|
3268
3273
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3269
3274
|
prefs
|
|
@@ -3346,12 +3351,12 @@ function usePatientSearch(options) {
|
|
|
3346
3351
|
|
|
3347
3352
|
// src/react/patients-bulk.ts
|
|
3348
3353
|
var import_server8 = require("convex/server");
|
|
3349
|
-
var
|
|
3354
|
+
var import_react7 = require("react");
|
|
3350
3355
|
var patientsGetByIdsRef = (0, import_server8.makeFunctionReference)("patients:getByIds");
|
|
3351
3356
|
var patientsGetByPhonesRef = (0, import_server8.makeFunctionReference)("patients:getByPhones");
|
|
3352
3357
|
var SKIP5 = "skip";
|
|
3353
3358
|
function usePatientsByIds(ids) {
|
|
3354
|
-
const stableIds = (0,
|
|
3359
|
+
const stableIds = (0, import_react7.useMemo)(() => {
|
|
3355
3360
|
const arr = ids != null ? ids : [];
|
|
3356
3361
|
return [...new Set(arr)].sort();
|
|
3357
3362
|
}, [ids]);
|
|
@@ -3360,7 +3365,7 @@ function usePatientsByIds(ids) {
|
|
|
3360
3365
|
patientsGetByIdsRef,
|
|
3361
3366
|
skipped ? SKIP5 : { ids: stableIds }
|
|
3362
3367
|
);
|
|
3363
|
-
const mapped = (0,
|
|
3368
|
+
const mapped = (0, import_react7.useMemo)(() => {
|
|
3364
3369
|
if (result === void 0) {
|
|
3365
3370
|
return void 0;
|
|
3366
3371
|
}
|
|
@@ -3382,7 +3387,7 @@ function usePatientsByIds(ids) {
|
|
|
3382
3387
|
};
|
|
3383
3388
|
}
|
|
3384
3389
|
function usePatientsByPhones(phones) {
|
|
3385
|
-
const stableDigits = (0,
|
|
3390
|
+
const stableDigits = (0, import_react7.useMemo)(() => {
|
|
3386
3391
|
const arr = phones != null ? phones : [];
|
|
3387
3392
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3388
3393
|
return [...new Set(digits)].sort();
|
|
@@ -3392,7 +3397,7 @@ function usePatientsByPhones(phones) {
|
|
|
3392
3397
|
patientsGetByPhonesRef,
|
|
3393
3398
|
skipped ? SKIP5 : { phoneDigits: stableDigits }
|
|
3394
3399
|
);
|
|
3395
|
-
const mapped = (0,
|
|
3400
|
+
const mapped = (0, import_react7.useMemo)(() => {
|
|
3396
3401
|
if (result === void 0) {
|
|
3397
3402
|
return void 0;
|
|
3398
3403
|
}
|
|
@@ -3431,23 +3436,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3431
3436
|
}
|
|
3432
3437
|
|
|
3433
3438
|
// src/react/tasks.ts
|
|
3434
|
-
var
|
|
3439
|
+
var import_react8 = require("convex/react");
|
|
3435
3440
|
var import_server10 = require("convex/server");
|
|
3436
|
-
var
|
|
3441
|
+
var import_react9 = require("react");
|
|
3437
3442
|
var conversationTasksMarkSeenRef = (0, import_server10.makeFunctionReference)("conversationTasks:markSeen");
|
|
3438
3443
|
function useConversationTaskMarkSeen() {
|
|
3439
|
-
const mutate = (0,
|
|
3444
|
+
const mutate = (0, import_react8.useMutation)(
|
|
3440
3445
|
conversationTasksMarkSeenRef
|
|
3441
3446
|
);
|
|
3442
|
-
return (0,
|
|
3447
|
+
return (0, import_react9.useCallback)(
|
|
3443
3448
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3444
3449
|
[mutate]
|
|
3445
3450
|
);
|
|
3446
3451
|
}
|
|
3447
3452
|
|
|
3448
3453
|
// src/react/tracking.ts
|
|
3449
|
-
var
|
|
3450
|
-
var TruthTrackingContext = (0,
|
|
3454
|
+
var import_react10 = require("react");
|
|
3455
|
+
var TruthTrackingContext = (0, import_react10.createContext)(
|
|
3451
3456
|
null
|
|
3452
3457
|
);
|
|
3453
3458
|
function TruthTrackingProvider({
|
|
@@ -3460,7 +3465,7 @@ function TruthTrackingProvider({
|
|
|
3460
3465
|
}) {
|
|
3461
3466
|
var _a, _b;
|
|
3462
3467
|
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 : "";
|
|
3463
|
-
const value = (0,
|
|
3468
|
+
const value = (0, import_react10.useMemo)(() => {
|
|
3464
3469
|
const tracker = new Tracker({
|
|
3465
3470
|
apiKey: resolvedApiKey,
|
|
3466
3471
|
environment,
|
|
@@ -3479,10 +3484,10 @@ function TruthTrackingProvider({
|
|
|
3479
3484
|
}
|
|
3480
3485
|
};
|
|
3481
3486
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3482
|
-
return (0,
|
|
3487
|
+
return (0, import_react10.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3483
3488
|
}
|
|
3484
3489
|
function useTruth() {
|
|
3485
|
-
const ctx = (0,
|
|
3490
|
+
const ctx = (0, import_react10.useContext)(TruthTrackingContext);
|
|
3486
3491
|
if (!ctx) {
|
|
3487
3492
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3488
3493
|
}
|
|
@@ -3510,15 +3515,15 @@ function useUserSettings(userId) {
|
|
|
3510
3515
|
}
|
|
3511
3516
|
|
|
3512
3517
|
// src/react/users.ts
|
|
3513
|
-
var
|
|
3518
|
+
var import_react11 = require("react");
|
|
3514
3519
|
function useUserSync(input) {
|
|
3515
3520
|
var _a, _b, _c, _d;
|
|
3516
3521
|
const sdkContext = useTruthSdkContext();
|
|
3517
3522
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3518
3523
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3519
|
-
const [status, setStatus] = (0,
|
|
3520
|
-
const [error, setError] = (0,
|
|
3521
|
-
const lastKeyRef = (0,
|
|
3524
|
+
const [status, setStatus] = (0, import_react11.useState)("idle");
|
|
3525
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
3526
|
+
const lastKeyRef = (0, import_react11.useRef)(null);
|
|
3522
3527
|
const sync = () => __async(null, null, function* () {
|
|
3523
3528
|
if (!input.userId) {
|
|
3524
3529
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3561,7 +3566,7 @@ function useUserSync(input) {
|
|
|
3561
3566
|
return { ok: false, reason: message };
|
|
3562
3567
|
}
|
|
3563
3568
|
});
|
|
3564
|
-
(0,
|
|
3569
|
+
(0, import_react11.useEffect)(() => {
|
|
3565
3570
|
var _a2, _b2, _c2, _d2, _e;
|
|
3566
3571
|
if (!input.userId) {
|
|
3567
3572
|
return;
|
|
@@ -3600,13 +3605,13 @@ function useUserSync(input) {
|
|
|
3600
3605
|
}
|
|
3601
3606
|
|
|
3602
3607
|
// src/react/voicemail.ts
|
|
3603
|
-
var
|
|
3608
|
+
var import_react12 = require("react");
|
|
3604
3609
|
function useVoicemailUrl(client) {
|
|
3605
|
-
const [url, setUrl] = (0,
|
|
3606
|
-
const [isLoading, setIsLoading] = (0,
|
|
3607
|
-
const [error, setError] = (0,
|
|
3608
|
-
const inFlightRef = (0,
|
|
3609
|
-
const fetchUrl = (0,
|
|
3610
|
+
const [url, setUrl] = (0, import_react12.useState)(null);
|
|
3611
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
3612
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
3613
|
+
const inFlightRef = (0, import_react12.useRef)(false);
|
|
3614
|
+
const fetchUrl = (0, import_react12.useCallback)(
|
|
3610
3615
|
(voicemailLink) => __async(null, null, function* () {
|
|
3611
3616
|
if (inFlightRef.current) {
|
|
3612
3617
|
return null;
|