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

Compare "Other Keys" branch with initial blank commit #6

Open
wants to merge 11 commits into
base: initial
Choose a base branch
from

Conversation

mickmister
Copy link
Member

@mickmister mickmister commented Feb 7, 2024

This PR is meant to compare the open PR #4 with the initial commit of the repository, so the whole repository can be reviewed at once here.

Feel free to take a look at previous PRs in isolation:

* horizontal buttons with chord names

* you can add chords to draft view

* add playwright

* add playwright tests

* fix GH workflow artifact upload

* fix GH workflow artifact upload #2

* add code coverage

* fix workflow file

* fix workflow run in background

* hardcode not running server in playwright process

* fix workflow for coverage post

* disable code coverage report in CI

* code coverage continue-on-error

* comment out code coverage in workflow. would rather it be obvious it's "not working"

* code coverage upload artifact

* explicitly stop running server in actions workflow

* use ts-node with nyc

* add server logs to workflow artifacts

* fix stop server pid in workflow

* avoid playwright web server in ci

* change wait pid to sleep

* try other sleep tactic

* make it so playwright video is always recorded

* fix test server path

* change "npm start" to run compiled build

* add "new jam" button

* websocket update works
* add linter

* run lint

* add ci workflow for lint checks etc.

* rename ci job
Comment on lines 34 to 38
export const initJamRouterWebsocket = () => {
jamRouter.ws(ROUTES.JAM_ROOM_WEBSOCKET, (ws, req) => {
connectedSockets.push(ws);
console.log('ws connected');
ws.send(JamView().toString());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the main stuff is pretty much "jammed" 🎸 into this file right now. Planning on separating this into a separate structure like:

  • modules/jam/jam_controller.ts
  • modules/jam/jam_views.tsx

return (
<div
id='jam-view'
hx-ws='message:replaceOuterHTML'
Copy link
Member Author

@mickmister mickmister Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also want to abstract out any things like this. I actually don't think we should use hx-ws here to dictate where the response will go.

The view should not have to "know" what is going to be updated with the websocket message. Instead the websocket messages themselves should contain "out of band" swapping instructions https://htmx.org/extensions/web-sockets/#receiving-messages-from-a-websocket

Comment on lines +145 to +147
hx-post={`${
ROUTES.JAM_ACTIONS_ADD_CHORD
}?${params.toString()}`}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is disgusting, and exactly why I suggest we use functions passed into views to avoid this exact sort of thing, in the comment below

export const JamPage = () => {
return (
<>
<div hx-ws='connect:/jam/ws' />
Copy link
Member Author

@mickmister mickmister Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also want to decouple the URL structure away from the views/components. There should be a functions like:

const makeJamViewWebsocketUrl = () => `connect:/jam/ws`;

const makeAddChordUrl = (chord: string) => `/jam/add_chord?chord=${chord}`;

I think all URL things should be done with functions like these, so there is no knowledge of the URL themselves in the view. Much easier to refactor. They are essentially onClick props, in the form of URL generator functions.

These functions will be defined right next to the handlers that process the requests for that URL. They can use some other defined enum, but I prefer seeing the URL as a magic string when looking at the handler. No other code needs to know the URL structure, as that other code will just use the makeAddChordUrl function etc.

Also, no more onChange handlers because we're not using React 🙂 We let the browser natively manage its form state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant