decord/source/modules/user_profile/WidgetStore.tsx

257 lines
7.5 KiB
TypeScript
Raw Normal View History

// Module ID: 7727
// Function ID: 7728
// Name: WidgetStore
// Dependencies: [32, 1371, 7723, 504, 1369, 12, 573, 2]
2026-07-20 16:05:17 +00:00
// Module 7727 (WidgetStore)
import _modDef12 from "module_12" /* 12 */;
import initializeDefault from "initialize" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import GlobalUtils from "GlobalUtils" /* 1369 */;
import _slicedToArray from "module_32" /* 32 */;
import UserStore from "UserStore" /* 1371 */;
import UserProfileStore from "UserProfileStore" /* 7723 */;
2026-07-23 10:11:24 +00:00
require = fn;
2026-07-29 08:29:29 +00:00
let c6 = null;
2026-08-11 06:20:06 +00:00
let c7 = null;
let c8 = false;
let closure_9 = { suggestedGamesIds: [], suggestedWishlistGamesIds: [] };
2026-07-29 08:29:29 +00:00
let c10 = false;
let c11 = false;
2026-08-11 06:20:06 +00:00
let c12 = false;
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class WidgetStore extends Store {
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = WidgetStore.prototype;
prototype["initialize"] = function initialize() {
this.waitFor(UserStore);
2026-07-29 08:29:29 +00:00
};
prototype["getPendingWidgets"] = function getPendingWidgets() {
2026-08-11 06:20:06 +00:00
return c6;
2026-07-29 08:29:29 +00:00
};
prototype["getSaveablePendingWidgets"] = function getSaveablePendingWidgets() {
2026-08-11 06:20:06 +00:00
let found1 = null;
2026-07-29 08:29:29 +00:00
if (null != _null) {
2026-08-11 06:20:06 +00:00
const mapped = _null.map((isUpdatable) => {
let tmp = isUpdatable;
if (!isUpdatable.isUpdatable()) {
let found;
if (_null2 != null) {
2026-08-11 06:20:06 +00:00
found = arr.find((getUniqueKey) => {
const uniqueKey = getUniqueKey.getUniqueKey();
return uniqueKey === isUpdatable.getUniqueKey();
});
}
tmp = found;
arr = _null2;
2026-08-11 06:20:06 +00:00
}
return tmp;
});
let found = mapped.filter(GlobalUtils.isNotNullish);
2026-08-11 06:20:06 +00:00
found1 = found.filter((isDiscardable) => !isDiscardable.isDiscardable());
2026-07-20 16:05:17 +00:00
}
2026-08-11 06:20:06 +00:00
return found1;
2026-07-29 08:29:29 +00:00
};
prototype["hasPendingChanges"] = function hasPendingChanges() {
2026-08-11 06:20:06 +00:00
let tmp = null !== c6;
2026-07-29 08:29:29 +00:00
if (tmp) {
2026-08-11 06:20:06 +00:00
let tmp3 = null === c7;
2026-07-29 08:29:29 +00:00
if (!tmp3) {
tmp3 = !_modDef12.isEqual(c6, c7);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp = tmp3;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp;
};
prototype["getWidgetUpdates"] = function getWidgetUpdates() {
let changedWidgets = this.getSaveablePendingWidgets();
if (null != changedWidgets) {
if (null != _null2) {
const _Map = Map;
const map = new Map(_null2.map((id) => {
const items = [id.id, id];
return items;
}));
const _Map2 = Map;
2026-08-24 06:08:38 +00:00
map1 = new Map(changedWidgets.map((id) => {
2026-07-29 08:29:29 +00:00
const items = [id.id, id];
return items;
}));
let items = [];
const items1 = [];
const tmp37 = map1[Symbol.iterator]();
while (tmp37 !== undefined) {
let tmp5 = _slicedToArray(tmp2, 2);
2026-07-29 08:29:29 +00:00
let obj = tmp5[1];
value = map.get(tmp5[0]);
2026-07-29 08:29:29 +00:00
let isEqualResult = null != value;
if (isEqualResult) {
isEqualResult = obj.isEqual(tmp7);
}
if (!isEqualResult) {
let arr = items.push(obj);
}
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
for (const item10029 of tmp32) {
let tmp16 = _slicedToArray(item10029, 2);
2026-07-29 08:29:29 +00:00
let tmp17 = tmp16[1];
if (!map1.has(tmp16[0])) {
let arr2 = items1.push(tmp17);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let num = 0;
let flag = false;
if (0 < changedWidgets.length) {
while (true) {
let tmp20 = changedWidgets[num];
let id;
if (tmp20 != null) {
id = tmp20.id;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp24 = _null2[num];
let id1;
if (tmp24 != null) {
id1 = tmp24.id;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
flag = true;
if (id !== id1) {
break;
} else {
let sum = num + 1;
num = sum;
flag = false;
if (sum >= changedWidgets.length) {
break;
2026-07-20 16:05:17 +00:00
}
}
}
}
const obj2 = { changedWidgets: items, removedWidgets: items1, hasOrderChanges: flag };
return obj2;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
if (changedWidgets == null) {
changedWidgets = [];
}
return { changedWidgets, removedWidgets: [], hasOrderChanges: false };
};
prototype["getChangedWidgets"] = function getChangedWidgets() {
return this.getWidgetUpdates().changedWidgets;
};
prototype["getRemovedWidgets"] = function getRemovedWidgets() {
return this.getWidgetUpdates().removedWidgets;
};
prototype["hasUnsavedChanges"] = function hasUnsavedChanges() {
const widgetUpdates = this.getWidgetUpdates();
let hasOrderChanges = widgetUpdates.changedWidgets.length > 0;
if (!hasOrderChanges) {
hasOrderChanges = widgetUpdates.removedWidgets.length > 0;
}
if (!hasOrderChanges) {
hasOrderChanges = widgetUpdates.hasOrderChanges;
}
return hasOrderChanges;
};
prototype["canSaveChanges"] = function canSaveChanges() {
const saveablePendingWidgets = this.getSaveablePendingWidgets();
let everyResult = null != saveablePendingWidgets;
if (everyResult) {
everyResult = saveablePendingWidgets.every((isValid) => isValid.isValid());
}
return everyResult;
};
Object.defineProperty(prototype, "isSubmitting", {
get: function isSubmitting() {
2026-08-11 06:20:06 +00:00
return c8;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "suggestedFetchError", {
get: function suggestedFetchError() {
2026-08-11 06:20:06 +00:00
return c10;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "suggestedFetchIsLoading", {
get: function suggestedFetchIsLoading() {
2026-08-11 06:20:06 +00:00
return c11;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "suggestedFetchAttempted", {
get: function suggestedFetchAttempted() {
2026-08-11 06:20:06 +00:00
return c12;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "suggestedGameIds", {
get: function suggestedGameIds() {
2026-08-11 06:20:06 +00:00
return closure_9;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
const widgetStore = new WidgetStore(DispatcherDefault, {
2026-07-20 16:05:17 +00:00
WIDGET_PENDING_SET: function handleSetPendingWidgets(widgets) {
const widgets2 = widgets.widgets;
if (null === c7) {
const currentUser = UserStore.getCurrentUser();
2026-07-20 16:05:17 +00:00
if (null != currentUser) {
const userProfile = UserProfileStore.getUserProfile(currentUser.id);
2026-07-20 16:05:17 +00:00
widgets = undefined;
2026-07-29 08:29:29 +00:00
if (userProfile != null) {
2026-07-20 16:05:17 +00:00
widgets = userProfile.widgets;
}
2026-07-29 08:29:29 +00:00
if (widgets == null) {
2026-07-20 16:05:17 +00:00
widgets = [];
}
c7 = widgets;
2026-07-20 16:05:17 +00:00
}
}
},
WIDGET_PENDING_SAVE_START: function handleSavePendingWidgetsStart() {
2026-08-24 06:08:38 +00:00
c8 = true;
2026-07-20 16:05:17 +00:00
},
WIDGET_PENDING_SAVE_SUCCESS: function handleSavePendingWidgetsSuccess() {
2026-08-24 06:08:38 +00:00
c8 = false;
2026-08-11 06:20:06 +00:00
if (null !== c6) {
2026-08-24 06:08:38 +00:00
c7 = null;
2026-08-11 06:20:06 +00:00
c6 = null;
2026-07-20 16:05:17 +00:00
}
},
WIDGET_PENDING_SAVE_FAILURE: function handleSavePendingWidgetsFailure() {
2026-08-24 06:08:38 +00:00
c8 = false;
2026-07-20 16:05:17 +00:00
},
WIDGET_SUGGESTED_FETCH_SUCCESS: function handleSetSuggestedGameIds(arg0) {
2026-08-11 06:20:06 +00:00
({ suggestedGamesIds: closure_9.suggestedGamesIds, suggestedWishlistGamesIds: closure_9.suggestedWishlistGamesIds } = arg0);
2026-08-24 06:08:38 +00:00
c11 = false;
c10 = false;
2026-07-20 16:05:17 +00:00
},
WIDGET_SUGGESTED_FETCH_FAILURE: function handleSetSuggestedFetchFailure() {
2026-08-24 06:08:38 +00:00
c10 = true;
c11 = false;
2026-07-20 16:05:17 +00:00
},
WIDGET_SUGGESTED_FETCH_START: function handleSetSuggestedFetchStart() {
2026-08-24 06:08:38 +00:00
c11 = true;
c10 = false;
c12 = true;
2026-07-20 16:05:17 +00:00
},
WIDGET_PENDING_CLEAR: function handleClearPendingWidgets() {
2026-08-24 06:08:38 +00:00
c6 = null;
c7 = null;
2026-07-20 16:05:17 +00:00
},
WIDGET_SUGGESTED_REMOVE_GAME: function handleRemoveApplicationIdFromSuggestedGames(applicationId) {
2026-07-23 10:11:24 +00:00
applicationId = applicationId.applicationId;
2026-08-11 06:20:06 +00:00
const suggestedGamesIds = closure_9.suggestedGamesIds;
closure_9.suggestedGamesIds = suggestedGamesIds.filter((item) => item !== applicationId);
2026-08-11 06:20:06 +00:00
const prop = closure_9.suggestedWishlistGamesIds;
closure_9.suggestedWishlistGamesIds = prop.filter((item) => item !== applicationId);
2026-07-20 16:05:17 +00:00
}
});
const size = fn(2);
const result = size.fileFinishedImporting("modules/user_profile/WidgetStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default widgetStore;