1
0
Fork 0

move utils into utils and globals into globals

This commit is contained in:
ChaotiCryptidz 2022-01-21 22:05:59 +00:00
parent 0695adec71
commit e2042747b8
21 changed files with 45 additions and 46 deletions

View file

@ -1,5 +1,5 @@
import { Component } from "preact";
import { settings } from "./globalSettings";
import { settings } from "./globals/globalSettings";
// @ts-ignore
import style_dark from "./scss/main-dark.scss" assert { type: "css" };

View file

@ -1,6 +1,6 @@
import { BaseAPIResponse } from "./types/api";
import { DoesNotExistError } from "../types/internalErrors";
import { settings } from "../globalSettings";
import { settings } from "../globals/globalSettings";
export function getHeaders(): Record<string, string> {
return {

View file

@ -1,2 +0,0 @@
import { Settings } from "./settings/Settings";
export const settings = new Settings();

View file

@ -1,4 +1,4 @@
import { API } from "./api/API";
import { API } from "../api/API";
import { settings } from "./globalSettings";
export const api = new API(settings);

View file

@ -0,0 +1,2 @@
import { Settings } from "../settings/Settings";
export const settings = new Settings();

View file

@ -27,13 +27,13 @@ import translations from "./translations/index.mjs";
import { Main } from "./pages";
import { NavBar } from "./ui/elements/NavBar";
import { ThemeLoader } from "./ThemeLoader";
import { api } from "./globalAPI";
import { formatDistance } from "./formatDistance";
import { api } from "./globals/globalAPI";
import { formatDistance } from "./utils/formatDistance";
import { getCurrentUrl, route } from "preact-router";
import { pageChecks } from "./pageUtils";
import { pageChecks } from "./pageChecks";
import { playground } from "./playground";
import { render } from "preact";
import { settings } from "./globalSettings";
import { settings } from "./globals/globalSettings";
import i18next from "i18next";
async function onLoad(): Promise<void> {

View file

@ -1,9 +1,6 @@
import { API } from "./api/API";
import { Settings } from "./settings/Settings";
import { route } from "preact-router";
import ClipboardJS from "clipboard";
import UIkit from "uikit";
import i18next from "i18next";
export async function pageChecks(url: string, api: API, settings: Settings): Promise<boolean> {
if (url.startsWith("/set_language")) return;
@ -40,23 +37,3 @@ export async function pageChecks(url: string, api: API, settings: Settings): Pro
}
return false;
}
export function addClipboardNotifications(clipboard: ClipboardJS, timeout = 1000): void {
clipboard.on("success", () => {
UIkit.notification(i18next.t("notification_copy_success"), {
status: "success",
timeout: timeout,
});
});
clipboard.on("error", function (e: Error) {
UIkit.notification(
i18next.t("notification_copy_error", {
error: e.message,
}),
{
status: "danger",
timeout: timeout,
},
);
});
}

View file

@ -1,6 +1,6 @@
import { api } from "./globalAPI";
import { pageChecks } from "./pageUtils";
import { settings } from "./globalSettings";
import { api } from "./globals/globalAPI";
import { pageChecks } from "./pageChecks";
import { settings } from "./globals/globalSettings";
import Router from "preact-router";
import { AccessHomePage } from "./ui/pages/Access/AccessHome";

View file

@ -1,5 +1,5 @@
import { Settings } from "./settings/Settings";
import { settings } from "./globalSettings";
import { settings } from "./globals/globalSettings";
// Playground is a way to debug and test things.
// Anything you put in here is gonna be run on page initial load

View file

@ -1,7 +1,7 @@
import { Button } from "./Button";
import { CodeBlock } from "./CodeBlock";
import { Component, JSX, createRef } from "preact";
import { addClipboardNotifications } from "../../pageUtils";
import { addClipboardNotifications } from "../../utils/clipboardNotifs";
import ClipboardJS from "clipboard";
import FileSaver from "file-saver";
import i18next from "i18next";

View file

@ -1,6 +1,6 @@
import { Component, JSX, createRef } from "preact";
import { MarginInline } from "./MarginInline";
import { addClipboardNotifications } from "../../pageUtils";
import { addClipboardNotifications } from "../../utils/clipboardNotifs";
import ClipboardJS from "clipboard";
import i18next from "i18next";

View file

@ -5,7 +5,7 @@ import { Margin } from "../elements/Margin";
import { PageTitle } from "../elements/PageTitle";
import { Tile } from "../elements/Tile";
import { TokenInfo } from "../../api/types/token";
import { pageChecks } from "../../pageUtils";
import { pageChecks } from "../../pageChecks";
import { route } from "preact-router";
import { sendErrorNotification } from "../elements/ErrorMessage";
import i18next from "i18next";

View file

@ -4,7 +4,7 @@ import { DefaultPageProps } from "../../types/DefaultPageProps";
import { ErrorMessage } from "../elements/ErrorMessage";
import { Margin } from "../elements/Margin";
import { PageTitle } from "../elements/PageTitle";
import { addClipboardNotifications } from "../../pageUtils";
import { addClipboardNotifications } from "../../utils/clipboardNotifs";
import { route } from "preact-router";
import ClipboardJS from "clipboard";
import i18next from "i18next";

View file

@ -8,7 +8,7 @@ import { Form } from "../../../elements/Form";
import { InputWithTitle } from "../../../elements/InputWithTitle";
import { Margin } from "../../../elements/Margin";
import { SecretTitleElement } from "../SecretTitleElement";
import { fileToBase64 } from "../../../../htmlUtils";
import { fileToBase64 } from "../../../../utils/fileToBase64";
import i18next from "i18next";
export class TransitDecrypt extends Component<DefaultPageProps, { plaintext: string }> {

View file

@ -8,7 +8,7 @@ import { Form } from "../../../elements/Form";
import { InputWithTitle } from "../../../elements/InputWithTitle";
import { Margin } from "../../../elements/Margin";
import { SecretTitleElement } from "../SecretTitleElement";
import { fileToBase64 } from "../../../../htmlUtils";
import { fileToBase64 } from "../../../../utils/fileToBase64";
import i18next from "i18next";
export class TransitEncrypt extends Component<DefaultPageProps, { ciphertext: string }> {

View file

@ -9,7 +9,7 @@ import { Form } from "../elements/Form";
import { Margin } from "../elements/Margin";
import { MarginInline } from "../elements/MarginInline";
import { PageTitle } from "../elements/PageTitle";
import { getTranslationCompletePercentage } from "../../translationUtils";
import { getTranslationCompletePercentage } from "../../utils/translationUtils";
import { route } from "preact-router";
import i18next from "i18next";

View file

@ -4,7 +4,7 @@ import { InputWithTitle } from "../../elements/InputWithTitle";
import i18next from "i18next";
// @ts-ignore
import { getTranslationCompletePercentage } from "../../../translationUtils";
import { getTranslationCompletePercentage } from "../../../utils/translationUtils";
import { settingsSavedNotification } from "./Settings";
import translations from "../../../translations/index.mjs";

View file

@ -0,0 +1,22 @@
import i18next from "i18next";
import { UIkit } from "uikit";
export function addClipboardNotifications(clipboard: ClipboardJS, timeout = 1000): void {
clipboard.on("success", () => {
UIkit.notification(i18next.t("notification_copy_success"), {
status: "success",
timeout: timeout,
});
});
clipboard.on("error", function (e: Error) {
UIkit.notification(
i18next.t("notification_copy_error", {
error: e.message,
}),
{
status: "danger",
timeout: timeout,
},
);
});
}

View file

@ -1,5 +1,5 @@
// @ts-ignore
import translations from "./translations/index.mjs";
import translations from "../translations/index.mjs";
export function arrayDiff(
a: string[],