decord/alpha/source/modules/feedback/FeedbackManager.tsx

179 lines
5.8 KiB
TypeScript
Raw Permalink Normal View History

2026-10-13 12:43:34 +00:00
// Module ID: 18095
// Function ID: 18096
// Name: feedback/FeedbackManager
2026-10-13 12:43:34 +00:00
// Dependencies: [6910, 18096, 9651, 18097, 2041, 510, 12, 6808, 2]
2026-07-23 10:11:24 +00:00
2026-10-13 12:43:34 +00:00
// Module 18095 (feedback/FeedbackManager)
import _mod12 from "module_12" /* 12 */;
2026-10-09 10:00:15 +00:00
import UserSettings from "UserSettings" /* 2041 */;
2026-10-13 12:43:34 +00:00
import FeedbackConfig from "FeedbackConfig" /* 18097 */;
2026-10-12 06:59:38 +00:00
import HotspotStore from "hotspot/HotspotStore" /* 6910 */;
2026-10-13 12:43:34 +00:00
import FeedbackOverrideStore from "FeedbackOverrideStore" /* 18096 */;
2026-10-12 06:59:38 +00:00
import Constants from "Constants" /* 9651 */;
import AutomaticLifecycleManager from "AutomaticLifecycleManager" /* 6808 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-07-20 16:05:17 +00:00
2026-10-03 08:58:59 +00:00
let _require, optOutExpiryTime;
let closure_4;
let hasOwnProperty;
2026-07-20 16:05:17 +00:00
function optOutEligibilityCheck(hotspot) {
_require = hotspot;
const InAppFeedbackStates = require("UserSettings").InAppFeedbackStates;
2026-07-29 08:29:29 +00:00
const tmp3 = InAppFeedbackStates.getSetting()[hotspot.feedbackType];
optOutExpiryTime = undefined;
2026-10-03 08:58:59 +00:00
const tmp = _require;
2026-07-29 08:29:29 +00:00
if (tmp3 != null) {
optOutExpiryTime = tmp3.optOutExpiryTime;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp5 = null != optOutExpiryTime;
if (tmp5) {
2026-07-20 16:05:17 +00:00
const _Number = Number;
2026-07-29 08:29:29 +00:00
tmp5 = !Number.isNaN(optOutExpiryTime);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp5) {
2026-07-20 16:05:17 +00:00
const _Date = Date;
2026-07-29 08:29:29 +00:00
tmp5 = Date.now() < optOutExpiryTime;
2026-07-20 16:05:17 +00:00
}
const hasHotspotResult = HotspotStore.hasHotspot(hotspot.hotspot);
2026-07-29 08:29:29 +00:00
let tmp10 = tmp9;
if (!hasHotspotResult) {
tmp10 = !tmp5;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp10) {
2026-10-09 10:00:15 +00:00
const InAppFeedbackStates2 = tmp(2041).InAppFeedbackStates;
2026-07-20 16:05:17 +00:00
InAppFeedbackStates2.updateSetting((arg0) => {
const obj = {};
2026-07-20 16:05:17 +00:00
const merged = Object.assign(arg0);
2026-10-03 08:58:59 +00:00
const feedbackType = hotspot.feedbackType;
const obj2 = { optOutExpiryTime: hasOwnProperty };
2026-07-23 10:11:24 +00:00
const merged1 = Object.assign(arg0[hotspot.feedbackType]);
2026-10-03 08:58:59 +00:00
obj[feedbackType] = obj2;
2026-07-20 16:05:17 +00:00
return obj;
});
}
2026-10-03 08:58:59 +00:00
return !tmp5 && !(!hasHotspotResult);
2026-07-20 16:05:17 +00:00
}
function triggerRateEligibilityCheck(chance) {
return Math.random() < chance.chance;
}
2026-07-29 08:29:29 +00:00
function recencyEligibilityCheck(cooldown, storageKey) {
2026-10-03 08:58:59 +00:00
let closure_0 = storageKey;
const InAppFeedbackStates = UserSettings.InAppFeedbackStates;
2026-07-29 08:29:29 +00:00
const tmp3 = InAppFeedbackStates.getSetting()[storageKey.feedbackType];
2026-07-20 16:05:17 +00:00
let lastImpressionTime;
2026-07-29 08:29:29 +00:00
if (tmp3 != null) {
lastImpressionTime = tmp3.lastImpressionTime;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
let c1;
2026-07-29 08:29:29 +00:00
let isNaNResult = null != lastImpressionTime;
if (isNaNResult) {
2026-07-20 16:05:17 +00:00
const _Number = Number;
2026-07-29 08:29:29 +00:00
isNaNResult = !Number.isNaN(lastImpressionTime);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!isNaNResult) {
isNaNResult = null == storageKey.storageKey;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp7;
if (!isNaNResult) {
const Storage = tmp(510).Storage;
2026-10-03 08:58:59 +00:00
const value = Storage.get(storageKey.storageKey);
c1 = value;
2026-07-29 08:29:29 +00:00
isNaNResult = null == value;
tmp7 = value;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!isNaNResult) {
const _Number2 = Number;
isNaNResult = Number.isNaN(tmp7);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!isNaNResult) {
2026-10-09 10:00:15 +00:00
const InAppFeedbackStates2 = tmp(2041).InAppFeedbackStates;
2026-07-29 08:29:29 +00:00
InAppFeedbackStates2.updateSetting((arg0) => {
const obj = {};
2026-07-29 08:29:29 +00:00
const merged = Object.assign(arg0);
2026-10-03 08:58:59 +00:00
const feedbackType = closure_0.feedbackType;
const obj2 = { lastImpressionTime };
const merged1 = Object.assign(arg0[closure_0.feedbackType]);
obj[feedbackType] = obj2;
2026-07-29 08:29:29 +00:00
return obj;
});
}
const items = [lastImpressionTime, tmp7];
2026-10-03 08:58:59 +00:00
const tmpResult = _mod12;
let num = tmpResult.max(items);
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 0;
}
const sum = num + cooldown.cooldown;
2026-07-20 16:05:17 +00:00
return sum < Date.now();
}
function groupRecencyEligibilityCheck(cooldown) {
2026-10-03 08:58:59 +00:00
let closure_0 = cooldown;
const values = Object.values(FeedbackConfig.FeedbackConfig);
2026-07-29 08:29:29 +00:00
const found = values.filter((group) => group.group === group.group);
const obj = found[Symbol.iterator]();
2026-07-29 08:29:29 +00:00
while (obj !== undefined) {
if (recencyEligibilityCheck(cooldown, tmp2)) {
continue;
} else {
obj.return();
let flag = false;
return false;
2026-07-20 16:05:17 +00:00
}
}
return true;
}
2026-10-03 08:58:59 +00:00
({ FeedbackTypePrecedence: closure_4, MAX_REPRESENTABLE_DATE: hasOwnProperty } = Constants);
class FeedbackManager extends AutomaticLifecycleManager {
2026-07-29 08:29:29 +00:00
constructor() {
2026-10-03 08:58:59 +00:00
const applyArgumentsResult = HermesBuiltin.applyArguments(this, new.target);
const require = applyArgumentsResult;
2026-07-29 08:29:29 +00:00
applyArgumentsResult.feedbackTypeToShow = null;
2026-10-03 08:58:59 +00:00
let obj = _mod12;
applyArgumentsResult.showFeedbackModalDebounced = obj.debounce((fn, fn2) => {
2026-10-03 08:58:59 +00:00
if (null != require.feedbackTypeToShow) {
const feedbackTypeToShow = tmp.feedbackTypeToShow;
const InAppFeedbackStates = UserSettings.InAppFeedbackStates;
2026-07-29 08:29:29 +00:00
InAppFeedbackStates.updateSetting((arg0) => {
const obj = {};
2026-07-29 08:29:29 +00:00
const merged = Object.assign(arg0);
2026-10-03 08:58:59 +00:00
const obj2 = { lastImpressionTime: Date.now() };
2026-07-29 08:29:29 +00:00
const merged1 = Object.assign(arg0[feedbackTypeToShow]);
obj[feedbackTypeToShow] = obj2;
2026-07-29 08:29:29 +00:00
return obj;
});
2026-10-03 08:58:59 +00:00
require.feedbackTypeToShow = null;
fn();
} else if (fn2 != null) {
fn2();
2026-07-29 08:29:29 +00:00
}
}, 200);
return applyArgumentsResult;
}
2026-10-03 08:58:59 +00:00
possiblyShowFeedbackModal(ACTIVITY, arg1, fn) {
let feedbackConfig = FeedbackOverrideStore.getFeedbackConfig(ACTIVITY);
if (feedbackConfig == null) {
feedbackConfig = FeedbackConfig.FeedbackConfig[ACTIVITY];
}
let eligibilityChecks = feedbackConfig.eligibilityChecks;
if (eligibilityChecks == null) {
eligibilityChecks = [];
}
const items = [triggerRateEligibilityCheck, optOutEligibilityCheck, groupRecencyEligibilityCheck];
const tmp4 = items.every((fn) => fn(feedbackConfig)) && eligibilityChecks.every((fn) => fn(feedbackConfig));
if (!tmp4) {
if (fn != null) {
fn();
}
} else {
const self = this;
self.feedbackTypeToShow = ACTIVITY;
const result = self.showFeedbackModalDebounced(arg1, fn);
2026-07-29 08:29:29 +00:00
}
}
2026-10-03 08:58:59 +00:00
}
const prototype = FeedbackManager.prototype;
let result = size.fileFinishedImporting("modules/feedback/FeedbackManager.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default FeedbackManager;