mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-21 15:48:52 -05:00
Fix settings properly
This commit is contained in:
parent
907bc25eef
commit
a1487b50be
6 changed files with 32 additions and 47 deletions
|
@ -25,6 +25,7 @@ import ThemesTab from "@components/VencordSettings/ThemesTab";
|
|||
import UpdaterTab from "@components/VencordSettings/UpdaterTab";
|
||||
import VencordTab from "@components/VencordSettings/VencordTab";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getIntlMessage } from "@utils/discord";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { React } from "@webpack/common";
|
||||
|
||||
|
@ -148,13 +149,13 @@ export default definePlugin({
|
|||
|
||||
if (!header) return;
|
||||
|
||||
/* const names = {
|
||||
top: i18n.Messages.USER_SETTINGS,
|
||||
aboveNitro: i18n.Messages.BILLING_SETTINGS,
|
||||
belowNitro: i18n.Messages.APP_SETTINGS,
|
||||
aboveActivity: i18n.Messages.ACTIVITY_SETTINGS
|
||||
const names = {
|
||||
top: getIntlMessage("USER_SETTINGS"),
|
||||
aboveNitro: getIntlMessage("BILLING_SETTINGS"),
|
||||
belowNitro: getIntlMessage("APP_SETTINGS"),
|
||||
aboveActivity: getIntlMessage("ACTIVITY_SETTINGS")
|
||||
};
|
||||
return header === names[settingsLocation]; */
|
||||
return header === names[settingsLocation];
|
||||
},
|
||||
|
||||
patchedSettings: new WeakSet(),
|
||||
|
|
|
@ -19,12 +19,31 @@
|
|||
import "./discord.css";
|
||||
|
||||
import { MessageObject } from "@api/MessageEvents";
|
||||
import { ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, InviteActions, MessageActions, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
||||
import { ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, i18n, InviteActions, MessageActions, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
||||
import { Channel, Guild, Message, User } from "discord-types/general";
|
||||
import { Except } from "type-fest";
|
||||
|
||||
import { runtimeHashMessageKey } from "./intlHash";
|
||||
import { MediaModalItem, MediaModalProps, openMediaModal } from "./modal";
|
||||
|
||||
/**
|
||||
* Get an internationalized message from a non hashed key
|
||||
* @param key The plain message key
|
||||
* @param values The values to interpolate, if it's a rich message
|
||||
*/
|
||||
export function getIntlMessage(key: string, values?: Record<PropertyKey, any>): string {
|
||||
return getIntlMessageFromHash(runtimeHashMessageKey(key), values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an internationalized message from a hashed key
|
||||
* @param key The hashed message key
|
||||
* @param values The values to interpolate, if it's a rich message
|
||||
*/
|
||||
export function getIntlMessageFromHash(key: string, values?: Record<PropertyKey, any>): string {
|
||||
return values == null ? i18n.intl.string(i18n.t[key]) : i18n.intl.format(i18n.t[key], values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the invite modal
|
||||
* @param code The invite code
|
||||
|
|
File diff suppressed because one or more lines are too long
1
src/webpack/common/types/index.d.ts
vendored
1
src/webpack/common/types/index.d.ts
vendored
|
@ -19,7 +19,6 @@
|
|||
export * from "./classes";
|
||||
export * from "./components";
|
||||
export * from "./fluxEvents";
|
||||
export * from "./i18nMessages";
|
||||
export * from "./menu";
|
||||
export * from "./stores";
|
||||
export * from "./utils";
|
||||
|
|
14
src/webpack/common/types/utils.d.ts
vendored
14
src/webpack/common/types/utils.d.ts
vendored
|
@ -21,7 +21,6 @@ import type { ReactNode } from "react";
|
|||
import { LiteralUnion } from "type-fest";
|
||||
|
||||
import type { FluxEvents } from "./fluxEvents";
|
||||
import { i18nMessages } from "./i18nMessages";
|
||||
|
||||
export { FluxEvents };
|
||||
|
||||
|
@ -148,19 +147,6 @@ export interface LocaleInfo {
|
|||
postgresLang: string;
|
||||
}
|
||||
|
||||
export interface i18n {
|
||||
getAvailableLocales(): Locale[];
|
||||
getLanguages(): LocaleInfo[];
|
||||
getDefaultLocale(): string;
|
||||
getLocale(): string;
|
||||
getLocaleInfo(): LocaleInfo;
|
||||
setLocale(locale: string): void;
|
||||
|
||||
loadPromise: Promise<void>;
|
||||
|
||||
Messages: Record<i18nMessages, any>;
|
||||
}
|
||||
|
||||
export interface Clipboard {
|
||||
copy(text: string): void;
|
||||
SUPPORTS_COPY: boolean;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { runtimeHashMessageKey } from "@utils/intlHash";
|
||||
import type { Channel } from "discord-types/general";
|
||||
|
||||
// eslint-disable-next-line path-alias/no-relative
|
||||
|
@ -56,7 +57,10 @@ export const { match, P }: Pick<typeof import("ts-pattern"), "match" | "P"> = ma
|
|||
|
||||
export const lodash: typeof import("lodash") = findByPropsLazy("debounce", "cloneDeep");
|
||||
|
||||
export const i18n: t.i18n = findLazy(m => m.Messages?.["en-US"]);
|
||||
export const i18n = mapMangledModuleLazy('defaultLocale:"en-US"', {
|
||||
intl: filters.byProps("string", "format"),
|
||||
t: filters.byProps(runtimeHashMessageKey("DISCORD"))
|
||||
});
|
||||
|
||||
export let SnowflakeUtils: t.SnowflakeUtils;
|
||||
waitFor(["fromTimestamp", "extractTimestamp"], m => SnowflakeUtils = m);
|
||||
|
|
Loading…
Add table
Reference in a new issue