decord/source/utils/GuildRoleRecordUtils.tsx

167 lines
5.4 KiB
TypeScript
Raw Normal View History

// Module ID: 2017
// Function ID: 2018
// Name: GuildRoleRecordUtils
// Dependencies: [1972, 2016, 1086, 1091, 2018, 2]
2026-07-29 08:29:29 +00:00
// Exports: constructGuildRoleInPlace, fromSerializedPartition, fromSyncOperation, isGuildRoleRecord, toSerializedPartition
2026-07-20 16:05:17 +00:00
// Module 2017 (GuildRoleRecordUtils)
import BigFlagUtilsAll from "BigFlagUtils" /* 1086 */;
import utils_ColorUtils from "utils/ColorUtils" /* 1091 */;
import GuildRoleRecord from "GuildRoleRecord" /* 2016 */;
import EnhancedRoleColorUtils from "EnhancedRoleColorUtils" /* 2018 */;
import PlainRecord from "PlainRecord" /* 1972 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-07-20 16:05:17 +00:00
function fromServerArray(id, roles) {
const obj = {};
2026-07-29 08:29:29 +00:00
const iter = roles[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
obj[nextResult.id] = fromServer(id, nextResult);
continue;
2026-07-20 16:05:17 +00:00
}
return obj;
}
function fromServer(guildId, id) {
const obj = { id: id.id, name: id.name, guildId, permissions: null, mentionable: null, position: null, color: null, colorString: null, colors: null, colorStrings: null, hoist: null, managed: null, tags: null, icon: null, unicodeEmoji: null, flags: null, description: null, version: null };
const deserializer = BigFlagUtilsAll;
obj.permissions = deserializer.deserialize(id.permissions);
({ mentionable: obj.mentionable, position: obj.position, color: obj.color } = id);
2026-07-20 16:05:17 +00:00
let int2hexResult = null;
if (0 !== id.color) {
int2hexResult = utils_ColorUtils.int2hex(id.color);
2026-07-20 16:05:17 +00:00
}
obj.colorString = int2hexResult;
2026-07-29 08:29:29 +00:00
let colors = id.colors;
if (colors == null) {
colors = null;
2026-07-20 16:05:17 +00:00
}
obj.colors = colors;
2026-07-20 16:05:17 +00:00
let result = null;
if (null != id.colors) {
result = EnhancedRoleColorUtils.extractColorStringsFromServerColors(id.colors);
2026-07-20 16:05:17 +00:00
}
obj.colorStrings = result;
({ hoist: obj.hoist, managed } = id);
2026-07-29 08:29:29 +00:00
if (managed == null) {
managed = false;
}
obj.managed = managed;
2026-07-20 16:05:17 +00:00
let tags = id.tags;
2026-07-29 08:29:29 +00:00
if (tags == null) {
2026-07-20 16:05:17 +00:00
tags = {};
}
obj.tags = tags;
({ icon: obj.icon, unicode_emoji: obj.unicodeEmoji, flags } = id);
2026-07-29 08:29:29 +00:00
if (flags == null) {
flags = 0;
2026-07-20 16:05:17 +00:00
}
obj.flags = flags;
2026-07-29 08:29:29 +00:00
let description = id.description;
if (description == null) {
description = null;
2026-07-20 16:05:17 +00:00
}
obj.description = description;
obj.version = id.version;
return React3(GuildRoleRecordTypeTag, obj);
2026-07-20 16:05:17 +00:00
}
function fromSerialized(guildId, id) {
const obj = { id: id.id, name: id.name, guildId, permissions: null, mentionable: null, position: null, color: null, colorString: null, colors: null, colorStrings: null, hoist: null, managed: null, tags: null, icon: null, unicodeEmoji: null, flags: null, description: null, version: null };
const deserializer = BigFlagUtilsAll;
obj.permissions = deserializer.deserialize(id.permissions);
({ mentionable: obj.mentionable, position: obj.position, color: obj.color } = id);
2026-07-20 16:05:17 +00:00
let int2hexResult = null;
if (null != id.color) {
int2hexResult = null;
if (0 !== id.color) {
int2hexResult = utils_ColorUtils.int2hex(id.color);
2026-07-20 16:05:17 +00:00
}
}
obj.colorString = int2hexResult;
2026-07-29 08:29:29 +00:00
let colors = id.colors;
if (colors == null) {
colors = null;
2026-07-20 16:05:17 +00:00
}
obj.colors = colors;
2026-07-20 16:05:17 +00:00
let result = null;
if (null != id.colors) {
result = EnhancedRoleColorUtils.extractColorStringsFromServerColors(id.colors);
2026-07-29 08:29:29 +00:00
}
obj.colorStrings = result;
({ hoist: obj.hoist, managed } = id);
2026-07-29 08:29:29 +00:00
if (managed == null) {
managed = false;
2026-07-20 16:05:17 +00:00
}
obj.managed = managed;
2026-07-20 16:05:17 +00:00
let tags = id.tags;
2026-07-29 08:29:29 +00:00
if (tags == null) {
2026-07-20 16:05:17 +00:00
tags = {};
}
obj.tags = tags;
({ icon: obj.icon, unicodeEmoji: obj.unicodeEmoji, flags } = id);
2026-07-29 08:29:29 +00:00
if (flags == null) {
flags = 0;
2026-07-20 16:05:17 +00:00
}
obj.flags = flags;
2026-07-29 08:29:29 +00:00
let description = id.description;
if (description == null) {
description = null;
2026-07-20 16:05:17 +00:00
}
obj.description = description;
obj.version = id.version;
return React3(GuildRoleRecordTypeTag, obj);
2026-07-20 16:05:17 +00:00
}
({ constructInPlace: c3, objectIsPlainRecordOfType: closure_4 } = PlainRecord);
const GuildRoleRecordTypeTag = GuildRoleRecord.GuildRoleRecordTypeTag;
let result = size.fileFinishedImporting("utils/GuildRoleRecordUtils.tsx");
2026-07-20 16:05:17 +00:00
export const isGuildRoleRecord = function isGuildRoleRecord(arg0) {
return React4(GuildRoleRecordTypeTag, arg0);
2026-07-20 16:05:17 +00:00
};
export { fromServerArray };
export { fromServer };
2026-07-29 08:29:29 +00:00
export const constructGuildRoleInPlace = function constructGuildRoleInPlace(arg0) {
return React3(GuildRoleRecordTypeTag, arg0);
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export { fromSerialized };
export const fromSyncOperation = function fromSyncOperation(id, roles, partition) {
if ("full_sync" === roles.op) {
return fromServerArray(id, roles.items);
} else {
const obj = {};
const merged = Object.assign(partition);
2026-07-29 08:29:29 +00:00
const deletes = roles.deletes;
for (const item10013 of deletes) {
delete tmp[tmp2];
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const writes = roles.writes;
for (const item10020 of writes) {
obj[item10020.id] = fromServer(arg0, item10020);
continue;
2026-07-20 16:05:17 +00:00
}
return obj;
}
};
export const fromSerializedPartition = function fromSerializedPartition(id, roles) {
const obj = {};
for (const key10006 in arg1) {
2026-07-23 10:11:24 +00:00
obj[key10006] = fromSerialized(arg0, arg1[key10006]);
continue;
2026-07-20 16:05:17 +00:00
}
return obj;
};
export const toSerializedPartition = function toSerializedPartition(unsafeMutableRoles) {
const obj = {};
2026-07-29 08:29:29 +00:00
for (const key10004 in arg0) {
let tmp2 = arg0[key10004];
let obj2 = {};
2026-07-20 16:05:17 +00:00
let merged = Object.assign(tmp2);
let str = tmp2.permissions;
obj2.permissions = str.toString();
obj[key10004] = obj2;
2026-07-23 10:11:24 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
return obj;
};