2024-06-07 01:09:07 +02:00
|
|
|
export enum SettingType {
|
|
|
|
|
String = "string",
|
|
|
|
|
Boolean = "boolean",
|
|
|
|
|
Enum = "enum",
|
|
|
|
|
Float = "float",
|
|
|
|
|
Integer = "integer",
|
|
|
|
|
Code = "code",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type Setting<T = SettingType> = {
|
|
|
|
|
id: string;
|
|
|
|
|
title: string;
|
|
|
|
|
description: string;
|
2024-06-19 08:16:28 +02:00
|
|
|
notImplemented?: boolean;
|
2024-06-07 01:09:07 +02:00
|
|
|
type: T;
|
|
|
|
|
value: T extends SettingType.String | SettingType.Code
|
|
|
|
|
? string
|
|
|
|
|
: T extends SettingType.Boolean
|
|
|
|
|
? boolean
|
|
|
|
|
: T extends SettingType.Float | SettingType.Integer
|
|
|
|
|
? number
|
|
|
|
|
: T extends SettingType.Enum
|
|
|
|
|
? string
|
|
|
|
|
: never;
|
|
|
|
|
min?: T extends SettingType.Float | SettingType.Integer ? number : never;
|
|
|
|
|
max?: T extends SettingType.Float | SettingType.Integer ? number : never;
|
|
|
|
|
step?: T extends SettingType.Float | SettingType.Integer ? number : never;
|
|
|
|
|
options?: T extends SettingType.Enum ? string[] : never;
|
|
|
|
|
language?: T extends SettingType.Code ? string : never;
|
|
|
|
|
path: SettingPages;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export enum SettingPages {
|
2024-06-19 08:16:28 +02:00
|
|
|
Account = "account",
|
2024-06-07 01:09:07 +02:00
|
|
|
Behaviour = "behaviour",
|
|
|
|
|
Advanced = "advanced",
|
2024-06-19 08:16:28 +02:00
|
|
|
Appearance = "appearance",
|
2024-06-07 01:09:07 +02:00
|
|
|
}
|
|
|
|
|
|
2024-06-19 08:16:28 +02:00
|
|
|
export const getSettingsForPath = (
|
|
|
|
|
settingsToFilterIn: Settings,
|
|
|
|
|
path: SettingPages,
|
|
|
|
|
) => settingsToFilterIn.filter((setting) => setting.path === path);
|
|
|
|
|
|
|
|
|
|
export const getSettingById = (settingsToFilterIn: Settings, id: SettingIds) =>
|
|
|
|
|
settingsToFilterIn.find((setting) => setting.id === id);
|
2024-06-07 01:09:07 +02:00
|
|
|
|
2024-06-19 08:16:28 +02:00
|
|
|
export const parseFromJson = (json: Record<string, unknown>) => {
|
|
|
|
|
const finalSettings = structuredClone(settings);
|
2024-06-07 01:09:07 +02:00
|
|
|
|
2024-06-19 08:16:28 +02:00
|
|
|
// Override the default values with the values from the JSON except for the user value
|
|
|
|
|
for (const setting of finalSettings) {
|
|
|
|
|
if (setting.id in json) {
|
|
|
|
|
setting.value = json[setting.id] as (typeof setting)["value"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return finalSettings;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export enum SettingIds {
|
2024-06-20 02:07:56 +02:00
|
|
|
Mfm = "mfm",
|
2024-06-19 08:16:28 +02:00
|
|
|
CustomCSS = "custom-css",
|
|
|
|
|
Theme = "theme",
|
|
|
|
|
CustomEmojis = "custom-emojis",
|
|
|
|
|
ShowContentWarning = "show-content-warning",
|
|
|
|
|
PopupAvatarHover = "popup-avatar-hover",
|
2024-06-29 05:05:50 +02:00
|
|
|
InfiniteScroll = "infinite-scroll",
|
2024-06-19 08:16:28 +02:00
|
|
|
ConfirmDelete = "confirm-delete",
|
|
|
|
|
ConfirmFollow = "confirm-follow",
|
|
|
|
|
ConfirmReblog = "confirm-reblog",
|
|
|
|
|
ConfirmFavourite = "confirm-favourite",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const settings = [
|
2024-06-07 01:09:07 +02:00
|
|
|
{
|
2024-06-20 02:07:56 +02:00
|
|
|
id: SettingIds.Mfm,
|
2024-06-07 01:09:07 +02:00
|
|
|
title: "Render MFM",
|
|
|
|
|
description: "Render Misskey-Flavoured Markdown",
|
|
|
|
|
type: SettingType.Boolean,
|
|
|
|
|
value: false,
|
|
|
|
|
path: SettingPages.Behaviour,
|
2024-06-19 08:16:28 +02:00
|
|
|
notImplemented: true,
|
2024-06-07 01:09:07 +02:00
|
|
|
} as Setting<SettingType.Boolean>,
|
|
|
|
|
{
|
2024-06-19 08:16:28 +02:00
|
|
|
id: SettingIds.CustomCSS,
|
2024-06-07 01:09:07 +02:00
|
|
|
title: "Custom CSS",
|
|
|
|
|
description: "Custom CSS for the UI",
|
|
|
|
|
type: SettingType.Code,
|
|
|
|
|
value: "",
|
|
|
|
|
language: "css",
|
|
|
|
|
path: SettingPages.Appearance,
|
|
|
|
|
} as Setting<SettingType.Code>,
|
|
|
|
|
{
|
2024-06-19 08:16:28 +02:00
|
|
|
id: SettingIds.Theme,
|
2024-06-07 01:09:07 +02:00
|
|
|
title: "Theme",
|
|
|
|
|
description: "UI theme",
|
|
|
|
|
type: SettingType.Enum,
|
|
|
|
|
value: "dark",
|
|
|
|
|
options: ["light", "dark"],
|
|
|
|
|
path: SettingPages.Appearance,
|
|
|
|
|
} as Setting<SettingType.Enum>,
|
|
|
|
|
{
|
2024-06-19 08:16:28 +02:00
|
|
|
id: SettingIds.CustomEmojis,
|
2024-06-07 01:09:07 +02:00
|
|
|
title: "Render Custom Emojis",
|
|
|
|
|
description: "Render custom emojis",
|
|
|
|
|
type: SettingType.Boolean,
|
|
|
|
|
value: true,
|
|
|
|
|
path: SettingPages.Behaviour,
|
|
|
|
|
} as Setting<SettingType.Boolean>,
|
|
|
|
|
{
|
2024-06-19 08:16:28 +02:00
|
|
|
id: SettingIds.ShowContentWarning,
|
2024-06-07 01:09:07 +02:00
|
|
|
title: "Show Content Warning",
|
|
|
|
|
description: "Show content warnings on notes marked sensitive/spoiler",
|
|
|
|
|
type: SettingType.Boolean,
|
|
|
|
|
value: true,
|
|
|
|
|
path: SettingPages.Behaviour,
|
|
|
|
|
} as Setting<SettingType.Boolean>,
|
|
|
|
|
{
|
2024-06-19 08:16:28 +02:00
|
|
|
id: SettingIds.PopupAvatarHover,
|
2024-06-07 01:09:07 +02:00
|
|
|
title: "Popup Profile Hover",
|
|
|
|
|
description: "Show profile popup when hovering over a user's avatar",
|
|
|
|
|
type: SettingType.Boolean,
|
|
|
|
|
value: true,
|
|
|
|
|
path: SettingPages.Behaviour,
|
2024-06-19 08:16:28 +02:00
|
|
|
notImplemented: true,
|
2024-06-07 01:09:07 +02:00
|
|
|
} as Setting<SettingType.Boolean>,
|
2024-06-29 05:05:50 +02:00
|
|
|
{
|
|
|
|
|
id: SettingIds.InfiniteScroll,
|
|
|
|
|
title: "Infinite Scroll",
|
|
|
|
|
description:
|
|
|
|
|
"Automatically load more notes when reaching the bottom of the page",
|
|
|
|
|
type: SettingType.Boolean,
|
|
|
|
|
value: true,
|
|
|
|
|
path: SettingPages.Behaviour,
|
|
|
|
|
} as Setting<SettingType.Boolean>,
|
2024-06-07 01:09:07 +02:00
|
|
|
{
|
2024-06-19 08:16:28 +02:00
|
|
|
id: SettingIds.ConfirmDelete,
|
2024-06-07 01:09:07 +02:00
|
|
|
title: "Confirm Delete",
|
|
|
|
|
description: "Confirm before deleting a note",
|
|
|
|
|
type: SettingType.Boolean,
|
|
|
|
|
value: false,
|
|
|
|
|
path: SettingPages.Behaviour,
|
2024-06-19 08:16:28 +02:00
|
|
|
notImplemented: true,
|
2024-06-07 01:09:07 +02:00
|
|
|
} as Setting<SettingType.Boolean>,
|
|
|
|
|
{
|
2024-06-19 08:16:28 +02:00
|
|
|
id: SettingIds.ConfirmFollow,
|
2024-06-07 01:09:07 +02:00
|
|
|
title: "Confirm Follow",
|
|
|
|
|
description: "Confirm before following/unfollowing a user",
|
|
|
|
|
type: SettingType.Boolean,
|
|
|
|
|
value: false,
|
|
|
|
|
path: SettingPages.Behaviour,
|
2024-06-19 08:16:28 +02:00
|
|
|
notImplemented: true,
|
2024-06-07 01:09:07 +02:00
|
|
|
} as Setting<SettingType.Boolean>,
|
|
|
|
|
{
|
2024-06-19 08:16:28 +02:00
|
|
|
id: SettingIds.ConfirmReblog,
|
2024-06-07 01:09:07 +02:00
|
|
|
title: "Confirm Reblog",
|
|
|
|
|
description: "Confirm before reblogging a note",
|
|
|
|
|
type: SettingType.Boolean,
|
|
|
|
|
value: false,
|
|
|
|
|
path: SettingPages.Behaviour,
|
2024-06-19 08:16:28 +02:00
|
|
|
notImplemented: true,
|
2024-06-07 01:09:07 +02:00
|
|
|
} as Setting<SettingType.Boolean>,
|
|
|
|
|
{
|
2024-06-19 08:16:28 +02:00
|
|
|
id: SettingIds.ConfirmFavourite,
|
2024-06-07 01:09:07 +02:00
|
|
|
title: "Confirm Favourite",
|
|
|
|
|
description: "Confirm before favouriting a note",
|
|
|
|
|
type: SettingType.Boolean,
|
|
|
|
|
value: false,
|
|
|
|
|
path: SettingPages.Behaviour,
|
2024-06-19 08:16:28 +02:00
|
|
|
notImplemented: true,
|
2024-06-07 01:09:07 +02:00
|
|
|
} as Setting<SettingType.Boolean>,
|
|
|
|
|
];
|
2024-06-19 08:16:28 +02:00
|
|
|
|
|
|
|
|
export type Settings = typeof settings;
|