diff --git a/frontend/src/html/pages/settings.html b/frontend/src/html/pages/settings.html index d33167a8e55e..ffe03d7a0dbf 100644 --- a/frontend/src/html/pages/settings.html +++ b/frontend/src/html/pages/settings.html @@ -106,6 +106,27 @@ +
+
+ + result saving + +
+
+ Toggle result saving. When disabled, results will not be saved ( + practice mode + ). +
+
+ + +
+
diff --git a/frontend/src/ts/commandline/commandline-metadata.ts b/frontend/src/ts/commandline/commandline-metadata.ts index c6255d843fbc..21d372364a8c 100644 --- a/frontend/src/ts/commandline/commandline-metadata.ts +++ b/frontend/src/ts/commandline/commandline-metadata.ts @@ -205,6 +205,13 @@ export const commandlineConfigMetadata: CommandlineConfigMetadataObject = { options: "fromSchema", }, }, + resultSavingEnabled: { + subgroup: { + options: "fromSchema", + alias: (val) => (val ? "enabled" : "disabled"), + }, + alias: "results practice incognito", + }, blindMode: { subgroup: { options: "fromSchema", diff --git a/frontend/src/ts/commandline/lists.ts b/frontend/src/ts/commandline/lists.ts index 169212ae540e..671a93d941a2 100644 --- a/frontend/src/ts/commandline/lists.ts +++ b/frontend/src/ts/commandline/lists.ts @@ -1,7 +1,6 @@ import MinBurstCommands from "./lists/min-burst"; import BailOutCommands from "./lists/bail-out"; import QuoteFavoriteCommands from "./lists/quote-favorites"; -import ResultSavingCommands from "./lists/result-saving"; import NavigationCommands from "./lists/navigation"; import ResultScreenCommands from "./lists/result-screen"; import CustomBackgroundCommands from "./lists/custom-background"; @@ -98,10 +97,10 @@ export const commands: CommandsSubgroup = { //account ...TagsCommands, ...PresetsCommands, - ...ResultSavingCommands, //behavior ...buildCommands( + "resultSavingEnabled", "difficulty", "quickRestart", "repeatQuotes", @@ -379,7 +378,6 @@ const lists = { minBurst: MinBurstCommands[0]?.subgroup, funbox: FunboxCommands[0]?.subgroup, tags: TagsCommands[0]?.subgroup, - resultSaving: ResultSavingCommands[0]?.subgroup, ads: adsCommands[0]?.subgroup, }; diff --git a/frontend/src/ts/commandline/lists/result-saving.ts b/frontend/src/ts/commandline/lists/result-saving.ts deleted file mode 100644 index acf1d9600fda..000000000000 --- a/frontend/src/ts/commandline/lists/result-saving.ts +++ /dev/null @@ -1,39 +0,0 @@ -import * as TestState from "../../test/test-state"; -import * as ModesNotice from "../../elements/modes-notice"; -import { Command, CommandsSubgroup } from "../types"; - -const subgroup: CommandsSubgroup = { - title: "Result saving...", - list: [ - { - id: "setResultSavingOff", - display: "off", - alias: "disabled incognito", - exec: (): void => { - TestState.setSaving(false); - void ModesNotice.update(); - }, - }, - { - id: "setResultSavingOn", - display: "on", - alias: "enabled incognito", - exec: (): void => { - TestState.setSaving(true); - void ModesNotice.update(); - }, - }, - ], -}; - -const commands: Command[] = [ - { - id: "setResultSaving", - display: "Result saving...", - icon: "fa-save", - alias: "results", - subgroup, - }, -]; - -export default commands; diff --git a/frontend/src/ts/config-metadata.ts b/frontend/src/ts/config-metadata.ts index 12787734b205..73a6867fd99d 100644 --- a/frontend/src/ts/config-metadata.ts +++ b/frontend/src/ts/config-metadata.ts @@ -209,6 +209,12 @@ export const configMetadata: ConfigMetadataObject = { changeRequiresRestart: false, group: "behavior", }, + resultSavingEnabled: { + icon: "fa-save", + displayString: "result saving", + changeRequiresRestart: false, + group: "behavior", + }, blindMode: { icon: "fa-eye-slash", displayString: "blind mode", diff --git a/frontend/src/ts/constants/default-config.ts b/frontend/src/ts/constants/default-config.ts index 7f2df921e2af..7da4ea735898 100644 --- a/frontend/src/ts/constants/default-config.ts +++ b/frontend/src/ts/constants/default-config.ts @@ -86,6 +86,7 @@ const obj: Config = { minAccCustom: 90, monkey: false, repeatQuotes: "off", + resultSavingEnabled: true, oppositeShiftMode: "off", customBackground: "", customBackgroundSize: "cover", diff --git a/frontend/src/ts/elements/modes-notice.ts b/frontend/src/ts/elements/modes-notice.ts index cac27c4e3696..b1e3b883d98b 100644 --- a/frontend/src/ts/elements/modes-notice.ts +++ b/frontend/src/ts/elements/modes-notice.ts @@ -32,6 +32,7 @@ ConfigEvent.subscribe(({ key }) => { "quickRestart", "customPolyglot", "alwaysShowDecimalPlaces", + "resultSavingEnabled", ]; if (configKeys.includes(key)) { void update(); @@ -49,9 +50,9 @@ export async function update(): Promise { ); } - if (!TestState.savingEnabled) { + if (!Config.resultSavingEnabled) { testModesNotice.appendHtml( - `
saving disabled
`, + `
saving disabled
`, ); } diff --git a/frontend/src/ts/pages/account-settings.ts b/frontend/src/ts/pages/account-settings.ts index c34f216d2928..fbb9ab074549 100644 --- a/frontend/src/ts/pages/account-settings.ts +++ b/frontend/src/ts/pages/account-settings.ts @@ -152,6 +152,7 @@ export function updateUI(): void { updateAuthenticationSections(); updateIntegrationSections(); updateAccountSections(); + void ApeKeyTable.update(updateUI); void BlockedUserTable.update(); updateTabs(); diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts index 72fff7a2da59..5708766857e5 100644 --- a/frontend/src/ts/pages/settings.ts +++ b/frontend/src/ts/pages/settings.ts @@ -80,6 +80,10 @@ async function initGroups(): Promise { ); groups["difficulty"] = new SettingsGroup("difficulty", "button"); groups["quickRestart"] = new SettingsGroup("quickRestart", "button"); + groups["resultSavingEnabled"] = new SettingsGroup( + "resultSavingEnabled", + "button", + ); groups["showAverage"] = new SettingsGroup("showAverage", "button"); groups["keymapMode"] = new SettingsGroup("keymapMode", "button", { updateCallback: () => { diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index 83b8bb5b109e..402cb43f1ba8 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -195,7 +195,7 @@ export function restart(options = {} as RestartOptions): void { options.withSameWordset = true; } - if (TestState.savingEnabled) { + if (Config.resultSavingEnabled) { TestInput.pushKeypressesToHistory(); TestInput.pushErrorToHistory(); TestInput.pushAfkToHistory(); @@ -1192,7 +1192,7 @@ async function saveResult( ): Promise>> { AccountButton.loading(true); - if (!TestState.savingEnabled) { + if (!Config.resultSavingEnabled) { Notifications.add("Result not saved: disabled by user", -1, { duration: 3, customTitle: "Notice", @@ -1355,7 +1355,7 @@ export function fail(reason: string): void { TestInput.pushErrorToHistory(); TestInput.pushAfkToHistory(); void finish(true); - if (!TestState.savingEnabled) return; + if (!Config.resultSavingEnabled) return; const testSeconds = TestStats.calculateTestSeconds(performance.now()); const afkseconds = TestStats.calculateAfkSeconds(testSeconds); let tt = Numbers.roundTo2(testSeconds - afkseconds); diff --git a/frontend/src/ts/test/test-state.ts b/frontend/src/ts/test/test-state.ts index 1b5079d9d377..c7c91884399f 100644 --- a/frontend/src/ts/test/test-state.ts +++ b/frontend/src/ts/test/test-state.ts @@ -5,7 +5,6 @@ export let isRepeated = false; export let isPaceRepeat = false; export let isActive = false; export let activeChallenge: null | Challenge = null; -export let savingEnabled = true; export let bailedOut = false; export let selectedQuoteId = 1; export let activeWordIndex = 0; @@ -31,10 +30,6 @@ export function setActiveChallenge(val: null | Challenge): void { activeChallenge = val; } -export function setSaving(val: boolean): void { - savingEnabled = val; -} - export function setBailedOut(tf: boolean): void { bailedOut = tf; } diff --git a/packages/schemas/src/configs.ts b/packages/schemas/src/configs.ts index 998ce464fbf2..576fe8285518 100644 --- a/packages/schemas/src/configs.ts +++ b/packages/schemas/src/configs.ts @@ -394,6 +394,7 @@ export const ConfigSchema = z difficulty: DifficultySchema, quickRestart: QuickRestartSchema, repeatQuotes: RepeatQuotesSchema, + resultSavingEnabled: z.boolean(), blindMode: z.boolean(), alwaysShowWordsHistory: z.boolean(), singleListCommandLine: SingleListCommandLineSchema,