Skip to content

Commit

Permalink
remove practiceNag from bits.ts as it requires dialog.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
schlawg committed Oct 30, 2024
1 parent 80c3e0d commit f5a116e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
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

0 comments on commit f5a116e

Please sign in to comment.