222 lines
6.1 KiB
TypeScript
222 lines
6.1 KiB
TypeScript
// Metro module 15651 (f15652).
|
|
import ChannelSettingsStore from "./ChannelSettingsStore";
|
|
import ChannelStore from "./ChannelStore";
|
|
import { ChannelSettingsSections, FormStates } from "../Constants";
|
|
import { ADVANCED_MODE_ON_KEY } from "../modules/channel_permissions/ChannelPermissionsConstants";
|
|
import { Storage } from "../_bundle/Module595";
|
|
import { makeEveryoneOverwrite, areChannelsLocked } from "../utils/PermissionUtils";
|
|
import Module12 from "../_bundle/Module12";
|
|
import Module589 from "../_bundle/Module589";
|
|
import Dispatcher from "../Dispatcher";
|
|
let c11172_4, c11172_5, c11172_11, CLOSED, c11172_13, c11172_14, c11172_15, channel2, category2, guildId, id, advancedMode2, syncChannelUpdates;
|
|
const init = function init() {
|
|
channel2 = ChannelSettingsStore.getChannel();
|
|
category2 = ChannelSettingsStore.getCategory();
|
|
if (channel2 == null) {
|
|
return false;
|
|
}
|
|
const guildId3 = channel2.getGuildId();
|
|
const guildId2 = channel2.getGuildId();
|
|
const r19 = {
|
|
...channel2.permissionOverwrites
|
|
};
|
|
if (guildId2 != null && r19[guildId2] == null) {
|
|
r19[guildId2] = makeEveryoneOverwrite(guildId2);
|
|
}
|
|
c11172_14 = r19;
|
|
c11172_15 = r19;
|
|
if (r19[guildId] == null) {
|
|
guildId = guildId3;
|
|
}
|
|
c11172_5 = category2 != null;
|
|
c11172_4 = areChannelsLocked(channel2, category2);
|
|
id = null;
|
|
c11172_13 = false;
|
|
CLOSED = FormStates.CLOSED;
|
|
c11172_11.clear();
|
|
};
|
|
syncChannelUpdates = function syncChannelUpdates(a0) {
|
|
if (channel2 != null && channel2.id === a0) {
|
|
const channel3 = ChannelStore.getChannel(a0);
|
|
channel2 = channel3;
|
|
if (channel3 == null) {
|
|
return false;
|
|
}
|
|
category2 = ChannelSettingsStore.getCategory();
|
|
const guildId3 = channel2.getGuildId();
|
|
if (guildId3 == null) {
|
|
return false;
|
|
}
|
|
const guildId2 = channel2.getGuildId();
|
|
const r23 = {
|
|
...channel2.permissionOverwrites
|
|
};
|
|
if (guildId2 != null && r23[guildId2] == null) {
|
|
r23[guildId2] = makeEveryoneOverwrite(guildId2);
|
|
}
|
|
c11172_15 = r23;
|
|
const r33 = {};
|
|
let c22289_0 = r33;
|
|
c11172_11.forEach((item) => {
|
|
if (c11172_14 != null) {
|
|
c22289_0[item] = c11172_14[item];
|
|
}
|
|
});
|
|
if (r33[guildId3] == null && channel2.permissionOverwrites[guildId3] == null) {
|
|
r33[guildId3] = makeEveryoneOverwrite(guildId3);
|
|
}
|
|
const r50 = {
|
|
...channel2.permissionOverwrites,
|
|
...r33
|
|
};
|
|
c11172_14 = r50;
|
|
if (r50[guildId] == null) {
|
|
guildId = guildId3;
|
|
} else if (id != null && c11172_14[id] != null) {
|
|
guildId = id;
|
|
id = null;
|
|
}
|
|
c11172_4 = areChannelsLocked(channel2, category2);
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
c11172_11 = new Set();
|
|
CLOSED = FormStates.CLOSED;
|
|
c11172_13 = false;
|
|
c11172_14 = null;
|
|
c11172_15 = null;
|
|
channel2 = null;
|
|
category2 = null;
|
|
guildId = null;
|
|
id = null;
|
|
advancedMode2 = Storage.get(ADVANCED_MODE_ON_KEY) || false;
|
|
class ChannelSettingsPermissionsStore extends Module589.Store {
|
|
static displayName = "ChannelSettingsPermissionsStore";
|
|
initialize() {
|
|
this.waitFor(ChannelSettingsStore, ChannelStore);
|
|
}
|
|
hasChanges() {
|
|
return c11172_13;
|
|
}
|
|
showNotice() {
|
|
return this.hasChanges();
|
|
}
|
|
getPermissionOverwrite(a0) {
|
|
return c11172_14 == null ? void 0 : c11172_14[a0];
|
|
}
|
|
get editedPermissionIds() {
|
|
return Array.from(c11172_11);
|
|
}
|
|
get permissionOverwrites() {
|
|
return c11172_14;
|
|
}
|
|
get selectedOverwriteId() {
|
|
return guildId;
|
|
}
|
|
get formState() {
|
|
return CLOSED;
|
|
}
|
|
get isLockable() {
|
|
return c11172_5;
|
|
}
|
|
get locked() {
|
|
return c11172_4;
|
|
}
|
|
get channel() {
|
|
return channel2;
|
|
}
|
|
get category() {
|
|
return category2;
|
|
}
|
|
get advancedMode() {
|
|
return advancedMode2;
|
|
}
|
|
}
|
|
const channelSettingsPermissionsStore = new ChannelSettingsPermissionsStore(Dispatcher, {
|
|
CHANNEL_SETTINGS_SET_SECTION: function handleSetSection({ section }) {
|
|
if (channel2 == null && section === ChannelSettingsSections.PERMISSIONS) {
|
|
init();
|
|
return void 0;
|
|
}
|
|
return false;
|
|
},
|
|
CHANNEL_SETTINGS_PERMISSIONS_INIT: init,
|
|
CHANNEL_SETTINGS_PERMISSIONS_UPDATE_PERMISSION: function handleUpdatePermission({ id: id2, allow, deny }) {
|
|
const r5 = c11172_14;
|
|
const r8 = r5 == null ? void 0 : r5[id2];
|
|
if (r8 != null && channel2 != null) {
|
|
const r13 = {
|
|
...r8,
|
|
allow,
|
|
deny
|
|
};
|
|
const r15 = {
|
|
...c11172_14
|
|
};
|
|
r15[id2] = r13;
|
|
c11172_14 = r15;
|
|
c11172_11.add(id2);
|
|
CLOSED = FormStates.OPEN;
|
|
c11172_13 = !Module12.isEqual(c11172_14, c11172_15);
|
|
c11172_4 = areChannelsLocked(channel2, category2);
|
|
return void 0;
|
|
}
|
|
return false;
|
|
},
|
|
CHANNEL_SETTINGS_PERMISSIONS_SELECT_PERMISSION: function handleSelectPermission({ id: id2 }) {
|
|
if (c11172_14 != null && c11172_14[id2] != null) {
|
|
guildId = id2;
|
|
} else {
|
|
if (channel2 == null) {
|
|
return false;
|
|
}
|
|
id = id2;
|
|
}
|
|
},
|
|
CHANNEL_SETTINGS_INIT: function handleInit() {
|
|
if (ChannelSettingsStore.getSection() === ChannelSettingsSections.PERMISSIONS) {
|
|
init();
|
|
}
|
|
},
|
|
CHANNEL_SETTINGS_CLOSE: function handleClose() {
|
|
CLOSED = FormStates.CLOSED;
|
|
c11172_14 = null;
|
|
c11172_15 = null;
|
|
channel2 = null;
|
|
category2 = null;
|
|
c11172_13 = false;
|
|
c11172_11.clear();
|
|
guildId = null;
|
|
id = null;
|
|
},
|
|
CHANNEL_UPDATES: function handleChannelUpdates({ channels }) {
|
|
if (channel2 == null) {
|
|
return false;
|
|
}
|
|
let r22 = false;
|
|
for (const item of channels) {
|
|
if (syncChannelUpdates(item.id) !== false) {
|
|
r22 = true;
|
|
}
|
|
}
|
|
return r22;
|
|
},
|
|
CHANNEL_SETTINGS_PERMISSIONS_SUBMITTING: function handleSubmitting() {
|
|
CLOSED = FormStates.SUBMITTING;
|
|
},
|
|
CHANNEL_SETTINGS_PERMISSIONS_SAVE_SUCCESS: function handleSaveSuccess(a0) {
|
|
if (a0.silent) {
|
|
CLOSED = FormStates.OPEN;
|
|
} else {
|
|
CLOSED = FormStates.CLOSED;
|
|
init();
|
|
}
|
|
},
|
|
CHANNEL_SETTINGS_PERMISSIONS_SET_ADVANCED_MODE: function handleSetAdvancedMode({ advancedMode: advancedMode3 }) {
|
|
advancedMode2 = advancedMode3;
|
|
Storage.set(ADVANCED_MODE_ON_KEY, advancedMode3);
|
|
}
|
|
});
|
|
export default channelSettingsPermissionsStore;
|