@mxenabled/connect-widget 2.19.8 → 2.19.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/index.es.js +35 -25
- package/dist/index.es.js.map +1 -1
- package/dist/lastBuild.txt +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -80009,6 +80009,23 @@ function getReferrer() {
|
|
|
80009
80009
|
}
|
|
80010
80010
|
const isValidUrl = (url) => typeof url === "string" && url.match(/((\w+:\/\/)[-a-zA-Z0-9:@;?&=/%+.*!'(),$_{}^~[\]`#|]+)/g);
|
|
80011
80011
|
|
|
80012
|
+
function createMemberUpdateTransport(api, memberGuid, options = {}) {
|
|
80013
|
+
const pollingInterval = options.pollingInterval || 3e3;
|
|
80014
|
+
const clientLocale = options.clientLocale || "en";
|
|
80015
|
+
return interval(pollingInterval).pipe(
|
|
80016
|
+
exhaustMap(
|
|
80017
|
+
() => defer(() => api.loadMemberByGuid(memberGuid, clientLocale)).pipe(
|
|
80018
|
+
mergeMap(
|
|
80019
|
+
(member) => defer(
|
|
80020
|
+
() => api.loadJob(member.most_recent_job_guid)
|
|
80021
|
+
).pipe(map((job) => ({ member, job })))
|
|
80022
|
+
),
|
|
80023
|
+
catchError((error) => of(error))
|
|
80024
|
+
)
|
|
80025
|
+
)
|
|
80026
|
+
);
|
|
80027
|
+
}
|
|
80028
|
+
|
|
80012
80029
|
function usePollMember() {
|
|
80013
80030
|
const { api } = useApi();
|
|
80014
80031
|
const clientLocale = useMemo(() => {
|
|
@@ -80017,29 +80034,19 @@ function usePollMember() {
|
|
|
80017
80034
|
const { optOutOfEarlyUserRelease, memberPollingMilliseconds } = useSelector(getExperimentalFeatures);
|
|
80018
80035
|
const pollingInterval = memberPollingMilliseconds || 3e3;
|
|
80019
80036
|
const pollMember = (memberGuid) => {
|
|
80020
|
-
|
|
80021
|
-
|
|
80022
|
-
|
|
80023
|
-
|
|
80024
|
-
|
|
80025
|
-
|
|
80026
|
-
|
|
80027
|
-
|
|
80028
|
-
|
|
80029
|
-
|
|
80030
|
-
|
|
80031
|
-
|
|
80032
|
-
|
|
80033
|
-
defer(() => api.loadMemberByGuid(memberGuid, clientLocale)).pipe(
|
|
80034
|
-
mergeMap(
|
|
80035
|
-
(member) => defer(() => api.loadJob(member.most_recent_job_guid)).pipe(
|
|
80036
|
-
map((job) => ({ member, job }))
|
|
80037
|
-
)
|
|
80038
|
-
),
|
|
80039
|
-
catchError((error) => of(error))
|
|
80040
|
-
)
|
|
80041
|
-
)
|
|
80042
|
-
),
|
|
80037
|
+
const loadMemberByGuid = api.loadMemberByGuid || (() => Promise.reject(new Error("api.loadMemberByGuid is required for member polling")));
|
|
80038
|
+
const updateStream$ = createMemberUpdateTransport(
|
|
80039
|
+
{
|
|
80040
|
+
loadMemberByGuid,
|
|
80041
|
+
loadJob: api.loadJob
|
|
80042
|
+
},
|
|
80043
|
+
memberGuid,
|
|
80044
|
+
{
|
|
80045
|
+
pollingInterval,
|
|
80046
|
+
clientLocale
|
|
80047
|
+
}
|
|
80048
|
+
);
|
|
80049
|
+
return updateStream$.pipe(
|
|
80043
80050
|
scan(
|
|
80044
80051
|
(acc, response) => {
|
|
80045
80052
|
const isError = response instanceof Error;
|
|
@@ -80053,9 +80060,12 @@ function usePollMember() {
|
|
|
80053
80060
|
// dont update current response if this is an error
|
|
80054
80061
|
currentResponse: isError ? acc.currentResponse : response,
|
|
80055
80062
|
// preserve the initialDataReadySent flag
|
|
80056
|
-
initialDataReady: acc.initialDataReady
|
|
80063
|
+
initialDataReady: acc.initialDataReady,
|
|
80064
|
+
pollingIsDone: false,
|
|
80065
|
+
userMessage: acc.userMessage
|
|
80057
80066
|
};
|
|
80058
|
-
if (!isError && !acc.initialDataReady && response
|
|
80067
|
+
if (!isError && !acc.initialDataReady && // @ts-expect-error response might be undefined or an error
|
|
80068
|
+
response?.job?.async_account_data_ready && !optOutOfEarlyUserRelease) {
|
|
80059
80069
|
pollingState.initialDataReady = true;
|
|
80060
80070
|
}
|
|
80061
80071
|
const [shouldStopPolling, messageKey] = handlePollingResponse(pollingState);
|