decord/source/modules/user_profile/WidgetStore.tsx

268 lines
7.8 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 7231
// Function ID: 7232
2026-07-29 08:29:29 +00:00
// Name: initialize
2026-08-25 06:04:03 +00:00
// Dependencies: [32, 1922, 7227, 589, 1370, 12, 709, 2]
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 7231 (initialize)
2026-08-24 06:08:38 +00:00
import applyDefault from "apply" /* 12 */;
import initializeDefault from "initialize" /* 589 */;
import dispatcherDefault from "dispatcher" /* 709 */;
import isDiscordFrontendDevelopment from "isDiscordFrontendDevelopment" /* 1370 */;
import closure_3 from "_slicedToArray" /* 32 */;
import closure_4 from "mergeGuildAvatar" /* 1922 */;
2026-08-25 06:04:03 +00:00
import closure_5 from "createUserWidgetFromServer" /* 7227 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
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() {
2026-08-24 06:08:38 +00:00
this.waitFor(closure_4);
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;
2026-08-24 06:08:38 +00:00
closure_0 = isUpdatable;
2026-08-11 06:20:06 +00:00
if (!isUpdatable.isUpdatable()) {
let found;
if (closure_7 != null) {
found = arr.find((getUniqueKey) => {
const uniqueKey = getUniqueKey.getUniqueKey();
return uniqueKey === isUpdatable.getUniqueKey();
});
}
tmp = found;
arr = closure_7;
}
return tmp;
});
2026-08-24 06:08:38 +00:00
let found = mapped.filter(isDiscordFrontendDevelopment.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) {
2026-08-24 06:08:38 +00:00
tmp3 = !applyDefault.isEqual(c6, c7);
const obj = applyDefault;
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 tmp4 = callback;
let tmp5 = callback(tmp2, 2);
let obj = tmp5[1];
let value = map.get(tmp5[0]);
let isEqualResult = null != value;
if (isEqualResult) {
let tmp9 = obj;
let tmp10 = value;
isEqualResult = obj.isEqual(tmp7);
}
if (!isEqualResult) {
let tmp11 = obj;
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 tmp15 = callback;
let tmp16 = callback(item10029, 2);
let tmp17 = tmp16[1];
if (!map1.has(tmp16[0])) {
let tmp18 = tmp17;
arr = 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 tmp21 = 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 tmp23 = _null2;
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
}
}
}
}
2026-07-29 08:29:29 +00:00
obj = { changedWidgets: null, removedWidgets: null, hasOrderChanges: null };
obj[0] = items;
obj[1] = items1;
obj[2] = flag;
2026-07-20 16:05:17 +00:00
return obj;
}
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
});
2026-08-24 06:08:38 +00:00
const widgetStore = new WidgetStore(dispatcherDefault, {
2026-07-20 16:05:17 +00:00
WIDGET_PENDING_SET: function handleSetPendingWidgets(widgets) {
2026-07-23 10:11:24 +00:00
widgets = widgets.widgets;
if (null === widgets) {
currentUser = currentUser.getCurrentUser();
2026-07-20 16:05:17 +00:00
if (null != currentUser) {
2026-07-23 10:11:24 +00:00
userProfile = userProfile.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 = [];
}
}
}
},
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((arg0) => arg0 !== applicationId);
const prop = closure_9.suggestedWishlistGamesIds;
closure_9.suggestedWishlistGamesIds = prop.filter((arg0) => arg0 !== applicationId);
2026-07-20 16:05:17 +00:00
}
});
2026-08-24 06:08:38 +00:00
const result = require("set").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;