decord/beta/source/utils/GuildRoleRecordUtils.tsx
github-actions 84d017ff78 chore: update source for beta 348.6
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5021.js (118.4 MB)
2026-09-28 16:18:32 +00:00

166 lines
5.4 KiB
TypeScript

// Module ID: 2104
// Function ID: 2105
// Name: GuildRoleRecordUtils
// Dependencies: [2060, 2103, 1086, 1092, 2105, 2]
// Exports: constructGuildRoleInPlace, fromSerializedPartition, fromSyncOperation, isGuildRoleRecord, toSerializedPartition
// Module 2104 (GuildRoleRecordUtils)
import BigFlagUtilsAll from "BigFlagUtils" /* 1086 */;
import utils_ColorUtils from "utils/ColorUtils" /* 1092 */;
import GuildRoleRecord from "GuildRoleRecord" /* 2103 */;
import EnhancedRoleColorUtils from "EnhancedRoleColorUtils" /* 2105 */;
import PlainRecord from "PlainRecord" /* 2060 */;
import size from "module_2" /* 2 */;
function fromServerArray(id, roles) {
const obj = {};
const iter = roles[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
obj[nextResult.id] = fromServer(id, nextResult);
continue;
}
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);
let int2hexResult = null;
if (0 !== id.color) {
int2hexResult = utils_ColorUtils.int2hex(id.color);
}
obj.colorString = int2hexResult;
let colors = id.colors;
if (colors == null) {
colors = null;
}
obj.colors = colors;
let result = null;
if (null != id.colors) {
result = EnhancedRoleColorUtils.extractColorStringsFromServerColors(id.colors);
}
obj.colorStrings = result;
({ hoist: obj.hoist, managed } = id);
if (managed == null) {
managed = false;
}
obj.managed = managed;
let tags = id.tags;
if (tags == null) {
tags = {};
}
obj.tags = tags;
({ icon: obj.icon, unicode_emoji: obj.unicodeEmoji, flags } = id);
if (flags == null) {
flags = 0;
}
obj.flags = flags;
let description = id.description;
if (description == null) {
description = null;
}
obj.description = description;
obj.version = id.version;
return React3(GuildRoleRecordTypeTag, obj);
}
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);
let int2hexResult = null;
if (null != id.color) {
int2hexResult = null;
if (0 !== id.color) {
int2hexResult = utils_ColorUtils.int2hex(id.color);
}
}
obj.colorString = int2hexResult;
let colors = id.colors;
if (colors == null) {
colors = null;
}
obj.colors = colors;
let result = null;
if (null != id.colors) {
result = EnhancedRoleColorUtils.extractColorStringsFromServerColors(id.colors);
}
obj.colorStrings = result;
({ hoist: obj.hoist, managed } = id);
if (managed == null) {
managed = false;
}
obj.managed = managed;
let tags = id.tags;
if (tags == null) {
tags = {};
}
obj.tags = tags;
({ icon: obj.icon, unicodeEmoji: obj.unicodeEmoji, flags } = id);
if (flags == null) {
flags = 0;
}
obj.flags = flags;
let description = id.description;
if (description == null) {
description = null;
}
obj.description = description;
obj.version = id.version;
return React3(GuildRoleRecordTypeTag, obj);
}
({ constructInPlace: c3, objectIsPlainRecordOfType: closure_4 } = PlainRecord);
const GuildRoleRecordTypeTag = GuildRoleRecord.GuildRoleRecordTypeTag;
let result = size.fileFinishedImporting("utils/GuildRoleRecordUtils.tsx");
export const isGuildRoleRecord = function isGuildRoleRecord(arg0) {
return React4(GuildRoleRecordTypeTag, arg0);
};
export { fromServerArray };
export { fromServer };
export const constructGuildRoleInPlace = function constructGuildRoleInPlace(arg0) {
return React3(GuildRoleRecordTypeTag, arg0);
};
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);
const deletes = roles.deletes;
for (const item10013 of deletes) {
delete tmp[tmp2];
continue;
}
const writes = roles.writes;
for (const item10020 of writes) {
obj[item10020.id] = fromServer(arg0, item10020);
continue;
}
return obj;
}
};
export const fromSerializedPartition = function fromSerializedPartition(id, roles) {
const obj = {};
for (const key10006 in arg1) {
obj[key10006] = fromSerialized(arg0, arg1[key10006]);
continue;
}
return obj;
};
export const toSerializedPartition = function toSerializedPartition(unsafeMutableRoles) {
const obj = {};
for (const key10004 in arg0) {
let tmp2 = arg0[key10004];
let obj2 = {};
let merged = Object.assign(tmp2);
let str = tmp2.permissions;
obj2.permissions = str.toString();
obj[key10004] = obj2;
continue;
}
return obj;
};