@hipnation-truth/sdk 0.26.8 → 0.26.9
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 +6 -5
- package/dist/react.js +95 -80
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -2779,13 +2779,14 @@ interface TruthSdkContextValue {
|
|
|
2779
2779
|
* signed-out render throws UNAUTHENTICATED and blanks the app. When no
|
|
2780
2780
|
* fetcher is configured this stays false and queries run unconditionally
|
|
2781
2781
|
* (legacy behavior).
|
|
2782
|
+
*
|
|
2783
|
+
* The "is the caller authenticated yet" half of the gate is no longer
|
|
2784
|
+
* tracked here: `<TruthProvider>` now mounts `ConvexProviderWithAuth`,
|
|
2785
|
+
* so `useConvexQueriesReady()` reads Convex's own server-acknowledged
|
|
2786
|
+
* `useConvexAuth().isAuthenticated`. `authGated` only answers "should we
|
|
2787
|
+
* gate at all", which still depends on whether a fetcher was supplied.
|
|
2782
2788
|
*/
|
|
2783
2789
|
authGated: boolean;
|
|
2784
|
-
/**
|
|
2785
|
-
* Whether Convex currently considers the caller authenticated (driven
|
|
2786
|
-
* by `setAuth`'s onChange). Only meaningful when `authGated` is true.
|
|
2787
|
-
*/
|
|
2788
|
-
authReady: boolean;
|
|
2789
2790
|
}
|
|
2790
2791
|
/**
|
|
2791
2792
|
* Read the Truth REST API base URL + API key + shared client from
|
package/dist/react.js
CHANGED
|
@@ -128,6 +128,9 @@ var import_server2 = require("convex/server");
|
|
|
128
128
|
var import_react_query3 = require("@convex-dev/react-query");
|
|
129
129
|
var import_react_query4 = require("@tanstack/react-query");
|
|
130
130
|
|
|
131
|
+
// src/react/queries-ready.ts
|
|
132
|
+
var import_react3 = require("convex/react");
|
|
133
|
+
|
|
131
134
|
// src/react/provider.ts
|
|
132
135
|
var import_react_query = require("@convex-dev/react-query");
|
|
133
136
|
var import_react_query2 = require("@tanstack/react-query");
|
|
@@ -2301,29 +2304,42 @@ function TruthProvider({
|
|
|
2301
2304
|
}) : void 0,
|
|
2302
2305
|
[hasAuthFetcher]
|
|
2303
2306
|
);
|
|
2304
|
-
const [
|
|
2307
|
+
const [tokenAttempted, setTokenAttempted] = (0, import_react2.useState)(false);
|
|
2305
2308
|
(0, import_react2.useEffect)(() => {
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2309
|
+
setTokenAttempted(false);
|
|
2310
|
+
}, [stableGetAuthToken]);
|
|
2311
|
+
const fetchAccessToken = (0, import_react2.useCallback)(
|
|
2312
|
+
(_0) => __async(null, [_0], function* ({
|
|
2313
|
+
forceRefreshToken
|
|
2314
|
+
}) {
|
|
2315
|
+
var _a2;
|
|
2316
|
+
const fetcher = stableGetAuthToken;
|
|
2317
|
+
if (!fetcher) {
|
|
2318
|
+
setTokenAttempted(true);
|
|
2319
|
+
return null;
|
|
2320
|
+
}
|
|
2321
|
+
let token = null;
|
|
2312
2322
|
for (let attempt = 0; attempt < 6; attempt++) {
|
|
2313
2323
|
try {
|
|
2314
|
-
|
|
2315
|
-
if (token)
|
|
2324
|
+
token = (_a2 = yield fetcher({ forceRefreshToken })) != null ? _a2 : null;
|
|
2325
|
+
if (token) break;
|
|
2316
2326
|
} catch (e) {
|
|
2317
2327
|
}
|
|
2318
2328
|
yield new Promise((resolve) => setTimeout(resolve, 200 + attempt * 150));
|
|
2319
2329
|
}
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2330
|
+
setTokenAttempted(true);
|
|
2331
|
+
return token;
|
|
2332
|
+
}),
|
|
2333
|
+
[stableGetAuthToken]
|
|
2334
|
+
);
|
|
2335
|
+
const useConvexAuthAdapter = (0, import_react2.useCallback)(
|
|
2336
|
+
() => ({
|
|
2337
|
+
isLoading: hasAuthFetcher && !tokenAttempted,
|
|
2338
|
+
isAuthenticated: hasAuthFetcher,
|
|
2339
|
+
fetchAccessToken
|
|
2340
|
+
}),
|
|
2341
|
+
[hasAuthFetcher, tokenAttempted, fetchAccessToken]
|
|
2342
|
+
);
|
|
2327
2343
|
const convexQueryClient = (0, import_react2.useMemo)(
|
|
2328
2344
|
() => new import_react_query.ConvexQueryClient(convexClient),
|
|
2329
2345
|
[convexClient]
|
|
@@ -2398,8 +2414,7 @@ function TruthProvider({
|
|
|
2398
2414
|
offlineStore,
|
|
2399
2415
|
offlineEnabled,
|
|
2400
2416
|
getAuthToken: stableGetAuthToken,
|
|
2401
|
-
authGated: hasAuthFetcher
|
|
2402
|
-
authReady: convexAuthed
|
|
2417
|
+
authGated: hasAuthFetcher
|
|
2403
2418
|
}),
|
|
2404
2419
|
[
|
|
2405
2420
|
resolvedApiBaseUrl,
|
|
@@ -2409,15 +2424,9 @@ function TruthProvider({
|
|
|
2409
2424
|
offlineStore,
|
|
2410
2425
|
offlineEnabled,
|
|
2411
2426
|
stableGetAuthToken,
|
|
2412
|
-
hasAuthFetcher
|
|
2413
|
-
convexAuthed
|
|
2427
|
+
hasAuthFetcher
|
|
2414
2428
|
]
|
|
2415
2429
|
);
|
|
2416
|
-
const convexTree = (0, import_react2.createElement)(
|
|
2417
|
-
import_react.ConvexProvider,
|
|
2418
|
-
{ client: convexClient },
|
|
2419
|
-
children
|
|
2420
|
-
);
|
|
2421
2430
|
const queryTree = persister ? (0, import_react2.createElement)(
|
|
2422
2431
|
import_react_query_persist_client.PersistQueryClientProvider,
|
|
2423
2432
|
{
|
|
@@ -2430,22 +2439,28 @@ function TruthProvider({
|
|
|
2430
2439
|
buster: String(SCHEMA_VERSION)
|
|
2431
2440
|
}
|
|
2432
2441
|
},
|
|
2433
|
-
|
|
2434
|
-
) : (0, import_react2.createElement)(import_react_query2.QueryClientProvider, { client: queryClient },
|
|
2442
|
+
children
|
|
2443
|
+
) : (0, import_react2.createElement)(import_react_query2.QueryClientProvider, { client: queryClient }, children);
|
|
2444
|
+
const authedTree = (0, import_react2.createElement)(
|
|
2445
|
+
import_react.ConvexProviderWithAuth,
|
|
2446
|
+
{ client: convexClient, useAuth: useConvexAuthAdapter },
|
|
2447
|
+
queryTree
|
|
2448
|
+
);
|
|
2435
2449
|
return (0, import_react2.createElement)(
|
|
2436
2450
|
TruthSdkContext.Provider,
|
|
2437
2451
|
{ value: sdkContext },
|
|
2438
|
-
|
|
2452
|
+
authedTree
|
|
2439
2453
|
);
|
|
2440
2454
|
}
|
|
2441
2455
|
|
|
2442
2456
|
// src/react/queries-ready.ts
|
|
2443
2457
|
function useConvexQueriesReady() {
|
|
2444
2458
|
const ctx = useTruthSdkContext();
|
|
2459
|
+
const { isAuthenticated } = (0, import_react3.useConvexAuth)();
|
|
2445
2460
|
if (!(ctx == null ? void 0 : ctx.authGated)) {
|
|
2446
2461
|
return true;
|
|
2447
2462
|
}
|
|
2448
|
-
return
|
|
2463
|
+
return isAuthenticated;
|
|
2449
2464
|
}
|
|
2450
2465
|
|
|
2451
2466
|
// src/react/offline/use-persistent-query.ts
|
|
@@ -2556,7 +2571,7 @@ function useConversationById(id) {
|
|
|
2556
2571
|
|
|
2557
2572
|
// src/react/conversations.ts
|
|
2558
2573
|
var import_server4 = require("convex/server");
|
|
2559
|
-
var
|
|
2574
|
+
var import_react4 = require("react");
|
|
2560
2575
|
var conversationsListForUserRef = (0, import_server4.makeFunctionReference)("conversations:listForUser");
|
|
2561
2576
|
var conversationsSearchForUserRef = (0, import_server4.makeFunctionReference)("conversations:searchForUser");
|
|
2562
2577
|
var conversationsGetUnreadTotalForUserRef = (0, import_server4.makeFunctionReference)("conversations:getUnreadTotalForUser");
|
|
@@ -2643,7 +2658,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
2643
2658
|
}
|
|
2644
2659
|
function useMemoizedPhones(phones) {
|
|
2645
2660
|
const key = phones ? [...phones].sort().join("|") : "";
|
|
2646
|
-
return (0,
|
|
2661
|
+
return (0, import_react4.useMemo)(
|
|
2647
2662
|
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
2648
2663
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2649
2664
|
[key]
|
|
@@ -2691,7 +2706,7 @@ function useConversationTasksByPhonePair(phonePair) {
|
|
|
2691
2706
|
}
|
|
2692
2707
|
|
|
2693
2708
|
// src/react/hooks.ts
|
|
2694
|
-
var
|
|
2709
|
+
var import_react5 = require("react");
|
|
2695
2710
|
var import_server5 = require("convex/server");
|
|
2696
2711
|
var patientsListRef = (0, import_server5.makeFunctionReference)("patients:list");
|
|
2697
2712
|
var patientsGetRef = (0, import_server5.makeFunctionReference)("patients:get");
|
|
@@ -2791,7 +2806,7 @@ function usePatientMedical(elationId, options) {
|
|
|
2791
2806
|
appointmentsByPatientRef,
|
|
2792
2807
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2793
2808
|
);
|
|
2794
|
-
(0,
|
|
2809
|
+
(0, import_react5.useEffect)(() => {
|
|
2795
2810
|
if (elationId === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
2796
2811
|
return;
|
|
2797
2812
|
}
|
|
@@ -2829,7 +2844,7 @@ function usePatientBasic(input, options) {
|
|
|
2829
2844
|
hintPatientByIdRef,
|
|
2830
2845
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
2831
2846
|
);
|
|
2832
|
-
(0,
|
|
2847
|
+
(0, import_react5.useEffect)(() => {
|
|
2833
2848
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2834
2849
|
return;
|
|
2835
2850
|
}
|
|
@@ -2885,7 +2900,7 @@ function usePatientPhoto(elationId, options) {
|
|
|
2885
2900
|
patientPhotoByIdRef,
|
|
2886
2901
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2887
2902
|
);
|
|
2888
|
-
(0,
|
|
2903
|
+
(0, import_react5.useEffect)(() => {
|
|
2889
2904
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2890
2905
|
return;
|
|
2891
2906
|
}
|
|
@@ -2928,7 +2943,7 @@ function useConversationMessages(input, options) {
|
|
|
2928
2943
|
}
|
|
2929
2944
|
|
|
2930
2945
|
// src/react/notifications.ts
|
|
2931
|
-
var
|
|
2946
|
+
var import_react6 = require("react");
|
|
2932
2947
|
function loadExpo() {
|
|
2933
2948
|
return __async(this, null, function* () {
|
|
2934
2949
|
try {
|
|
@@ -2943,12 +2958,12 @@ function useNotifications(options) {
|
|
|
2943
2958
|
const sdkContext = useTruthSdkContext();
|
|
2944
2959
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
2945
2960
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
2946
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
2947
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
2948
|
-
const expoRef = (0,
|
|
2949
|
-
const isWebRef = (0,
|
|
2950
|
-
const vapidKeyRef = (0,
|
|
2951
|
-
(0,
|
|
2961
|
+
const [permissionStatus, setPermissionStatus] = (0, import_react6.useState)("unknown");
|
|
2962
|
+
const [devicePushToken, setDevicePushToken] = (0, import_react6.useState)(null);
|
|
2963
|
+
const expoRef = (0, import_react6.useRef)(null);
|
|
2964
|
+
const isWebRef = (0, import_react6.useRef)(false);
|
|
2965
|
+
const vapidKeyRef = (0, import_react6.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
|
|
2966
|
+
(0, import_react6.useEffect)(() => {
|
|
2952
2967
|
let mounted = true;
|
|
2953
2968
|
void (() => __async(null, null, function* () {
|
|
2954
2969
|
var _a2;
|
|
@@ -3004,7 +3019,7 @@ function useNotifications(options) {
|
|
|
3004
3019
|
mounted = false;
|
|
3005
3020
|
};
|
|
3006
3021
|
}, [apiBaseUrl, apiKey]);
|
|
3007
|
-
const register = (0,
|
|
3022
|
+
const register = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
3008
3023
|
var _a2, _b2;
|
|
3009
3024
|
if (!options.userId) {
|
|
3010
3025
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3117,7 +3132,7 @@ function useNotifications(options) {
|
|
|
3117
3132
|
options.appVersion,
|
|
3118
3133
|
options.serviceWorkerPath
|
|
3119
3134
|
]);
|
|
3120
|
-
const unregister = (0,
|
|
3135
|
+
const unregister = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
3121
3136
|
if (!devicePushToken) {
|
|
3122
3137
|
return;
|
|
3123
3138
|
}
|
|
@@ -3132,7 +3147,7 @@ function useNotifications(options) {
|
|
|
3132
3147
|
});
|
|
3133
3148
|
setDevicePushToken(null);
|
|
3134
3149
|
}), [apiBaseUrl, apiKey, devicePushToken]);
|
|
3135
|
-
const addReceivedListener = (0,
|
|
3150
|
+
const addReceivedListener = (0, import_react6.useCallback)(
|
|
3136
3151
|
(listener) => {
|
|
3137
3152
|
if (isWebRef.current) {
|
|
3138
3153
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3161,7 +3176,7 @@ function useNotifications(options) {
|
|
|
3161
3176
|
},
|
|
3162
3177
|
[]
|
|
3163
3178
|
);
|
|
3164
|
-
const addResponseListener = (0,
|
|
3179
|
+
const addResponseListener = (0, import_react6.useCallback)(
|
|
3165
3180
|
(listener) => {
|
|
3166
3181
|
if (isWebRef.current) {
|
|
3167
3182
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3190,7 +3205,7 @@ function useNotifications(options) {
|
|
|
3190
3205
|
},
|
|
3191
3206
|
[]
|
|
3192
3207
|
);
|
|
3193
|
-
const getBadgeCount = (0,
|
|
3208
|
+
const getBadgeCount = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
3194
3209
|
var _a2;
|
|
3195
3210
|
const expo = expoRef.current;
|
|
3196
3211
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -3198,7 +3213,7 @@ function useNotifications(options) {
|
|
|
3198
3213
|
}
|
|
3199
3214
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
3200
3215
|
}), []);
|
|
3201
|
-
const setBadgeCount = (0,
|
|
3216
|
+
const setBadgeCount = (0, import_react6.useCallback)((count) => __async(null, null, function* () {
|
|
3202
3217
|
const expo = expoRef.current;
|
|
3203
3218
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
3204
3219
|
return;
|
|
@@ -3206,7 +3221,7 @@ function useNotifications(options) {
|
|
|
3206
3221
|
yield expo.setBadgeCountAsync(count);
|
|
3207
3222
|
}), []);
|
|
3208
3223
|
const autoRegister = options.autoRegister !== false;
|
|
3209
|
-
(0,
|
|
3224
|
+
(0, import_react6.useEffect)(() => {
|
|
3210
3225
|
if (!autoRegister) {
|
|
3211
3226
|
return;
|
|
3212
3227
|
}
|
|
@@ -3243,7 +3258,7 @@ function useNotificationsActions() {
|
|
|
3243
3258
|
const sdkContext = useTruthSdkContext();
|
|
3244
3259
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
3245
3260
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
3246
|
-
const post = (0,
|
|
3261
|
+
const post = (0, import_react6.useCallback)(
|
|
3247
3262
|
(path, body) => __async(null, null, function* () {
|
|
3248
3263
|
if (!apiBaseUrl || !apiKey) {
|
|
3249
3264
|
throw new Error(
|
|
@@ -3269,7 +3284,7 @@ function useNotificationsActions() {
|
|
|
3269
3284
|
}),
|
|
3270
3285
|
[apiBaseUrl, apiKey]
|
|
3271
3286
|
);
|
|
3272
|
-
const get = (0,
|
|
3287
|
+
const get = (0, import_react6.useCallback)(
|
|
3273
3288
|
(path) => __async(null, null, function* () {
|
|
3274
3289
|
const res = yield fetch(`${apiBaseUrl}/api${path}`, {
|
|
3275
3290
|
method: "GET",
|
|
@@ -3285,21 +3300,21 @@ function useNotificationsActions() {
|
|
|
3285
3300
|
}),
|
|
3286
3301
|
[apiBaseUrl, apiKey]
|
|
3287
3302
|
);
|
|
3288
|
-
const send = (0,
|
|
3303
|
+
const send = (0, import_react6.useCallback)(
|
|
3289
3304
|
(input) => post("/notifications/send", input),
|
|
3290
3305
|
[post]
|
|
3291
3306
|
);
|
|
3292
|
-
const schedule = (0,
|
|
3307
|
+
const schedule = (0, import_react6.useCallback)(
|
|
3293
3308
|
(input) => post("/notifications/schedule", input),
|
|
3294
3309
|
[post]
|
|
3295
3310
|
);
|
|
3296
|
-
const getPreferences = (0,
|
|
3311
|
+
const getPreferences = (0, import_react6.useCallback)(
|
|
3297
3312
|
(userId) => get(
|
|
3298
3313
|
`/notifications/preferences/${encodeURIComponent(userId)}`
|
|
3299
3314
|
),
|
|
3300
3315
|
[get]
|
|
3301
3316
|
);
|
|
3302
|
-
const updatePreferences = (0,
|
|
3317
|
+
const updatePreferences = (0, import_react6.useCallback)(
|
|
3303
3318
|
(userId, prefs) => post(
|
|
3304
3319
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3305
3320
|
prefs
|
|
@@ -3382,12 +3397,12 @@ function usePatientSearch(options) {
|
|
|
3382
3397
|
|
|
3383
3398
|
// src/react/patients-bulk.ts
|
|
3384
3399
|
var import_server8 = require("convex/server");
|
|
3385
|
-
var
|
|
3400
|
+
var import_react7 = require("react");
|
|
3386
3401
|
var patientsGetByIdsRef = (0, import_server8.makeFunctionReference)("patients:getByIds");
|
|
3387
3402
|
var patientsGetByPhonesRef = (0, import_server8.makeFunctionReference)("patients:getByPhones");
|
|
3388
3403
|
var SKIP5 = "skip";
|
|
3389
3404
|
function usePatientsByIds(ids) {
|
|
3390
|
-
const stableIds = (0,
|
|
3405
|
+
const stableIds = (0, import_react7.useMemo)(() => {
|
|
3391
3406
|
const arr = ids != null ? ids : [];
|
|
3392
3407
|
return [...new Set(arr)].sort();
|
|
3393
3408
|
}, [ids]);
|
|
@@ -3396,7 +3411,7 @@ function usePatientsByIds(ids) {
|
|
|
3396
3411
|
patientsGetByIdsRef,
|
|
3397
3412
|
skipped ? SKIP5 : { ids: stableIds }
|
|
3398
3413
|
);
|
|
3399
|
-
const mapped = (0,
|
|
3414
|
+
const mapped = (0, import_react7.useMemo)(() => {
|
|
3400
3415
|
if (result === void 0) {
|
|
3401
3416
|
return void 0;
|
|
3402
3417
|
}
|
|
@@ -3418,7 +3433,7 @@ function usePatientsByIds(ids) {
|
|
|
3418
3433
|
};
|
|
3419
3434
|
}
|
|
3420
3435
|
function usePatientsByPhones(phones) {
|
|
3421
|
-
const stableDigits = (0,
|
|
3436
|
+
const stableDigits = (0, import_react7.useMemo)(() => {
|
|
3422
3437
|
const arr = phones != null ? phones : [];
|
|
3423
3438
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3424
3439
|
return [...new Set(digits)].sort();
|
|
@@ -3428,7 +3443,7 @@ function usePatientsByPhones(phones) {
|
|
|
3428
3443
|
patientsGetByPhonesRef,
|
|
3429
3444
|
skipped ? SKIP5 : { phoneDigits: stableDigits }
|
|
3430
3445
|
);
|
|
3431
|
-
const mapped = (0,
|
|
3446
|
+
const mapped = (0, import_react7.useMemo)(() => {
|
|
3432
3447
|
if (result === void 0) {
|
|
3433
3448
|
return void 0;
|
|
3434
3449
|
}
|
|
@@ -3467,23 +3482,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3467
3482
|
}
|
|
3468
3483
|
|
|
3469
3484
|
// src/react/tasks.ts
|
|
3470
|
-
var
|
|
3485
|
+
var import_react8 = require("convex/react");
|
|
3471
3486
|
var import_server10 = require("convex/server");
|
|
3472
|
-
var
|
|
3487
|
+
var import_react9 = require("react");
|
|
3473
3488
|
var conversationTasksMarkSeenRef = (0, import_server10.makeFunctionReference)("conversationTasks:markSeen");
|
|
3474
3489
|
function useConversationTaskMarkSeen() {
|
|
3475
|
-
const mutate = (0,
|
|
3490
|
+
const mutate = (0, import_react8.useMutation)(
|
|
3476
3491
|
conversationTasksMarkSeenRef
|
|
3477
3492
|
);
|
|
3478
|
-
return (0,
|
|
3493
|
+
return (0, import_react9.useCallback)(
|
|
3479
3494
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3480
3495
|
[mutate]
|
|
3481
3496
|
);
|
|
3482
3497
|
}
|
|
3483
3498
|
|
|
3484
3499
|
// src/react/tracking.ts
|
|
3485
|
-
var
|
|
3486
|
-
var TruthTrackingContext = (0,
|
|
3500
|
+
var import_react10 = require("react");
|
|
3501
|
+
var TruthTrackingContext = (0, import_react10.createContext)(
|
|
3487
3502
|
null
|
|
3488
3503
|
);
|
|
3489
3504
|
function TruthTrackingProvider({
|
|
@@ -3496,7 +3511,7 @@ function TruthTrackingProvider({
|
|
|
3496
3511
|
}) {
|
|
3497
3512
|
var _a, _b;
|
|
3498
3513
|
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 : "";
|
|
3499
|
-
const value = (0,
|
|
3514
|
+
const value = (0, import_react10.useMemo)(() => {
|
|
3500
3515
|
const tracker = new Tracker({
|
|
3501
3516
|
apiKey: resolvedApiKey,
|
|
3502
3517
|
environment,
|
|
@@ -3515,10 +3530,10 @@ function TruthTrackingProvider({
|
|
|
3515
3530
|
}
|
|
3516
3531
|
};
|
|
3517
3532
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3518
|
-
return (0,
|
|
3533
|
+
return (0, import_react10.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3519
3534
|
}
|
|
3520
3535
|
function useTruth() {
|
|
3521
|
-
const ctx = (0,
|
|
3536
|
+
const ctx = (0, import_react10.useContext)(TruthTrackingContext);
|
|
3522
3537
|
if (!ctx) {
|
|
3523
3538
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3524
3539
|
}
|
|
@@ -3546,15 +3561,15 @@ function useUserSettings(userId) {
|
|
|
3546
3561
|
}
|
|
3547
3562
|
|
|
3548
3563
|
// src/react/users.ts
|
|
3549
|
-
var
|
|
3564
|
+
var import_react11 = require("react");
|
|
3550
3565
|
function useUserSync(input) {
|
|
3551
3566
|
var _a, _b, _c, _d;
|
|
3552
3567
|
const sdkContext = useTruthSdkContext();
|
|
3553
3568
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3554
3569
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3555
|
-
const [status, setStatus] = (0,
|
|
3556
|
-
const [error, setError] = (0,
|
|
3557
|
-
const lastKeyRef = (0,
|
|
3570
|
+
const [status, setStatus] = (0, import_react11.useState)("idle");
|
|
3571
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
3572
|
+
const lastKeyRef = (0, import_react11.useRef)(null);
|
|
3558
3573
|
const sync = () => __async(null, null, function* () {
|
|
3559
3574
|
if (!input.userId) {
|
|
3560
3575
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3597,7 +3612,7 @@ function useUserSync(input) {
|
|
|
3597
3612
|
return { ok: false, reason: message };
|
|
3598
3613
|
}
|
|
3599
3614
|
});
|
|
3600
|
-
(0,
|
|
3615
|
+
(0, import_react11.useEffect)(() => {
|
|
3601
3616
|
var _a2, _b2, _c2, _d2, _e;
|
|
3602
3617
|
if (!input.userId) {
|
|
3603
3618
|
return;
|
|
@@ -3636,13 +3651,13 @@ function useUserSync(input) {
|
|
|
3636
3651
|
}
|
|
3637
3652
|
|
|
3638
3653
|
// src/react/voicemail.ts
|
|
3639
|
-
var
|
|
3654
|
+
var import_react12 = require("react");
|
|
3640
3655
|
function useVoicemailUrl(client) {
|
|
3641
|
-
const [url, setUrl] = (0,
|
|
3642
|
-
const [isLoading, setIsLoading] = (0,
|
|
3643
|
-
const [error, setError] = (0,
|
|
3644
|
-
const inFlightRef = (0,
|
|
3645
|
-
const fetchUrl = (0,
|
|
3656
|
+
const [url, setUrl] = (0, import_react12.useState)(null);
|
|
3657
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
3658
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
3659
|
+
const inFlightRef = (0, import_react12.useRef)(false);
|
|
3660
|
+
const fetchUrl = (0, import_react12.useCallback)(
|
|
3646
3661
|
(voicemailLink) => __async(null, null, function* () {
|
|
3647
3662
|
if (inFlightRef.current) {
|
|
3648
3663
|
return null;
|