Skip to content

Commit a4b6671

Browse files
authored
refactor(states): Replace jQuery with dom utils in states (@thanoskn) (#7314)
### Description Replaced jQuery with dom utils ### Checks - [x] Adding/modifying Typescript code? - [x] I have used `qs`, `qsa` or `qsr` instead of JQuery selectors. - [x] Check if any open issues are related to this PR; if so, be sure to tag them below. - [x] Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info) - [x] Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title. ### Related issue #7186 , #7319
1 parent bd2df39 commit a4b6671

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

frontend/src/ts/states/connection.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { debounce } from "throttle-debounce";
22
import * as Notifications from "../elements/notifications";
33
import * as ConnectionEvent from "../observables/connection-event";
44
import * as TestState from "../test/test-state";
5+
import { qs, onWindowLoad } from "../utils/dom";
56

67
let state = navigator.onLine;
78

@@ -33,9 +34,9 @@ const throttledHandleState = debounce(5000, () => {
3334
Notifications.add("You're back online", 1, {
3435
customTitle: "Connection",
3536
});
36-
$(
37+
qs(
3738
`#bannerCenter .psa.notice[id="${noInternetBannerId}"] .closeButton`,
38-
).trigger("click");
39+
)?.dispatch("click");
3940
}
4041
bannerAlreadyClosed = false;
4142
} else if (!TestState.isActive) {
@@ -48,7 +49,7 @@ ConnectionEvent.subscribe((newState) => {
4849
throttledHandleState();
4950
});
5051

51-
window.addEventListener("load", () => {
52+
onWindowLoad(() => {
5253
state = navigator.onLine;
5354
if (!state) {
5455
showOfflineBanner();

0 commit comments

Comments
 (0)