Skip to content

Commit f7865f9

Browse files
committed
brr
1 parent 060c501 commit f7865f9

55 files changed

Lines changed: 174 additions & 287 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

frontend/src/ts/auth.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Ape from "./ape";
1212
import { showRegisterCaptchaModal } from "./components/modals/RegisterCaptchaModal";
1313
import { updateFromServer as updateConfigFromServer } from "./config/remote";
1414
import * as DB from "./db";
15-
import * as AuthEvent from "./events/auth";
15+
import { authEvent } from "./events/auth";
1616
import {
1717
isAuthAvailable,
1818
getAuthenticatedUser,
@@ -131,7 +131,7 @@ export async function loadUser(_user: UserType): Promise<void> {
131131
signOut();
132132
return;
133133
}
134-
AuthEvent.dispatch({ type: "snapshotUpdated", data: { isInitial: true } });
134+
authEvent.dispatch({ type: "snapshotUpdated", data: { isInitial: true } });
135135
}
136136

137137
export async function onAuthStateChanged(
@@ -155,7 +155,7 @@ export async function onAuthStateChanged(
155155
void Sentry.clearUser();
156156
}
157157

158-
AuthEvent.dispatch({
158+
authEvent.dispatch({
159159
type: "authStateChanged",
160160
data: { isUserSignedIn: user !== null, loadPromise: userPromise },
161161
});
@@ -231,7 +231,7 @@ async function addAuthProvider(
231231
await linkWithPopup(user, provider);
232232
hideLoaderBar();
233233
showSuccessNotification(`${providerName} authentication added`);
234-
AuthEvent.dispatch({ type: "authConfigUpdated" });
234+
authEvent.dispatch({ type: "authConfigUpdated" });
235235
} catch (error) {
236236
hideLoaderBar();
237237
showErrorNotification(`Failed to add ${providerName} authentication`, {

frontend/src/ts/commandline/lists/themes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as ThemeController from "../../controllers/theme-controller";
55
import { Command, CommandsSubgroup } from "../types";
66
import { ThemesList, ThemeWithName } from "../../constants/themes";
77
import { not } from "@monkeytype/util/predicates";
8-
import * as ConfigEvent from "../../events/config";
8+
import { configEvent } from "../../events/config";
99
import * as getErrorMessage from "../../utils/error";
1010

1111
const isFavorite = (theme: ThemeWithName): boolean =>
@@ -77,7 +77,7 @@ export function update(themes: ThemeWithName[]): void {
7777
}
7878

7979
// subscribe to theme-related config events to update the theme command list
80-
ConfigEvent.subscribe(({ key }) => {
80+
configEvent.subscribe(({ key }) => {
8181
if (key === "favThemes") {
8282
// update themes list when favorites change
8383
try {

frontend/src/ts/components/pages/profile/ProfileSearchPage.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { UserNameSchema } from "@monkeytype/schemas/users";
22
import { createForm } from "@tanstack/solid-form";
33
import { createEffect, createSignal, JSXElement, Show } from "solid-js";
44

5-
import * as NavigationEvent from "../../../events/navigation";
5+
import { navigationEvent } from "../../../events/navigation";
66
import { useRefWithUtils } from "../../../hooks/useRefWithUtils";
77
import { queryClient } from "../../../queries";
88
import { getUserProfile } from "../../../queries/profile";
@@ -27,7 +27,10 @@ export function ProfileSearchPage(): JSXElement {
2727
onSubmit: async ({ value }) => {
2828
setEditable(false);
2929
try {
30-
NavigationEvent.dispatch(`/profile/${value.username}`, {});
30+
navigationEvent.dispatch({
31+
url: `/profile/${value.username}`,
32+
options: {},
33+
});
3134
} finally {
3235
setEditable(true);
3336
}

frontend/src/ts/config/lifecycle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from "./persistence";
1212
import { Config, setConfigStore } from "./store";
1313
import { getDefaultConfig } from "../constants/default-config";
14-
import * as ConfigEvent from "../events/config";
14+
import { configEvent } from "../events/config";
1515
import { migrateConfig } from "./utils";
1616
import { promiseWithResolvers, typedKeys } from "../utils/misc";
1717
import { setConfig } from "./setters";
@@ -76,7 +76,7 @@ export async function applyConfig(
7676
//migrate old values if needed, remove additional keys and merge with default config
7777
const fullConfig: ConfigSchemas.Config = migrateConfig(partialConfig);
7878

79-
ConfigEvent.dispatch({ key: "fullConfigChange" });
79+
configEvent.dispatch({ key: "fullConfigChange" });
8080

8181
const defaultConfig = getDefaultConfig();
8282
for (const key of typedKeys(fullConfig)) {
@@ -107,7 +107,7 @@ export async function applyConfig(
107107
saveToLocalStorage(key);
108108
}
109109

110-
ConfigEvent.dispatch({ key: "fullConfigChangeFinished" });
110+
configEvent.dispatch({ key: "fullConfigChangeFinished" });
111111
setConfigStore(reconcile(Config));
112112
}
113113

frontend/src/ts/config/setters.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ZodType as ZodSchema } from "zod";
33
import { saveToLocalStorage } from "../config/persistence";
44
import { configMetadata, ConfigMetadataObject } from "./metadata";
55
import { isConfigValueValid } from "./validation";
6-
import * as ConfigEvent from "../events/config";
6+
import { configEvent } from "../events/config";
77
import { showNoticeNotification } from "../states/notifications";
88
import {
99
canSetConfigWithCurrentFunboxes,
@@ -124,7 +124,7 @@ export function setConfig<T extends keyof ConfigSchemas.Config>(
124124
if (!options?.nosave) saveToLocalStorage(key, options?.nosave);
125125

126126
// @ts-expect-error i can't figure this out
127-
ConfigEvent.dispatch({
127+
configEvent.dispatch({
128128
key: key,
129129
newValue: value,
130130
nosave: options?.nosave ?? false,
@@ -195,7 +195,7 @@ export function toggleFunbox(funbox: FunboxName, nosave?: boolean): boolean {
195195

196196
Config.funbox = newConfig;
197197
saveToLocalStorage("funbox", nosave);
198-
ConfigEvent.dispatch({
198+
configEvent.dispatch({
199199
key: "funbox",
200200
newValue: Config.funbox,
201201
nosave,

frontend/src/ts/controllers/ad-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* oxlint-disable no-unsafe-member-access */
22
import { debounce } from "throttle-debounce";
3-
import * as ConfigEvent from "../events/config";
3+
import { configEvent } from "../events/config";
44
import { Config } from "../config/store";
55
import * as TestState from "../test/test-state";
66
import * as EG from "./eg-ad-controller";
@@ -286,7 +286,7 @@ window.addEventListener("resize", () => {
286286
debouncedBreakpoint2Update();
287287
});
288288

289-
ConfigEvent.subscribe(({ key, newValue }) => {
289+
configEvent.subscribe(({ key, newValue }) => {
290290
if (key === "ads") {
291291
if (newValue === "off") {
292292
removeAll();

frontend/src/ts/controllers/challenge-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as Funbox from "../test/funbox/funbox";
1010

1111
import { Config } from "../config/store";
1212
import { setConfig } from "../config/setters";
13-
import * as ConfigEvent from "../events/config";
13+
import { configEvent } from "../events/config";
1414
import * as TestState from "../test/test-state";
1515

1616
import { showLoaderBar, hideLoaderBar } from "../states/loader-bar";
@@ -389,7 +389,7 @@ export async function setup(challengeName: string): Promise<boolean> {
389389
}
390390
}
391391

392-
ConfigEvent.subscribe(({ key }) => {
392+
configEvent.subscribe(({ key }) => {
393393
if (
394394
[
395395
"difficulty",

frontend/src/ts/controllers/chart-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Chart.defaults.elements.line.fill = "origin";
6060
import "chartjs-adapter-date-fns";
6161
import { format } from "date-fns/format";
6262
import { Config } from "../config/store";
63-
import * as ConfigEvent from "../events/config";
63+
import { configEvent } from "../events/config";
6464
import * as TestInput from "../test/test-input";
6565
import * as DateTime from "../utils/date-and-time";
6666
import * as Arrays from "../utils/arrays";
@@ -1354,7 +1354,7 @@ createDebouncedEffectOn(125, getTheme, (theme) => {
13541354
void miniResult.updateColors(theme);
13551355
});
13561356

1357-
ConfigEvent.subscribe(({ key, newValue }) => {
1357+
configEvent.subscribe(({ key, newValue }) => {
13581358
if (key === "accountChart" && getActivePage() === "account") {
13591359
updateAccountChartButtons();
13601360
accountHistory.update();

frontend/src/ts/controllers/quotes-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { removeLanguageSize } from "../utils/strings";
22
import { randomElementFromArray, shuffle } from "../utils/arrays";
33
import { cachedFetchJson } from "../utils/json-data";
4-
import { subscribe } from "../events/config";
4+
import { configEvent } from "../events/config";
55
import * as DB from "../db";
66
import Ape from "../ape";
77
import { tryCatch } from "@monkeytype/util/trycatch";
@@ -251,7 +251,7 @@ class QuotesController {
251251

252252
const quoteController = new QuotesController();
253253

254-
subscribe(({ key, newValue }) => {
254+
configEvent.subscribe(({ key, newValue }) => {
255255
if (key === "quoteLength") {
256256
quoteController.updateQuoteQueue(newValue as number[]);
257257
}

frontend/src/ts/controllers/route-controller.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { isAuthAvailable, isAuthenticated } from "../firebase";
55
import { isFunboxActive } from "../test/funbox/list";
66
import * as TestState from "../test/test-state";
77
import { showNoticeNotification } from "../states/notifications";
8-
import * as NavigationEvent from "../events/navigation";
9-
import * as AuthEvent from "../events/auth";
8+
import { navigationEvent, type NavigateOptions } from "../events/navigation";
9+
import { authEvent } from "../events/auth";
1010

1111
//source: https://www.youtube.com/watch?v=OstALBk-jTc
1212
// https://www.youtube.com/watch?v=OstALBk-jTc
@@ -34,7 +34,7 @@ type Route = {
3434
path: string;
3535
load: (
3636
params: Record<string, string>,
37-
navigateOptions: NavigationEvent.NavigateOptions,
37+
navigateOptions: NavigateOptions,
3838
) => Promise<void>;
3939
};
4040

@@ -159,7 +159,7 @@ export async function navigate(
159159
url = window.location.pathname +
160160
window.location.search +
161161
window.location.hash,
162-
options = {} as NavigationEvent.NavigateOptions,
162+
options = {} as NavigateOptions,
163163
): Promise<void> {
164164
if (
165165
!options.force &&
@@ -207,9 +207,7 @@ export async function navigate(
207207
await router(options);
208208
}
209209

210-
async function router(
211-
options = {} as NavigationEvent.NavigateOptions,
212-
): Promise<void> {
210+
async function router(options = {} as NavigateOptions): Promise<void> {
213211
const matches = routes.map((r) => {
214212
return {
215213
route: r,
@@ -249,11 +247,11 @@ document.addEventListener("DOMContentLoaded", () => {
249247
});
250248
});
251249

252-
NavigationEvent.subscribe((url, options) => {
250+
navigationEvent.subscribe(({ url, options }) => {
253251
void navigate(url, options);
254252
});
255253

256-
AuthEvent.subscribe((event) => {
254+
authEvent.subscribe((event) => {
257255
if (event.type === "authStateChanged") {
258256
let keyframes = [
259257
{

0 commit comments

Comments
 (0)