MonkeyTypes > Types (#2491)

This commit is contained in:
Ferotiq 2022-02-13 13:29:09 -06:00 committed by GitHub
parent a9d2ff7314
commit d152eec6b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 42 additions and 42 deletions

View file

@ -1,5 +1,5 @@
import * as Loader from "./elements/loader";
import * as Types from "./types/interfaces";
import * as MonkeyTypes from "./types/interfaces";
export function getuid(): void {
console.error("Only share this uid with Miodec and nobody else!");
@ -128,10 +128,10 @@ export async function getFunbox(funbox: string): Promise<Funbox | undefined> {
}
type QuoteCollection = {
quotes: Types.Quote[];
quotes: MonkeyTypes.Quote[];
length?: number;
language?: string;
groups: number[][] | Types.Quote[][];
groups: number[][] | MonkeyTypes.Quote[][];
};
let quotes: QuoteCollection;
@ -388,7 +388,7 @@ export async function getReleasesFromGitHub(): Promise<object> {
$("#bottom .version .text").text(data[0].name);
$("#bottom .version").css("opacity", 1);
$("#versionHistory .releases").empty();
data.forEach((release: Types.GithubRelease) => {
data.forEach((release: MonkeyTypes.GithubRelease) => {
if (!release.draft && !release.prerelease) {
$("#versionHistory .releases").append(`
<div class="release">
@ -770,7 +770,7 @@ export function canQuickRestart(
mode: string,
words: number,
time: number,
CustomText: Types.CustomText
CustomText: MonkeyTypes.CustomText
): boolean {
if (
(mode === "words" && words < 1000) ||
@ -905,8 +905,8 @@ export function swapElements(
}
export function getMode2(
config: Types.Config,
randomQuote: Types.Quote
config: MonkeyTypes.Config,
randomQuote: MonkeyTypes.Quote
): string {
const mode = config.mode;
let mode2 = "";

View file

@ -25,7 +25,7 @@ import * as TodayTracker from "../test/today-tracker";
import * as Notifications from "../elements/notifications";
import Page from "./page";
import * as Misc from "../misc";
import * as Types from "../types/interfaces";
import * as MonkeyTypes from "../types/interfaces";
let filterDebug = false;
//toggle filterdebug
@ -36,7 +36,7 @@ export function toggleFilterDebug(): void {
}
}
let filteredResults: Types.Result[] = [];
let filteredResults: MonkeyTypes.Result[] = [];
let visibleTableLines = 0;
function loadMoreLines(lineIndex?: number): void {
@ -115,7 +115,7 @@ function loadMoreLines(lineIndex?: number): void {
if (result.tags !== undefined && result.tags.length > 0) {
result.tags.forEach((tag) => {
DB.getSnapshot().tags.forEach((snaptag: Types.Tag) => {
DB.getSnapshot().tags.forEach((snaptag: MonkeyTypes.Tag) => {
if (tag === snaptag._id) {
tagNames += snaptag.name + ", ";
}
@ -271,7 +271,7 @@ export function update(): void {
filteredResults = [];
$(".pageAccount .history table tbody").empty();
DB.getSnapshot().results.forEach((result: Types.Result) => {
DB.getSnapshot().results.forEach((result: MonkeyTypes.Result) => {
// totalSeconds += tt;
//apply filters
@ -396,7 +396,7 @@ export function update(): void {
} else {
//tags exist
const validTags: string[] = DB.getSnapshot().tags.map(
(t: Types.Tag) => t._id
(t: MonkeyTypes.Tag) => t._id
);
result.tags.forEach((tag) => {
//check if i even need to check tags anymore

View file

@ -26,7 +26,7 @@ import * as CustomThemePopup from "../popups/custom-theme-popup";
import * as ConfigEvent from "../observables/config-event";
import * as ActivePage from "../states/active-page";
import Page from "./page";
import * as Types from "../types/interfaces";
import * as MonkeyTypes from "../types/interfaces";
//todo remove once settings group is converted to ts
interface Group {
@ -629,7 +629,7 @@ function setActiveFunboxButton(): void {
function refreshTagsSettingsSection(): void {
if (firebase.auth().currentUser !== null && DB.getSnapshot() !== null) {
const tagsEl = $(".pageSettings .section.tags .tagsList").empty();
DB.getSnapshot().tags.forEach((tag: Types.Tag) => {
DB.getSnapshot().tags.forEach((tag: MonkeyTypes.Tag) => {
// let tagPbString = "No PB found";
// if (tag.pb != undefined && tag.pb > 0) {
// tagPbString = `PB: ${tag.pb}`;
@ -664,7 +664,7 @@ function refreshTagsSettingsSection(): void {
function refreshPresetsSettingsSection(): void {
if (firebase.auth().currentUser !== null && DB.getSnapshot() !== null) {
const presetsEl = $(".pageSettings .section.presets .presetsList").empty();
DB.getSnapshot().presets.forEach((preset: Types.Preset) => {
DB.getSnapshot().presets.forEach((preset: MonkeyTypes.Preset) => {
presetsEl.append(`
<div class="buttons preset" id="${preset._id}">
<div class="button presetButton">

View file

@ -5,7 +5,7 @@ import * as Config from "../config";
import * as Loader from "../elements/loader";
import axiosInstance from "../axios-instance";
import * as Settings from "../pages/settings";
import * as Types from "../types/interfaces";
import * as MonkeyTypes from "../types/interfaces";
import * as Notifications from "../elements/notifications";
import { AxiosError } from "axios";
@ -67,7 +67,7 @@ function hide(): void {
}
}
interface ConfigChanges extends Types.Config {
interface ConfigChanges extends MonkeyTypes.Config {
tags: string[];
}
@ -85,7 +85,7 @@ async function apply(): Promise<void> {
if ((updateConfig && action === "edit") || action === "add") {
configChanges = Config.getConfigChanges() as ConfigChanges;
const activeTagIds: string[] = [];
DB.getSnapshot().tags.forEach((tag: Types.Tag) => {
DB.getSnapshot().tags.forEach((tag: MonkeyTypes.Tag) => {
if (tag.active) {
activeTagIds.push(tag._id);
}
@ -142,8 +142,8 @@ async function apply(): Promise<void> {
Notifications.add(response.data.message);
} else {
Notifications.add("Preset updated", 1);
const preset: Types.Snapshot = DB.getSnapshot().presets.filter(
(preset: Types.Preset) => preset._id == presetid
const preset: MonkeyTypes.Snapshot = DB.getSnapshot().presets.filter(
(preset: MonkeyTypes.Preset) => preset._id == presetid
)[0];
preset.name = inputVal;
if (updateConfig === true) preset.config = configChanges;
@ -169,7 +169,7 @@ async function apply(): Promise<void> {
} else {
Notifications.add("Preset removed", 1);
DB.getSnapshot().presets.forEach(
(preset: Types.Preset, index: number) => {
(preset: MonkeyTypes.Preset, index: number) => {
if (preset._id === presetid) {
DB.getSnapshot().presets.splice(index, 1);
}

View file

@ -7,7 +7,7 @@ import * as Loader from "../elements/loader";
import * as Settings from "../pages/settings";
import axiosInstance from "../axios-instance";
import * as ResultTagsPopup from "./result-tags-popup";
import * as Types from "../types/interfaces";
import * as MonkeyTypes from "../types/interfaces";
import { AxiosError } from "axios";
export function show(action: string, id?: string, name?: string): void {
@ -121,7 +121,7 @@ async function apply(): Promise<void> {
Notifications.add(response.data.message);
} else {
Notifications.add("Tag updated", 1);
DB.getSnapshot().tags.forEach((tag: Types.Tag) => {
DB.getSnapshot().tags.forEach((tag: MonkeyTypes.Tag) => {
if (tag._id === tagid) {
tag.name = inputVal;
}
@ -147,7 +147,7 @@ async function apply(): Promise<void> {
Notifications.add(response.data.message);
} else {
Notifications.add("Tag removed", 1);
DB.getSnapshot().tags.forEach((tag: Types.Tag, index: number) => {
DB.getSnapshot().tags.forEach((tag: MonkeyTypes.Tag, index: number) => {
if (tag._id === tagid) {
DB.getSnapshot().tags.splice(index, 1);
}
@ -173,7 +173,7 @@ async function apply(): Promise<void> {
Notifications.add(response.data.message);
} else {
Notifications.add("Tag PB cleared", 1);
DB.getSnapshot().tags.forEach((tag: Types.Tag) => {
DB.getSnapshot().tags.forEach((tag: MonkeyTypes.Tag) => {
if (tag._id === tagid) {
tag.personalBests = {};
}

View file

@ -1,6 +1,6 @@
// @ts-ignore
import * as DB from "../db";
import * as Types from "../types/interfaces";
import * as MonkeyTypes from "../types/interfaces";
function update(mode: string): void {
$("#pbTablesPopup table tbody").empty();
@ -13,7 +13,7 @@ function update(mode: string): void {
type PersonalBest = {
acc: number;
consistency: number;
difficulty: Types.Difficulty;
difficulty: MonkeyTypes.Difficulty;
lazyMode: boolean;
language: string;
punctuation: boolean;

View file

@ -6,7 +6,7 @@ import * as Loader from "../elements/loader";
import axiosInstance from "../axios-instance";
import * as Notifications from "../elements/notifications";
import { AxiosError } from "axios";
import * as Types from "../types/interfaces";
import * as MonkeyTypes from "../types/interfaces";
let rating = 0;
@ -25,7 +25,7 @@ type QuoteRatings = {
};
let quoteStats: QuoteStats | null | Record<string, never> = null;
let currentQuote: Types.Quote | null = null;
let currentQuote: MonkeyTypes.Quote | null = null;
function reset(): void {
$(`#quoteRatePopup .quote .text`).text("-");
@ -37,7 +37,7 @@ function reset(): void {
}
export async function getQuoteStats(
quote?: Types.Quote
quote?: MonkeyTypes.Quote
): Promise<QuoteStats | undefined> {
if (quote) currentQuote = quote;
let response;
@ -106,7 +106,7 @@ function updateData(): void {
updateRatingStats();
}
export function show(quote: Types.Quote, shouldReset = true): void {
export function show(quote: MonkeyTypes.Quote, shouldReset = true): void {
if ($("#quoteRatePopupWrapper").hasClass("hidden")) {
if (shouldReset) {
reset();
@ -246,5 +246,5 @@ $("#quoteRatePopup .submitButton").click(() => {
$(".pageTest #rateQuoteButton").click(async () => {
// TODO remove this when done with TestWords
show((TestWords.randomQuote as unknown) as Types.Quote);
show((TestWords.randomQuote as unknown) as MonkeyTypes.Quote);
});

View file

@ -6,14 +6,14 @@ import * as Loader from "../elements/loader";
import * as Notifications from "../elements/notifications";
import axiosInstance from "../axios-instance";
import * as Misc from "../misc";
import * as Types from "../types/interfaces";
import * as MonkeyTypes from "../types/interfaces";
import { AxiosError } from "axios";
const CAPTCHA_ID = 1;
type State = {
previousPopupShowCallback?: () => void;
quoteToReport?: Types.Quote;
quoteToReport?: MonkeyTypes.Quote;
};
type Options = {

View file

@ -11,7 +11,7 @@ import * as QuoteSubmitPopup from "./quote-submit-popup";
import * as QuoteApprovePopup from "./quote-approve-popup";
import * as QuoteReportPopup from "./quote-report-popup";
import * as Misc from "../misc";
import * as Types from "../types/interfaces";
import * as MonkeyTypes from "../types/interfaces";
export let selectedId = 1;
@ -22,7 +22,7 @@ export function setSelectedId(val: number): void {
async function updateResults(searchText: string): Promise<void> {
const quotes = await Misc.getQuotes(Config.language);
const reg = new RegExp(searchText, "i");
const found: Types.Quote[] = [];
const found: MonkeyTypes.Quote[] = [];
quotes.quotes.forEach((quote) => {
const quoteText = quote["text"].replace(/[.,'"/#!$%^&*;:{}=\-_`~()]/g, "");
const test1 = reg.test(quoteText);

View file

@ -3,7 +3,7 @@ import * as DB from "../db";
import * as Loader from "../elements/loader";
import * as Notifications from "../elements/notifications";
import axiosInstance from "../axios-instance";
import * as Types from "../types/interfaces";
import * as MonkeyTypes from "../types/interfaces";
function show(): void {
if ($("#resultEditTagsPanelWrapper").hasClass("hidden")) {
@ -34,7 +34,7 @@ function hide(): void {
export function updateButtons(): void {
$("#resultEditTagsPanel .buttons").empty();
DB.getSnapshot().tags.forEach((tag: Types.Tag) => {
DB.getSnapshot().tags.forEach((tag: MonkeyTypes.Tag) => {
$("#resultEditTagsPanel .buttons").append(
`<div class="button tag" tagid="${tag._id}">${tag.name}</div>`
);
@ -99,7 +99,7 @@ $("#resultEditTagsPanel .confirmButton").click(() => {
Notifications.add(response.data.message);
} else {
Notifications.add("Tags updated.", 1, 2);
DB.getSnapshot().results.forEach((result: Types.Result) => {
DB.getSnapshot().results.forEach((result: MonkeyTypes.Result) => {
if (result._id === resultid) {
result.tags = newtags;
}
@ -109,7 +109,7 @@ $("#resultEditTagsPanel .confirmButton").click(() => {
if (newtags.length > 0) {
newtags.forEach((tag) => {
DB.getSnapshot().tags.forEach((snaptag: Types.Tag) => {
DB.getSnapshot().tags.forEach((snaptag: MonkeyTypes.Tag) => {
if (tag === snaptag._id) {
tagNames += snaptag.name + ", ";
}

View file

@ -9,7 +9,7 @@ import * as Notifications from "../elements/notifications";
import axiosInstance from "../axios-instance";
import * as Settings from "../pages/settings";
import { AxiosError } from "axios";
import * as Types from "../types/interfaces";
import * as MonkeyTypes from "../types/interfaces";
type Input = {
placeholder: string;
@ -583,7 +583,7 @@ list["clearTagPb"] = new SimplePopup(
Loader.hide();
if (res.data.resultCode === 1) {
const tag = DB.getSnapshot().tags.filter(
(t: Types.Tag) => t._id === tagid
(t: MonkeyTypes.Tag) => t._id === tagid
)[0];
tag.pb = 0;
$(