diff options
author | Ven <vendicated@riseup.net> | 2023-02-10 22:33:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-10 22:33:34 +0100 |
commit | 1d995e58f515dbeb908ba34bf70f829bfd3ccfac (patch) | |
tree | df8c540f5656028502288ab4e58e41754f723bc9 /src/utils | |
parent | 6114bc6b168607613d06ae8fb4f29e74c763a417 (diff) | |
download | Vencord-1d995e58f515dbeb908ba34bf70f829bfd3ccfac.tar.gz Vencord-1d995e58f515dbeb908ba34bf70f829bfd3ccfac.tar.bz2 Vencord-1d995e58f515dbeb908ba34bf70f829bfd3ccfac.zip |
Notification API (#467)
Co-authored-by: Ven <vendicated@riseup.net>
Co-authored-by: afn <hey@afn.lol>
Co-authored-by: afn <afnzmn@gmail.com>
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/Queue.ts | 2 | ||||
-rw-r--r-- | src/utils/index.ts | 1 | ||||
-rw-r--r-- | src/utils/margins.ts | 35 | ||||
-rw-r--r-- | src/utils/misc.tsx | 4 | ||||
-rw-r--r-- | src/utils/settingsSync.ts | 1 |
5 files changed, 41 insertions, 2 deletions
diff --git a/src/utils/Queue.ts b/src/utils/Queue.ts index 86eb791..2680f56 100644 --- a/src/utils/Queue.ts +++ b/src/utils/Queue.ts @@ -27,7 +27,7 @@ export class Queue { * @param maxSize The maximum amount of functions that can be queued at once. * If the queue is full, the oldest function will be removed. */ - constructor(public maxSize = Infinity) { } + constructor(public readonly maxSize = Infinity) { } private queue = [] as Array<() => Promisable<unknown>>; diff --git a/src/utils/index.ts b/src/utils/index.ts index b80bde3..cfded6b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -22,6 +22,7 @@ export * from "./debounce"; export * as Discord from "./discord"; export { default as IpcEvents } from "./IpcEvents"; export { default as Logger } from "./Logger"; +export * from "./margins"; export * from "./misc"; export * as Modals from "./modal"; export * from "./onceDefined"; diff --git a/src/utils/margins.ts b/src/utils/margins.ts new file mode 100644 index 0000000..5d7eed7 --- /dev/null +++ b/src/utils/margins.ts @@ -0,0 +1,35 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ + +let styleStr = ""; + +export const Margins: Record<`${"top" | "bottom" | "left" | "right"}${8 | 16 | 20}`, string> = {} as any; + +for (const dir of ["top", "bottom", "left", "right"] as const) { + for (const size of [8, 16, 20] as const) { + const cl = `vc-m-${dir}-${size}`; + Margins[`${dir}${size}`] = cl; + styleStr += `.${cl}{margin-${dir}:${size}px;}`; + } +} + +document.addEventListener("DOMContentLoaded", () => + document.head.append(Object.assign(document.createElement("style"), { + textContent: styleStr, + id: "vencord-margins" + })), { once: true }); diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx index c64d9e1..a41ab67 100644 --- a/src/utils/misc.tsx +++ b/src/utils/misc.tsx @@ -200,3 +200,7 @@ export const checkIntersecting = (el: Element) => { const documentHeight = Math.max(document.documentElement.clientHeight, window.innerHeight); return !(elementBox.bottom < 0 || elementBox.top - documentHeight >= 0); }; + +export function identity<T>(value: T): T { + return value; +} diff --git a/src/utils/settingsSync.ts b/src/utils/settingsSync.ts index 5cd81e7..18e1854 100644 --- a/src/utils/settingsSync.ts +++ b/src/utils/settingsSync.ts @@ -112,7 +112,6 @@ export async function uploadSettingsBackup(showToast = true): Promise<void> { if (file) { try { - console.log(file); await importSettings(new TextDecoder().decode(file.data)); if (showToast) toastSuccess(); } catch (err) { |