91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
// Metro module 9275 (f9276).
|
|
import SurveyStore, { SURVEY_REFETCH_INTERVAL } from "../stores/SurveyStore";
|
|
import { AnalyticEvents, Endpoints, NoticeTypes } from "../Constants";
|
|
import Dispatcher from "../Dispatcher";
|
|
import AnalyticsUtils from "../utils/AnalyticsUtils";
|
|
import TrackedHTTPUtils from "../utils/TrackedHTTPUtils";
|
|
import { NetworkActionNames } from "../_bundle/Module503";
|
|
import { exact } from "../_bundle/Module1385";
|
|
import { rejectWithMigratedError } from "../_bundle/sendRequest";
|
|
export function overrideSurvey(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "SURVEY_OVERRIDE",
|
|
id: a0
|
|
});
|
|
}
|
|
export function surveyHide(a0, a1) {
|
|
Dispatcher.dispatch({
|
|
type: "SURVEY_HIDE",
|
|
key: a0
|
|
});
|
|
if (a1) {
|
|
AnalyticsUtils.track(AnalyticEvents.APP_NOTICE_CLOSED, {
|
|
notice_type: NoticeTypes.SURVEY,
|
|
survey_id: a0,
|
|
dismissed: a1
|
|
});
|
|
} else {
|
|
AnalyticsUtils.track(AnalyticEvents.APP_NOTICE_PRIMARY_CTA_OPENED, {
|
|
notice_type: NoticeTypes.SURVEY
|
|
});
|
|
}
|
|
}
|
|
export function surveyFetch(a0, a1) {
|
|
const query = {};
|
|
if (a0 != null) {
|
|
query.survey_override = a0;
|
|
}
|
|
if (a1 != null) {
|
|
query.disable_auto_seen = a1;
|
|
}
|
|
return TrackedHTTPUtils.get({
|
|
url: Endpoints.USER_SURVEY,
|
|
query,
|
|
trackedActionData: {
|
|
event: NetworkActionNames.USER_SURVEY_FETCH,
|
|
properties: (a0) => exact({
|
|
key: (a0 == null ? void 0 : a0.body?.survey)?.key
|
|
})
|
|
},
|
|
rejectWithError: rejectWithMigratedError()
|
|
}).then((result) => {
|
|
Dispatcher.dispatch({
|
|
type: "SURVEY_FETCHED",
|
|
survey: result == null ? void 0 : result.body?.survey
|
|
});
|
|
return result == null ? void 0 : result.body?.survey;
|
|
}, () => {
|
|
Dispatcher.dispatch({
|
|
type: "SURVEY_FETCHED",
|
|
survey: null
|
|
});
|
|
});
|
|
}
|
|
export function surveySeen(a0) {
|
|
let key;
|
|
L4: {
|
|
key = a0;
|
|
const lastSeenTimestamp = SurveyStore.getLastSeenTimestamp();
|
|
if (lastSeenTimestamp !== null) {
|
|
if (lastSeenTimestamp != null && Date.now() - lastSeenTimestamp >= SURVEY_REFETCH_INTERVAL) {
|
|
break L4;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "SURVEY_SEEN",
|
|
key: a0
|
|
});
|
|
return TrackedHTTPUtils.post({
|
|
url: Endpoints.USER_SURVEY_SEEN(a0),
|
|
trackedActionData: {
|
|
event: NetworkActionNames.USER_SURVEY_SEEN,
|
|
properties: () => exact({
|
|
key
|
|
})
|
|
},
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
}
|