Skip to content

Commit 521434c

Browse files
authored
Merge pull request #30 from SolidLabResearch/29-bugfix-404-on-watchpage
bugfix /watch gave a 404, and cleanup of routing variables
2 parents 38d0bf0 + db1401a commit 521434c

8 files changed

Lines changed: 21 additions & 19 deletions

File tree

solid-watchparty/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
baseDir: '/solid-watch-party/',
3+
outDir: '../dist',
4+
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import viteConfig from "./vite.config.js";
22
import * as fs from "fs";
33

4-
// TODO: possibly get these from App.jsx
54
const routes = [
65
"/menu",
76
"/watch"
87
];
98
const dir = viteConfig.build.outDir;
10-
119
for (const route of routes) {
1210
fs.cpSync(dir + "/index.html", dir + route + "/index.html");
1311
}

solid-watchparty/src/App.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
33
import { SessionProvider } from '@inrupt/solid-ui-react'
44

5-
/* page imports */
65
import LoginPage from './pages/LoginPage';
76
import MenuPage from './pages/MenuPage';
87
import WatchPage from './pages/WatchPage';
98

109
/* config imports */
11-
import { BASEPATH } from './config'
10+
import config from '../config';
1211

13-
const router = createBrowserRouter([
14-
{path: (BASEPATH + "/"), element: <LoginPage/>},
15-
{path: (BASEPATH + "/menu"), element: <MenuPage/>},
16-
{path: (BASEPATH + "/watch"), element: <WatchPage/>},
12+
export const router = createBrowserRouter([
13+
{path: (config.baseDir + "/"), element: <LoginPage/>},
14+
{path: (config.baseDir + "/menu"), element: <MenuPage/>},
15+
{path: (config.baseDir + "/watch"), element: <WatchPage/>},
1716
]);
1817

1918
function App() {

solid-watchparty/src/components/SWChatComponent.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ function SWChatComponent({roomUrl, joined}) {
115115
<SWAutoScrollDiv className="overflow-y-auto overflow-x-auto mb-2 shrink">
116116
{messages.map((message) => <SWMessageComponent message={message} key={message.key}/>)}
117117
</SWAutoScrollDiv>
118-
<form className="grow-0 flex flex-between items-center" onSubmit={submitMessage}>
118+
<form autocomplete="off" className="grow-0 flex flex-between items-center" onSubmit={submitMessage}>
119119
<input id="msgInput" className="px-2 h-10 rgb-bg-1 sw-border w-full"
120120
onChange={(e) => setInput(parseMessage(e.target.value))}
121-
value={input}/>
121+
value={input} type='text'/>
122122
<button className="sw-btn hidden"> P </button>
123123
</form>
124124
</>

solid-watchparty/src/config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
export const BASEPATH = '/solid-watch-party'
2-
31
/* NOTE(Elias): default POD directory structure related to the watchparty */
42
export const ROOMS_ROOT = 'watchparties/myRooms';
53
export const MESSAGES_ROOT = 'watchparties/myMessages';

solid-watchparty/src/pages/LoginPage.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import SWPageWrapper from '../components/SWPageWrapper'
77
import SWLoginButton from '../components/SWLoginButton'
88

99
/* config imports */
10-
import { BASEPATH } from '../config.js'
10+
import config from '../../config';
1111

1212
const authOptions = {
1313
clientName: "solid-watchparty",
1414
};
1515

1616
export default function LoginPage()
1717
{
18-
const [oidcIssuer, setOidcIssuer] = useState("http://localhost:3000/");
18+
const [oidcIssuer, setOidcIssuer] = useState("");
1919
const currentLocation = useLocation();
20-
const redirectLocation = (currentLocation.state?.from || `${BASEPATH}/menu`);
20+
const redirectLocation = (currentLocation.state?.from || `${config.baseDir}/menu`);
2121
return (
2222
<SWPageWrapper className="flex justify-center items-center" mustBeAuthenticated={false}>
2323
<div className="w-1/2">

solid-watchparty/src/pages/MenuPage.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import {
2121
validateLength
2222
} from '../utils/validationUtils';
2323

24+
/* config imports */
25+
import config from '../../config';
2426

2527
function
2628
MenuPage()
@@ -46,7 +48,7 @@ MenuPage()
4648
} else if (!result.exists) {
4749
setRoomUrl({value: roomUrl.value, alertMsg: "Room does not exist"});
4850
} else {
49-
navigateTo('/watch?room=' + encodeURIComponent(roomUrl.value));
51+
navigateTo(`${config.baseDir}/watch?room=${encodeURIComponent(roomUrl.value)}`);
5052
}
5153
}
5254
setIsJoinLoading(false);
@@ -63,7 +65,7 @@ MenuPage()
6365
if (result.error) {
6466
setRoomName({value: roomName.value, alertMsg: result.errorMsg});
6567
} else {
66-
navigateTo('/watch?room=' + encodeURIComponent(result.roomUrl));
68+
navigateTo(`${config.baseDir}/watch?room=${encodeURIComponent(result.roomUrl)}`);
6769
}
6870
}
6971
setIsCreateLoading(false);

solid-watchparty/vite.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
3+
import config from './config.js'
34

45
// https://vitejs.dev/config/
56
export default defineConfig({
67
plugins: [react()],
7-
base: '/solid-watch-party/',
8+
base: config.baseDir,
89
build: {
9-
outDir: '../dist'
10+
outDir: config.outDir
1011
},
1112
})

0 commit comments

Comments
 (0)