Files
discord-decomp/modules/user_profile/UserProfilePersonalWidget.tsx
T
2026-11-01 12:12:55 +02:00

126 lines
3.2 KiB
TypeScript

// Metro module 5904 (f5905).
import _objectWithoutProperties from "../../_bundle/_objectWithoutProperties";
import { WidgetType } from "../../_bundle/Module5897";
import isUndefinedOrNull from "../../_bundle/isUndefinedOrNull";
const _excluded = ["localDataUri"];
class UserProfilePersonalWidget {
constructor(a0) {
const id = a0.id;
let header = a0.header;
const { top, bottom } = a0;
this.id = id;
this.type = WidgetType.PERSONAL;
if (header == null) {
header = "";
}
this.header = header;
const r2 = top != null;
let top2 = void 0;
if (r2) {
let title = top.title;
if (title == null) {
title = "";
}
let subtitle = top.subtitle;
if (subtitle == null) {
subtitle = "";
}
top2 = {
title,
subtitle,
image: top.image
};
}
this.top = top2;
let r24 = bottom?.entries;
if (r24 == null) {
r24 = [];
}
this.bottom = {
entries: r24.map((item) => item.hideImage === true ? item.image != null ? {
...item,
image: void 0
} : item : item)
};
}
toSubmission() {
const r7 = JSON;
const r2 = this.top != null;
let top = void 0;
if (r2) {
const image = this.top.image;
let image2 = image;
if (image != null) {
const r25 = "localDataUri" in image;
image2 = image;
if (r25) {
image.localDataUri;
image2 = _objectWithoutProperties(image, _excluded);
}
}
top = {
...this.top,
image: image2
};
}
return {
id: this.id,
data: {
type: this.type,
title: r7.stringify({
header: this.header,
top,
bottom: {
...this.bottom,
entries: this.bottom.entries.map((entry) => {
const image = entry.image;
let image2 = image;
if (image != null) {
const r10 = "localDataUri" in image;
image2 = image;
if (r10) {
image.localDataUri;
image2 = _objectWithoutProperties(image, _excluded);
}
}
return {
...entry,
image: image2
};
})
}
})
}
};
}
isDiscardable() {
return this.header.trim() === "" && (this.top == null || this.top.title.trim() === "" && this.top.subtitle.trim() === "" && this.top.image == null) && this.bottom.entries.every((entry) => entry.value.trim() === "" && entry.label.trim() === "" && entry.image == null);
}
isValid() {
return !this.isDiscardable();
}
isEqual(a0) {
return a0 instanceof UserProfilePersonalWidget && (isUndefinedOrNull(this.header, a0.header) && isUndefinedOrNull(this.top, a0.top) && isUndefinedOrNull(this.bottom, a0.bottom));
}
getUniqueKey() {
return this.type;
}
getProfileAnalyticsOptions() {
return {
widgetType: this.type
};
}
getProfileEditAnalyticsOptions() {
return {
widgetEdited: this.type
};
}
}
export function createDefaultPersonalWidgetTop() {
return {
title: "",
subtitle: ""
};
}
export { UserProfilePersonalWidget };