Skip to content

Commit 71e1a40

Browse files
committed
use absolute imports
Also init howler after click, to avoid warning.
1 parent 57d8fb9 commit 71e1a40

20 files changed

+86
-71
lines changed

src/main/client/src/Login.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
22
Form,
3-
} from "./component/Form.jsx"
3+
} from "src/component/Form.jsx"
44
import {
55
Input,
6-
} from "./component/Input.jsx"
6+
} from "src/component/Input.jsx"
77
import {
88
Button,
9-
} from "./component/Button.jsx"
9+
} from "src/component/Button.jsx"
1010
import {
1111
useNavigate,
1212
} from "react-router-dom"
@@ -17,10 +17,10 @@ import {
1717
base,
1818
tfetch,
1919
doTry,
20-
} from "./util.js"
20+
} from "src/util.js"
2121
import {
2222
useAuthStore,
23-
} from "./store.js"
23+
} from "src/store.js"
2424

2525
export function Login() {
2626
let navigate = useNavigate()

src/main/client/src/Router.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ import {
1919
} from "tailwind-merge"
2020
import {
2121
useAuthStore,
22-
} from "./store.js"
22+
} from "src/store.js"
2323
import {
2424
Login,
25-
} from "./Login.jsx"
25+
} from "src/Login.jsx"
2626
import {
2727
Lobby,
28-
} from "./feature/lobby/Lobby.jsx"
28+
} from "src/feature/lobby/Lobby.jsx"
2929
import {
3030
Game,
31-
} from "./feature/game/Game.jsx"
31+
} from "src/feature/game/Game.jsx"
3232
import {
3333
base,
3434
StompContext,
35-
} from "./util.js"
35+
} from "src/util.js"
3636
import {
3737
useLayoutStore,
38-
} from "./layout.js"
38+
} from "src/layout.js"
3939

4040
export const Router = createBrowserRouter(
4141
createRoutesFromElements(

src/main/client/src/component/Chat.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import {
1010
} from "tailwind-merge"
1111
import {
1212
useAuthStore,
13-
} from "../store.js"
13+
} from "src/store.js"
1414
import {
1515
StompContext,
1616
tfetch,
1717
doTry,
18-
} from "../util.js"
18+
} from "src/util.js"
1919

