decord/source/stores/ChannelSectionStore.tsx
2026-08-08 06:10:11 +00:00

781 lines
21 KiB
TypeScript

// Module ID: 5898
// Function ID: 5899
// Name: handlePermissionsChange
// Dependencies: [4217, 5899, 1372, 1891, 3929, 1960, 4124, 1903, 676, 1379, 505, 5900, 1231, 11, 4540, 589, 709, 2]
// Exports: isViewChannelSidebar
// Module 5898 (handlePermissionsChange)
import getHash from "getHash";
import handleReaction from "handleReaction";
import ensureGuildLoaded from "ensureGuildLoaded";
import createGuildRecordFromRust from "createGuildRecordFromRust";
import getUncachedChannelPermissions from "getUncachedChannelPermissions";
import handleConnectionOpen from "handleConnectionOpen";
import closure_9 from "handleConnectionOpen";
import mergeGuildAvatar from "mergeGuildAvatar";
import ME from "ME";
import set from "set";
import { Permissions } from "sum";
import { PersistedStore } from "initialize";
import set from "ensureGuildLoaded";
let closure_12;
let closure_14;
let map1;
let unpackModuleId;
const require = arg1;
function handlePermissionsChange() {
let flag = false;
let flag2 = false;
const keys = Object.keys();
if (keys !== undefined) {
flag2 = flag;
while (keys[tmp] !== undefined) {
let tmp13 = tmp6;
let tmp14 = dependencyMap;
let tmp15 = dependencyMap[tmp6];
let tmp16 = require;
let tmp17 = dependencyMap;
if (tmp15.type === require(5900) /* SidebarType */.SidebarType.VIEW_THREAD) {
let tmp7 = channel;
channel = channel.getChannel(tmp15.channelId);
let canResult = null != channel;
if (canResult) {
let tmp10 = getUncachedChannelPermissions;
let tmp11 = Permissions;
canResult = getUncachedChannelPermissions.can(Permissions.VIEW_CHANNEL, channel);
}
if (canResult) {
continue;
} else {
let tmp12 = dependencyMap;
delete tmp2[tmp3];
flag = true;
continue;
}
continue;
}
continue;
}
}
return flag2;
}
function setIsSearchSidebarOpen() {
let hasSearchStateResult = null != c23;
if (hasSearchStateResult) {
hasSearchStateResult = handleReaction.hasSearchState(c23);
}
if (hasSearchStateResult === c22) {
return false;
} else {
c22 = hasSearchStateResult;
}
}
({ ChannelSections: unpackModuleId, ComponentActions: closure_12 } = ME);
({ isStaticChannelRoute: map1, buildGuildStaticChannelId: closure_14 } = set);
let c16 = false;
let c17 = false;
let c18 = false;
let c19 = true;
let closure_20 = {};
let closure_21 = {};
let c22 = false;
let c23 = null;
class ChannelSectionStore extends PersistedStore {
}
const prototype = ChannelSectionStore.prototype;
prototype["initialize"] = function initialize(isMembersOpen) {
if (null != isMembersOpen) {
let flag = isMembersOpen.isMembersOpen;
if (flag == null) {
flag = false;
}
let flag2 = isMembersOpen.isSummariesOpen;
if (flag2 == null) {
flag2 = false;
}
let flag3 = isMembersOpen.isProfileOpen;
if (flag3 == null) {
flag3 = true;
}
let sidebars = isMembersOpen.sidebars;
if (sidebars == null) {
sidebars = {};
}
let guildSidebars = isMembersOpen.guildSidebars;
if (guildSidebars == null) {
guildSidebars = {};
}
}
const items = [handleReaction];
this.syncWith(items, setIsSearchSidebarOpen);
const items1 = [getUncachedChannelPermissions];
this.syncWith(items1, handlePermissionsChange);
this.waitFor(ensureGuildLoaded, getHash, createGuildRecordFromRust, getUncachedChannelPermissions, handleReaction, handleConnectionOpen, closure_9, mergeGuildAvatar);
};
prototype["getState"] = function getState() {
return { isMembersOpen: c16, isSummariesOpen: c17, isProfileOpen: c19, sidebars: closure_20, guildSidebars: closure_21 };
};
prototype["getSection"] = function getSection(arg0, arg1) {
if (c22) {
return constants.SEARCH;
} else {
let tmp3 = null;
if (null != arg0) {
tmp3 = arg0;
if (callback(arg0)) {
const guildId = store2.getGuildId();
let tmp7 = null;
if (null != guildId) {
tmp7 = callback2(arg0, guildId);
}
tmp3 = tmp7;
}
}
if (null != tmp3) {
if (null != dependencyMap[tmp3]) {
let MEMBERS = constants.SIDEBAR_CHAT;
}
return MEMBERS;
}
if (arg1) {
if (c19) {
MEMBERS = constants.PROFILE;
}
}
if (c17) {
MEMBERS = constants.SUMMARIES;
} else if (c16) {
MEMBERS = constants.MEMBERS;
} else {
MEMBERS = c18 ? tmp15.CONVERSATIONS : tmp15.NONE;
}
}
};
prototype["getSidebarState"] = function getSidebarState(channelId) {
let tmp = null;
if (null != channelId) {
tmp = channelId;
if (callback(channelId)) {
const guildId = store2.getGuildId();
let tmp5 = null;
if (null != guildId) {
tmp5 = callback2(channelId, guildId);
}
tmp = tmp5;
}
}
let tmp7;
if (null != tmp) {
tmp7 = dependencyMap[tmp];
}
return tmp7;
};
prototype["getGuildSidebarState"] = function getGuildSidebarState(arg0) {
let tmp;
if (null != arg0) {
tmp = dependencyMap2[arg0];
}
return tmp;
};
prototype["getCurrentSidebarChannelId"] = function getCurrentSidebarChannelId(channelId) {
let tmp = null;
if (null != channelId) {
tmp = channelId;
if (callback(channelId)) {
const guildId = store2.getGuildId();
let tmp5 = null;
if (null != guildId) {
tmp5 = callback2(channelId, guildId);
}
tmp = tmp5;
}
}
if (null == tmp) {
return null;
} else if (c22) {
return null;
} else {
let tmp9 = null;
if (null != dependencyMap[tmp]) {
if (tmp8.type !== require(5900) /* SidebarType */.SidebarType.VIEW_THREAD) {
if (tmp8.type !== tmp10(5900).SidebarType.VIEW_CHANNEL) {
channelId = null;
}
tmp9 = channelId;
}
channelId = tmp8.channelId;
}
return tmp9;
}
};
prototype["getCurrentSidebarMessageId"] = function getCurrentSidebarMessageId(channelId) {
let tmp = null;
if (null != channelId) {
tmp = channelId;
if (callback(channelId)) {
const guildId = store2.getGuildId();
let tmp5 = null;
if (null != guildId) {
tmp5 = callback2(channelId, guildId);
}
tmp = tmp5;
}
}
if (null == tmp) {
return null;
} else if (c22) {
return null;
} else {
let tmp9 = null;
if (null != dependencyMap[tmp]) {
if (tmp8.type !== require(5900) /* SidebarType */.SidebarType.VIEW_THREAD) {
if (tmp8.type !== tmp10(5900).SidebarType.VIEW_CHANNEL) {
let tmp12 = null;
}
tmp9 = tmp12;
}
const details = tmp8.details;
let initialMessageId;
if (details != null) {
initialMessageId = details.initialMessageId;
}
tmp12 = initialMessageId;
}
return tmp9;
}
};
prototype["getCurrentSearchContextId"] = function getCurrentSearchContextId() {
return c23;
};
ChannelSectionStore.displayName = "ChannelSectionStore";
ChannelSectionStore.persistKey = "ChannelSectionStore2";
const channelSectionStore = new ChannelSectionStore(require("dispatcher"), {
SIDEBAR_SET_SELECTED_SEARCH_CONTEXT: function handleSetSelectedSearchContext(searchContextId) {
searchContextId = searchContextId.searchContextId;
let hasSearchStateResult = null != searchContextId;
if (hasSearchStateResult) {
hasSearchStateResult = handleReaction.hasSearchState(searchContextId);
}
if (hasSearchStateResult !== c22) {
c22 = hasSearchStateResult;
}
return false;
},
CHANNEL_TOGGLE_MEMBERS_SECTION: function handleChannelToggleMembersSection() {
if (c22) {
const ComponentDispatch = require(1231) /* ComponentDispatcher */.ComponentDispatch;
ComponentDispatch.dispatch(constants2.SEARCH_RESULTS_CLOSE);
}
if (c17) {
let flag2 = false;
if (c22) {
c22 = false;
flag2 = true;
}
const channelId = store.getChannelId();
let tmp13 = null;
if (null != channelId) {
tmp13 = channelId;
if (callback(channelId)) {
const guildId = store2.getGuildId();
let tmp17 = null;
if (null != guildId) {
tmp17 = callback2(channelId, guildId);
}
tmp13 = tmp17;
}
}
let tmp19 = null != tmp13;
if (tmp19) {
tmp19 = tmp13 in closure_20;
}
if (tmp19) {
delete tmp[tmp3];
flag2 = true;
}
if (!flag2) {
let tmp22 = !tmp8;
} else {
tmp22 = tmp8;
}
c17 = tmp22;
}
if (c18) {
let flag4 = false;
if (c22) {
c22 = false;
flag4 = true;
}
const channelId1 = store.getChannelId();
let tmp28 = null;
if (null != channelId1) {
tmp28 = channelId1;
if (callback(channelId1)) {
const guildId1 = store2.getGuildId();
let tmp32 = null;
if (null != guildId1) {
tmp32 = callback2(channelId1, guildId1);
}
tmp28 = tmp32;
}
}
let tmp34 = null != tmp28;
if (tmp34) {
tmp34 = tmp28 in closure_20;
}
if (tmp34) {
delete tmp[tmp2];
flag4 = true;
}
if (!flag4) {
let tmp37 = !tmp23;
} else {
tmp37 = tmp23;
}
c18 = tmp37;
}
let flag5 = false;
if (c22) {
c22 = false;
flag5 = true;
}
const channelId2 = store.getChannelId();
let tmp40 = null;
if (null != channelId2) {
tmp40 = channelId2;
if (callback(channelId2)) {
const guildId2 = store2.getGuildId();
let tmp44 = null;
if (null != guildId2) {
tmp44 = callback2(channelId2, guildId2);
}
tmp40 = tmp44;
}
}
let tmp46 = null != tmp40;
if (tmp46) {
tmp46 = tmp40 in closure_20;
}
if (tmp46) {
delete tmp[tmp3];
flag5 = true;
}
if (!flag5) {
let tmp49 = !tmp38;
} else {
tmp49 = tmp38;
}
let c16 = tmp49;
},
USER_PROFILE_SIDEBAR_TOGGLE_SECTION: function handleUserProfileSidebarToggleSection() {
if (!c19) {
const ComponentDispatch = require(1231) /* ComponentDispatcher */.ComponentDispatch;
ComponentDispatch.dispatch(constants2.SEARCH_RESULTS_CLOSE);
}
let flag = false;
if (c22) {
c22 = false;
flag = true;
}
const channelId = store.getChannelId();
let tmp9 = null;
if (null != channelId) {
tmp9 = channelId;
if (callback(channelId)) {
const guildId = store2.getGuildId();
let tmp13 = null;
if (null != guildId) {
tmp13 = callback2(channelId, guildId);
}
tmp9 = tmp13;
}
}
let tmp15 = null != tmp9;
if (tmp15) {
tmp15 = tmp9 in closure_20;
}
if (tmp15) {
delete tmp[tmp2];
flag = true;
}
if (!flag) {
let tmp18 = !tmp7;
} else {
tmp18 = tmp7;
}
c19 = tmp18;
},
CHANNEL_TOGGLE_SUMMARIES_SECTION: function handleChannelToggleSummariesSection() {
if (c16) {
let flag2 = false;
if (c22) {
c22 = false;
flag2 = true;
}
const channelId = store.getChannelId();
let tmp9 = null;
if (null != channelId) {
tmp9 = channelId;
if (callback(channelId)) {
const guildId = store2.getGuildId();
let tmp13 = null;
if (null != guildId) {
tmp13 = callback2(channelId, guildId);
}
tmp9 = tmp13;
}
}
let tmp15 = null != tmp9;
if (tmp15) {
tmp15 = tmp9 in closure_20;
}
if (tmp15) {
delete tmp[tmp3];
flag2 = true;
}
if (!flag2) {
let tmp18 = !tmp4;
} else {
tmp18 = tmp4;
}
c16 = tmp18;
}
if (c18) {
let flag4 = false;
if (c22) {
c22 = false;
flag4 = true;
}
const channelId1 = store.getChannelId();
let tmp24 = null;
if (null != channelId1) {
tmp24 = channelId1;
if (callback(channelId1)) {
const guildId1 = store2.getGuildId();
let tmp28 = null;
if (null != guildId1) {
tmp28 = callback2(channelId1, guildId1);
}
tmp24 = tmp28;
}
}
let tmp30 = null != tmp24;
if (tmp30) {
tmp30 = tmp24 in closure_20;
}
if (tmp30) {
delete tmp[tmp2];
flag4 = true;
}
if (!flag4) {
let tmp33 = !tmp19;
} else {
tmp33 = tmp19;
}
c18 = tmp33;
}
let flag5 = false;
if (c22) {
c22 = false;
flag5 = true;
}
const channelId2 = store.getChannelId();
let tmp36 = null;
if (null != channelId2) {
tmp36 = channelId2;
if (callback(channelId2)) {
const guildId2 = store2.getGuildId();
let tmp40 = null;
if (null != guildId2) {
tmp40 = callback2(channelId2, guildId2);
}
tmp36 = tmp40;
}
}
let tmp42 = null != tmp36;
if (tmp42) {
tmp42 = tmp36 in closure_20;
}
if (tmp42) {
delete tmp[tmp3];
flag5 = true;
}
if (!flag5) {
let tmp45 = !tmp34;
} else {
tmp45 = tmp34;
}
let c17 = tmp45;
},
CHANNEL_TOGGLE_CONVERSATIONS_SECTION: function handleChannelToggleConversationsSection() {
if (c22) {
const ComponentDispatch = require(1231) /* ComponentDispatcher */.ComponentDispatch;
ComponentDispatch.dispatch(constants2.SEARCH_RESULTS_CLOSE);
}
let c16 = false;
let c17 = false;
let flag = false;
if (c22) {
c22 = false;
flag = true;
}
const channelId = store.getChannelId();
let tmp9 = null;
if (null != channelId) {
tmp9 = channelId;
if (callback(channelId)) {
const guildId = store2.getGuildId();
let tmp13 = null;
if (null != guildId) {
tmp13 = callback2(channelId, guildId);
}
tmp9 = tmp13;
}
}
let tmp15 = null != tmp9;
if (tmp15) {
tmp15 = tmp9 in closure_20;
}
if (tmp15) {
delete tmp[tmp2];
flag = true;
}
if (!flag) {
let tmp18 = !tmp7;
} else {
tmp18 = tmp7;
}
let c18 = tmp18;
},
CHANNEL_OPEN_CONVERSATIONS_SECTION: function handleChannelOpenConversationsSection() {
let flag = !c18;
if (!c18) {
if (c22) {
const ComponentDispatch = require(1231) /* ComponentDispatcher */.ComponentDispatch;
ComponentDispatch.dispatch(constants2.SEARCH_RESULTS_CLOSE);
}
let c16 = false;
let c17 = false;
c18 = true;
flag = true;
}
return flag;
},
SIDEBAR_VIEW_CHANNEL: function handleSidebarViewChannel(arg0) {
let baseChannelId;
let channelId;
let details;
let sidebarType;
({ sidebarType, baseChannelId } = arg0);
let c22 = false;
let tmp = null;
({ channelId, details } = arg0);
if (null != baseChannelId) {
tmp = baseChannelId;
if (callback(baseChannelId)) {
const guildId = store2.getGuildId();
let tmp5 = null;
if (null != guildId) {
tmp5 = callback2(baseChannelId, guildId);
}
tmp = tmp5;
}
}
if (null == tmp) {
return false;
} else {
let obj = { type: null, channelId: null, details: null };
obj[0] = sidebarType;
obj[1] = channelId;
obj[2] = details;
let tmp9 = obj;
if (sidebarType === require(5900) /* SidebarType */.SidebarType.VIEW_MOD_REPORT) {
obj = {};
const merged = Object.assign(obj);
obj.baseChannelId = baseChannelId;
tmp9 = obj;
}
closure_20[tmp] = tmp9;
return true;
}
},
SIDEBAR_VIEW_GUILD: function handleSidebarViewGuild(arg0) {
let baseChannelId;
let details;
let guildId;
let sidebarType;
({ guildId, baseChannelId } = arg0);
let c22 = false;
let tmp = null;
({ sidebarType, details } = arg0);
if (null != baseChannelId) {
tmp = baseChannelId;
if (callback(baseChannelId)) {
guildId = store2.getGuildId();
let tmp5 = null;
if (null != guildId) {
tmp5 = callback2(baseChannelId, guildId);
}
tmp = tmp5;
}
}
let flag = null != tmp;
if (flag) {
const obj = { type: null, baseChannelId: null, guildId: null, details: null };
obj[0] = sidebarType;
obj[1] = tmp;
obj[2] = guildId;
obj[3] = details;
closure_21[guildId] = obj;
flag = true;
}
return flag;
},
SIDEBAR_CREATE_THREAD: function handleCreateThread(parentChannelId) {
let _location;
let parentMessageId;
parentChannelId = parentChannelId.parentChannelId;
let c22 = false;
let tmp = null;
({ parentMessageId, location: _location } = parentChannelId);
if (null != parentChannelId) {
tmp = parentChannelId;
if (callback(parentChannelId)) {
const guildId = store2.getGuildId();
let tmp5 = null;
if (null != guildId) {
tmp5 = callback2(parentChannelId, guildId);
}
tmp = tmp5;
}
}
if (null != tmp) {
const obj = { type: null, parentChannelId: null, parentMessageId: null, location: null };
obj[0] = require(5900) /* SidebarType */.SidebarType.CREATE_THREAD;
obj[1] = parentChannelId;
obj[2] = parentMessageId;
obj[3] = _location;
closure_20[tmp] = obj;
}
},
SIDEBAR_CLOSE: function handleCloseSidebar(baseChannelId) {
baseChannelId = baseChannelId.baseChannelId;
let tmp3 = null;
if (null != baseChannelId) {
tmp3 = baseChannelId;
if (callback(baseChannelId)) {
const guildId = store2.getGuildId();
let tmp7 = null;
if (null != guildId) {
tmp7 = callback2(baseChannelId, guildId);
}
tmp3 = tmp7;
}
}
if (null != tmp3) {
delete tmp[tmp2];
}
},
SIDEBAR_CLOSE_GUILD: function handleGuildCloseSidebar(arg0) {
let flag = null != dependencyMap2[arg0.guildId];
if (flag) {
delete tmp[tmp2];
flag = true;
}
return flag;
},
CHANNEL_DELETE: function handleChannelDelete(channel) {
channel = channel.channel;
if (channel.id in dependencyMap) {
const id = channel.id;
delete tmp3[tmp2];
return true;
} else {
let flag = false;
let flag2 = false;
const keys = Object.keys();
if (keys !== undefined) {
flag2 = flag;
while (keys[tmp] !== undefined) {
let tmp16 = tmp11;
let tmp17 = dependencyMap;
let tmp18 = dependencyMap[tmp11];
let tmp14 = null != tmp18;
if (tmp14) {
let tmp12 = require;
let tmp13 = dependencyMap;
tmp14 = tmp18.type === require(5900) /* SidebarType */.SidebarType.VIEW_CHANNEL;
}
if (tmp14) {
tmp14 = tmp18.channelId === channel.id;
}
if (!tmp14) {
continue;
} else {
let tmp15 = dependencyMap;
delete tmp4[tmp5];
flag = true;
continue;
}
continue;
}
}
return flag2;
}
const tmp6 = dependencyMap;
},
CHANNEL_SELECT: function handleChannelSelect() {
if (tmp) {
let c16 = false;
let c17 = false;
let c18 = false;
}
},
THREAD_CREATE: function handleThreadCreate(channel) {
channel = channel.channel;
currentUser = currentUser.getCurrentUser();
let id;
if (currentUser != null) {
id = currentUser.id;
}
if (channel.ownerId === id) {
return false;
} else {
let tmp5 = null != tmp12;
if (tmp5) {
tmp5 = tmp12.type === require(5900) /* SidebarType */.SidebarType.CREATE_THREAD;
}
if (tmp5) {
let obj = importDefault(11);
tmp5 = tmp12.parentMessageId === obj.castChannelIdAsMessageId(channel.id);
}
if (tmp5) {
obj = { type: null, channelId: null };
obj[0] = require(5900) /* SidebarType */.SidebarType.VIEW_THREAD;
obj[1] = channel.id;
dependencyMap[channel.parent_id] = obj;
}
}
},
THREAD_DELETE: function handleThreadDelete(channel) {
channel = channel.channel;
if (null != dependencyMap[channel.parent_id]) {
if (tmp3.type === require(5900) /* SidebarType */.SidebarType.VIEW_THREAD) {
if (tmp3.channelId === channel.id) {
const parent_id = channel.parent_id;
delete tmp2[tmp];
}
}
}
return false;
}
});
const result = set.fileFinishedImporting("stores/ChannelSectionStore.tsx");
export default channelSectionStore;
export const MESSAGE_REQUESTS_BASE_CHANNEL_ID = "message_requests";
export const isViewChannelSidebar = function isViewChannelSidebar(type) {
const items = [require(5900) /* SidebarType */.SidebarType.VIEW_CHANNEL, require(5900) /* SidebarType */.SidebarType.VIEW_THREAD, require(5900) /* SidebarType */.SidebarType.VIEW_MESSAGE_REQUEST, require(5900) /* SidebarType */.SidebarType.VIEW_MOD_REPORT];
return items.includes(type.type);
};