mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-15 09:33:03 -04:00
improve settings ui (again)
This commit is contained in:
parent
77492061f5
commit
99b41dba19
11 changed files with 308 additions and 186 deletions
62
src/webpack/common/types/utils.d.ts
vendored
62
src/webpack/common/types/utils.d.ts
vendored
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Guild, GuildMember } from "discord-types/general";
|
||||
import { Guild, GuildMember, User } from "discord-types/general";
|
||||
import type { ReactNode } from "react";
|
||||
import { LiteralUnion } from "type-fest";
|
||||
|
||||
|
@ -256,3 +256,63 @@ export interface PopoutActions {
|
|||
close(key: string): void;
|
||||
setAlwaysOnTop(key: string, alwaysOnTop: boolean): void;
|
||||
}
|
||||
|
||||
export type UserNameUtilsTagInclude = LiteralUnion<"auto" | "always" | "never", string>;
|
||||
export interface UserNameUtilsTagOptions {
|
||||
forcePomelo?: boolean;
|
||||
identifiable?: UserNameUtilsTagInclude;
|
||||
decoration?: UserNameUtilsTagInclude;
|
||||
mode?: "full" | "username";
|
||||
}
|
||||
|
||||
export interface UsernameUtils {
|
||||
getGlobalName(user: User): string;
|
||||
getFormattedName(user: User, useTagInsteadOfUsername?: boolean): string;
|
||||
getName(user: User): string;
|
||||
useName(user: User): string;
|
||||
getUserTag(user: User, options?: UserNameUtilsTagOptions): string;
|
||||
useUserTag(user: User, options?: UserNameUtilsTagOptions): string;
|
||||
|
||||
|
||||
useDirectMessageRecipient: any;
|
||||
humanizeStatus: any;
|
||||
}
|
||||
|
||||
export class DisplayProfile {
|
||||
userId: string;
|
||||
banner?: string;
|
||||
bio?: string;
|
||||
pronouns?: string;
|
||||
accentColor?: number;
|
||||
themeColors?: number[];
|
||||
popoutAnimationParticleType?: any;
|
||||
profileEffectId?: string;
|
||||
_userProfile?: any;
|
||||
_guildMemberProfile?: any;
|
||||
canUsePremiumProfileCustomization: boolean;
|
||||
canEditThemes: boolean;
|
||||
premiumGuildSince: Date | null;
|
||||
premiumSince: Date | null;
|
||||
premiumType?: number;
|
||||
primaryColor?: number;
|
||||
|
||||
getBadges(): Array<{
|
||||
id: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
link?: string;
|
||||
}>;
|
||||
getBannerURL(options: { canAnimate: boolean; size: number; }): string;
|
||||
getLegacyUsername(): string | null;
|
||||
hasFullProfile(): boolean;
|
||||
hasPremiumCustomization(): boolean;
|
||||
hasThemeColors(): boolean;
|
||||
isUsingGuildMemberBanner(): boolean;
|
||||
isUsingGuildMemberBio(): boolean;
|
||||
isUsingGuildMemberPronouns(): boolean;
|
||||
}
|
||||
|
||||
export interface DisplayProfileUtils {
|
||||
getDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null;
|
||||
useDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,25 @@ const ToastPosition = {
|
|||
BOTTOM: 1
|
||||
};
|
||||
|
||||
export interface ToastData {
|
||||
message: string,
|
||||
id: string,
|
||||
/**
|
||||
* Toasts.Type
|
||||
*/
|
||||
type: number,
|
||||
options?: ToastOptions;
|
||||
}
|
||||
|
||||
export interface ToastOptions {
|
||||
/**
|
||||
* Toasts.Position
|
||||
*/
|
||||
position?: number;
|
||||
component?: React.ReactNode,
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
export const Toasts = {
|
||||
Type: ToastType,
|
||||
Position: ToastPosition,
|
||||
|
@ -81,23 +100,9 @@ export const Toasts = {
|
|||
|
||||
// hack to merge with the following interface, dunno if there's a better way
|
||||
...{} as {
|
||||
show(data: {
|
||||
message: string,
|
||||
id: string,
|
||||
/**
|
||||
* Toasts.Type
|
||||
*/
|
||||
type: number,
|
||||
options?: {
|
||||
/**
|
||||
* Toasts.Position
|
||||
*/
|
||||
position?: number;
|
||||
component?: React.ReactNode,
|
||||
duration?: number;
|
||||
};
|
||||
}): void;
|
||||
show(data: ToastData): void;
|
||||
pop(): void;
|
||||
create(message: string, type: number, options?: ToastOptions): ToastData;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -105,18 +110,15 @@ export const Toasts = {
|
|||
waitFor("showToast", m => {
|
||||
Toasts.show = m.showToast;
|
||||
Toasts.pop = m.popToast;
|
||||
Toasts.create = m.createToast;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Show a simple toast. If you need more options, use Toasts.show manually
|
||||
*/
|
||||
export function showToast(message: string, type = ToastType.MESSAGE) {
|
||||
Toasts.show({
|
||||
id: Toasts.genId(),
|
||||
message,
|
||||
type
|
||||
});
|
||||
export function showToast(message: string, type = ToastType.MESSAGE, options?: ToastOptions) {
|
||||
Toasts.show(Toasts.create(message, type, options));
|
||||
}
|
||||
|
||||
export const UserUtils = {
|
||||
|
@ -172,3 +174,9 @@ export const PopoutActions: t.PopoutActions = mapMangledModuleLazy('type:"POPOUT
|
|||
close: filters.byCode('type:"POPOUT_WINDOW_CLOSE"'),
|
||||
setAlwaysOnTop: filters.byCode('type:"POPOUT_WINDOW_SET_ALWAYS_ON_TOP"'),
|
||||
});
|
||||
|
||||
export const UsernameUtils: t.UsernameUtils = findByPropsLazy("useName", "getGlobalName");
|
||||
export const DisplayProfileUtils: t.DisplayProfileUtils = mapMangledModuleLazy(/=\i\.getUserProfile\(\i\),\i=\i\.getGuildMemberProfile\(/, {
|
||||
getDisplayProfile: filters.byCode(".getGuildMemberProfile("),
|
||||
useDisplayProfile: filters.byCode(/\[\i\.\i,\i\.\i],\(\)=>/)
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue