Skip to content

Commit

Permalink
Fix wrong import order of some modules
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Mar 18, 2024
1 parent 8654604 commit 104498d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
24 changes: 6 additions & 18 deletions web/js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {log} from 'log';
import {opts, settings} from 'settings';

settings.init();
log.level = settings.loadOr(opts.LOG_LEVEL, log.DEFAULT);

import {api} from 'api';
import {
pub,
Expand Down Expand Up @@ -36,8 +42,6 @@ import {
} from 'event';
import {gui} from 'gui';
import {keyboard, KEY, joystick, retropad, touch} from 'input';
import {log} from 'log';
import {opts, settings} from 'settings';
import {socket, webrtc} from 'network';
import {debounce} from 'utils';

Expand Down Expand Up @@ -512,22 +516,6 @@ sub(SETTINGS_CHANGED, () => {
// initial app state
setState(app.state.eden);

settings.init();

(() => {
let lvl = settings.loadOr(opts.LOG_LEVEL, log.DEFAULT);
// migrate old log level options
// !to remove at some point
if (isNaN(lvl)) {
console.warn(
`The log value [${lvl}] is not supported! ` +
`The default value [debug] will be used instead.`);
settings.set(opts.LOG_LEVEL, `${log.DEFAULT}`)
lvl = log.DEFAULT
}
log.level = lvl
})();

keyboard.init();
joystick.init();
touch.init();
Expand Down
2 changes: 1 addition & 1 deletion web/js/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const select = (key = '', callback = () => ({}), values = {values: [], labels: [
};
el.append(select);

select.append(_option('none', current === ''));
select.append(_option(0, current === '', 'none'));
values.values.forEach((value, index) => {
select.append(_option(value, current === value, values.labels?.[index]));
});
Expand Down
16 changes: 8 additions & 8 deletions web/js/input/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,6 @@ playerSlider.onkeydown = (e) => {
e.preventDefault();
}

// Bind events for menu
// TODO change this flow
pub(MENU_HANDLER_ATTACHED, {event: 'mousedown', handler: handleMenuDown});
pub(MENU_HANDLER_ATTACHED, {event: 'touchstart', handler: handleMenuDown});
pub(MENU_HANDLER_ATTACHED, {event: 'touchend', handler: handleMenuUp});

sub(DPAD_TOGGLE, (data) => onDpadToggle(data.checked));

/**
* Touch controls.
*
Expand All @@ -311,6 +303,14 @@ sub(DPAD_TOGGLE, (data) => onDpadToggle(data.checked));
*/
export const touch = {
init: () => {
// Bind events for menu
// TODO change this flow
pub(MENU_HANDLER_ATTACHED, {event: 'mousedown', handler: handleMenuDown});
pub(MENU_HANDLER_ATTACHED, {event: 'touchstart', handler: handleMenuDown});
pub(MENU_HANDLER_ATTACHED, {event: 'touchend', handler: handleMenuUp});

sub(DPAD_TOGGLE, (data) => onDpadToggle(data.checked));

// add buttons into the state 🤦
Array.from(document.querySelectorAll('.btn,.btn-big')).forEach((el) => {
vpadState[getKey(el)] = false;
Expand Down
2 changes: 1 addition & 1 deletion web/js/network/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const init = (roomId, wid, zone) => {
let objParams = {room_id: roomId, zone: zone};
if (wid) objParams.wid = wid;
const url = buildUrl(objParams)
console.info(`[ws] connecting to ${url}`);
log.info(`[ws] connecting to ${url}`);
conn = new WebSocket(url.toString());
conn.onopen = () => {
log.info('[ws] <- open connection');
Expand Down

0 comments on commit 104498d

Please sign in to comment.