Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove practiceNag from bits.ts in favor of boot.ts confirm #16290

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion modules/practice/src/main/PracticeUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ final class PracticeUi(helpers: Helpers)(
div(cls := "bar", style := s"width: ${data.progressPercent}%")
),
postForm(action := routes.Practice.reset)(
if ctx.isAuth then (data.nbDoneChapters > 0).option(a(cls := "do-reset")("Reset my progress"))
if ctx.isAuth then
(data.nbDoneChapters > 0).option(
submitButton(cls := "button confirm", title := "You will lose your practice progress!")(
"Reset my progress"
)
)
else a(href := routes.Auth.signup)("Sign up to save your progress")
)
),
Expand Down
11 changes: 0 additions & 11 deletions ui/bits/src/bits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { text, formToXhr } from 'common/xhr';
import flairPickerLoader from './exports/flairPicker';
import { spinnerHtml } from 'common/spinner';
import { wireCropDialog } from './exports/crop';
import { confirm } from 'common/dialog';

// avoid node_modules and pay attention to imports here. we don't want to force people
// to download the entire toastui editor library just to do some light form processing.
Expand Down Expand Up @@ -31,8 +30,6 @@ export function initModule(args: { fn: string } & any): void {
return oauth(args);
case 'pmAll':
return pmAll();
case 'practiceNag':
return practiceNag();
case 'relayForm':
return relayForm();
case 'setAssetInfo':
Expand Down Expand Up @@ -189,14 +186,6 @@ function pmAll() {
});
}

function practiceNag() {
const el = document.querySelector('.do-reset');
if (!(el instanceof HTMLAnchorElement)) return;
el.addEventListener('click', async () => {
if (await confirm('You will lose your practice progress!')) (el.parentNode as HTMLFormElement).submit();
});
}

// ensure maximum browser compatibility here,
// as the oauth page can be embedded in very dubious webviews
function oauth({ danger }: { danger: boolean }) {
Expand Down
Loading