Add more Webpack Commons & utils
This commit is contained in:
parent
bb7332cefd
commit
2105de8ca5
1
src/globals.d.ts
vendored
1
src/globals.d.ts
vendored
|
@ -5,6 +5,7 @@ declare global {
|
|||
export var appSettings: {
|
||||
set(setting: string, v: any): void;
|
||||
};
|
||||
export var DiscordNative: any;
|
||||
|
||||
interface Window {
|
||||
webpackChunkdiscord_app: {
|
||||
|
|
10
src/utils/discord.ts
Normal file
10
src/utils/discord.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { Guild } from "discord-types/general";
|
||||
import { ChannelStore, SelectedChannelStore, GuildStore } from "../webpack/common";
|
||||
|
||||
export function getCurrentChannel() {
|
||||
return ChannelStore.getChannel(SelectedChannelStore.getChannelId());
|
||||
}
|
||||
|
||||
export function getCurrentGuild(): Guild | undefined {
|
||||
return GuildStore.getGuild(getCurrentChannel()?.guild_id);
|
||||
}
|
|
@ -125,3 +125,7 @@ export function humanFriendlyJoin(elements: any[], mapper: (e: any) => string =
|
|||
export function classes(...classes: string[]) {
|
||||
return classes.join(" ");
|
||||
}
|
||||
|
||||
export function sleep(ms: number): Promise<void> {
|
||||
return new Promise(r => setTimeout(r, ms));
|
||||
}
|
||||
|
|
|
@ -8,7 +8,12 @@ export const Margins = lazyWebpack(filters.byProps(["marginTop20"]));
|
|||
|
||||
export let FluxDispatcher: Other.FluxDispatcher;
|
||||
export let React: typeof import("react");
|
||||
|
||||
export let GuildStore: Stores.GuildStore;
|
||||
export let UserStore: Stores.UserStore;
|
||||
export let SelectedChannelStore: Stores.SelectedChannelStore;
|
||||
export let ChannelStore: Stores.ChannelStore;
|
||||
|
||||
export const Forms = {} as {
|
||||
FormTitle: Components.FormTitle;
|
||||
FormSection: any;
|
||||
|
@ -86,7 +91,12 @@ waitFor(["dispatch", "subscribe"], m => {
|
|||
};
|
||||
m.subscribe("CONNECTION_OPEN", cb);
|
||||
});
|
||||
|
||||
waitFor(["getCurrentUser", "initialize"], m => UserStore = m);
|
||||
waitFor("getSortedPrivateChannels", m => ChannelStore = m);
|
||||
waitFor("getCurrentlySelectedChannelId", m => SelectedChannelStore = m);
|
||||
waitFor("getGuildCount", m => GuildStore = m);
|
||||
|
||||
waitFor(["Hovers", "Looks", "Sizes"], m => Button = m);
|
||||
waitFor(filters.byCode("helpdeskArticleId"), m => Switch = m);
|
||||
waitFor(["Positions", "Colors"], m => Tooltip = m);
|
||||
|
|
Loading…
Reference in a new issue