2020
export const Chat = ({chatId}) => {
2121
let [messages, setMessages] = useState([])
@@ -79,7 +79,7 @@ export const Chat = ({chatId}) => {
7979
let data = new FormData(event.target)
8080
event.target.reset()
8181
stompClient.publish({
82-
destination: "/app/chat/send/",
82+
destination: "/app/chat/send",
8383
body: JSON.stringify({
8484
message: data.get("message"),
8585
id: chatId,

src/main/client/src/component/SideBar.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
import {
88
vw,
99
sanitizeSidebarWidth,
10-
} from "../util.js"
10+
} from "src/util.js"
1111
import {
1212
useLayoutStore,
1313
useViewStateStore,
14-
} from "../layout.js"
14+
} from "src/layout.js"
1515

1616
export const SideBar = ({page, children}) => {
1717
let dragging = useViewStateStore(state => state.dragging)

src/main/client/src/feature/game/Game.jsx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ import {
1717
BLACK,
1818
tfetch,
1919
doTry,
20-
} from "../../util.js"
20+
} from "src/util.js"
2121
import {
2222
PointList,
23-
} from "../../model/PointList.js"
23+
} from "src/model/PointList.js"
2424
import {
2525
useAuthStore,
2626
useGameStore,
2727
useMuteStore,
28-
} from "../../store.js"
28+
} from "src/store.js"
2929
import {
3030
useLayoutStore,
3131
useViewStateStore,
32-
} from "../../layout.js"
32+
} from "src/layout.js"
3333
import {
3434
paintShadow,
3535
paintGrid,
@@ -79,12 +79,21 @@ export const Game = () => {
7979
let dragging = useLayoutStore(state => state.dragging)
8080
let muted = useMuteStore(state => state.muted)
8181
let setMuteState = useMuteStore((state) => state.setMuted)
82-
let sound = useMemo(() => new Howl({
83-
src: ["/app/stone1.wav"],
84-
onloaderror: function (id, error) {
85-
throw new Error(id + ": " + error)
82+
let howler = useRef()
83+
let playClickSound = useCallback(() => {
84+
if (muted) {
85+
return
86+
}
87+
if (!howler.current) {
88+
howler.current = new Howl({
89+
src: ["/app/stone1.wav"],
90+
onloaderror: (id, error) => {
91+
throw new Error(id + ": " + error)
92+
},
93+
})
8694
}
87-
}),[])
95+
howler.current.play()
96+
}, [howler, muted])
8897

8998
let context = useMemo(() => {
9099
let dim = board.length
@@ -204,14 +213,12 @@ export const Game = () => {
204213
if (!isSelfPlay()) { // myColor is 0 in self play
205214
addMove({...move, color: myColor})
206215
}
207-
if (!muted) {
208-
sound.play();
209-
}
216+
playClickSound()
210217
stompClient.publish({
211218
destination: "/app/game/move",
212219
body: JSON.stringify(move),
213220
})
214-
}, [context, currentPlayer, currentColor, auth, board, stompClient, counting, forbidden_x, forbidden_y, gameHasEnded, movesLength, addMove, isSelfPlay, myColor, muted, sound])
221+
}, [context, currentPlayer, currentColor, auth, board, stompClient, counting, forbidden_x, forbidden_y, gameHasEnded, movesLength, addMove, isSelfPlay, myColor, playClickSound])
215222

216223
let onMuteClick = useCallback(() => {
217224
if (muted) {

src/main/client/src/feature/game/GamePanel.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ import {
2323
TERRITORY_B,
2424
TERRITORY_W,
2525
base,
26-
} from "../../util.js"
26+
} from "src/util.js"
2727
import {
2828
Button,
29-
} from "../../component/Button.jsx"
29+
} from "src/component/Button.jsx"
3030
import {
3131
useAuthStore,
3232
useGameStore,
33-
} from "../../store.js"
33+
} from "src/store.js"
3434
import {
3535
useViewStateStore,
36-
} from "../../layout.js"
36+
} from "src/layout.js"
3737
import {
3838
Chat,
39-
} from "../../component/Chat.jsx"
39+
} from "src/component/Chat.jsx"
4040
import {
4141
SideBar,
42-
} from "../../component/SideBar.jsx"
42+
} from "src/component/SideBar.jsx"
4343

4444
export const GamePanel = () => {
4545
return (

src/main/client/src/feature/game/paint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
TERRITORY_B,
55
REMOVED_B,
66
ANY_REMOVED,
7-
} from "../../util.js"
7+
} from "src/util.js"
88

99
const kirsch = "#dfbd6d"
1010
const asch = "#8c7130"

src/main/client/src/feature/lobby/ActiveGames.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import {
1515
StompContext,
1616
tfetch,
1717
doTry,
18-
} from "../../util.js"
18+
} from "src/util.js"
1919
import {
2020
useAuthStore,
2121
useGameStore,
22-
} from "../../store.js"
22+
} from "src/store.js"
2323

2424
export function ActiveGames() {
2525
let [activeGames, setActiveGames] = useState([])

src/main/client/src/feature/lobby/Lobby.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import {
1212
} from "react-router-dom"
1313
import {
1414
Button,
15-
} from "../../component/Button.jsx"
15+
} from "src/component/Button.jsx"
1616
import {
1717
base,
1818
StompContext,
1919
tfetch,
2020
doTry,
21-
} from "../../util.js"
21+
} from "src/util.js"
2222
import {
2323
LobbyPanel,
2424
} from "./LobbyPanel.jsx"
@@ -30,7 +30,7 @@ import {
3030
} from "./ActiveGames.jsx"
3131
import {
3232
useAuthStore,
33-
} from "../../store.js"
33+
} from "src/store.js"
3434
import {
3535
CgClose,
3636
} from "react-icons/cg"

src/main/client/src/feature/lobby/LobbyPanel.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import {
44
import {
55
tfetch,
66
doTry,
7-
} from "../../util.js"
7+
} from "src/util.js"
88
import {
99
useAuthStore,
10-
} from "../../store.js"
10+
} from "src/store.js"
1111
import {
1212
Chat,
13-
} from "../../component/Chat.jsx"
13+
} from "src/component/Chat.jsx"
1414
import {
1515
SideBar,
16-
} from "../../component/SideBar.jsx"
16+
} from "src/component/SideBar.jsx"
1717

1818
export const LobbyPanel = () => {
1919
return (

src/main/client/src/feature/lobby/OpenGames.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ import {
2121
} from "react-router-dom"
2222
import {
2323
Form,
24-
} from "../../component/Form.jsx"
24+
} from "src/component/Form.jsx"
2525
import {
2626
Button,
27-
} from "../../component/Button.jsx"
27+
} from "src/component/Button.jsx"
2828
import {
2929
base,
3030
StompContext,
3131
tfetch,
3232
doTry,
33-
} from "../../util.js"
33+
} from "src/util.js"
3434
import {
3535
useAuthStore,
3636
useGameStore,
37-
} from "../../store.js"
37+
} from "src/store.js"
3838

3939
export function OpenGames() {
4040
let [openGames, setOpenGames] = useState([])

src/main/client/src/index.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import ReactDOM from "react-dom/client"
2-
import "./index.css"
2+
import "src/index.css"
33
import {
44
Client,
55
} from "@stomp/stompjs"
66
import {
77
StompContext,
8-
} from "./util.js"
8+
} from "src/util.js"
99
import {
1010
RouterProvider,
1111
} from "react-router-dom"
1212
import {
1313
Router,
14-
} from "./Router.jsx"
14+
} from "src/Router.jsx"
1515

1616
const stompClient = new Client({
1717
brokerURL: "ws://" + location.host + "/app/ws/action"

src/main/client/src/model/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import {
1111
BLACK,
1212
WHITE,
13-
} from "../util.js"
13+
} from "src/util.js"
1414

1515
export function updateBoard(board, move) {
1616
if (move.action === "pass") {

src/main/client/src/model/board.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "./PointSet.js"
1010
import {
1111
hasStone,
12-
} from "../util.js"
12+
} from "src/util.js"
1313

1414
export function getGroupInfo(board, xx, yy) {
1515
let color = board[yy][xx]

src/main/client/src/model/board.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import {
1010
BLACK,
1111
WHITE,
12-
} from "../util.js"
12+
} from "src/util.js"
1313

1414
test("liberties", () => {
1515
let b = BLACK

src/main/client/src/model/count.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
TOGGLE_B,
1818
TOGGLE_W,
1919
TOGGLE_STUFF,
20-
} from "../util.js"
20+
} from "src/util.js"
2121

2222
export function count(board) {
2323
let acc = createAcc(board.length)

src/main/client/src/model/count.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
TERRITORY_W,
1515
REMOVED_W,
1616
REMOVED_B,
17-
} from "../util.js"
17+
} from "src/util.js"
1818

1919
test("basicCount", () => {
2020
let B = BLACK

src/main/client/src/model/ko.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
import {
55
BLACK,
66
WHITE,
7-
} from "../util.js"
7+
} from "src/util.js"
88

99
const NOT_FORBIDDEN = [-1, -1]
1010

src/main/client/src/store.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ import {
1111
BLACK,
1212
WHITE,
1313
COLORS,
14-
} from "./util.js"
14+
} from "src/util.js"
1515
import {
1616
rehydrate,
17-
} from "./model/board.js"
17+
} from "src/model/board.js"
1818
import {
1919
updateBoard,
20-
} from "./model/base.js"
20+
} from "src/model/base.js"
2121
import {
2222
getForbidden,
23-
} from "./model/ko.js"
23+
} from "src/model/ko.js"
2424
import {
2525
count,
2626
toggleStonesAt,
2727
resetCounting,
28-
} from "./model/count.js"
28+
} from "src/model/count.js"
2929

3030
export const useAuthStore = create(
3131
persist(

0 commit comments

Comments
 (0)