Skip to content

Commit e7ca8ed

Browse files
committed
Hack loading SPA from Next
1 parent e8c677d commit e7ca8ed

File tree

9 files changed

+54
-49
lines changed

9 files changed

+54
-49
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import App from "../../../skin-museum-client/src/App";
2+
export default function Page() {
3+
return <App next={true} />;
4+
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
import ReduxContextProvider from "./redux";
2+
import { GoogleAnalytics } from "@next/third-parties/google";
3+
14
export default function RootLayout({
25
children,
36
}: {
47
children: React.ReactNode;
58
}) {
69
return (
710
<html lang="en">
8-
<body>{children}</body>
11+
<body>
12+
<ReduxContextProvider>{children}</ReduxContextProvider>
13+
<GoogleAnalytics gaId="UA-96948-20" />
14+
</body>
915
</html>
1016
);
1117
}

packages/skin-database/app/page.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use client";
2+
import { Provider } from "react-redux";
3+
import { createStore } from "../../skin-museum-client/src/redux/store";
4+
import { useEffect, useState } from "react";
5+
6+
type Props = {
7+
children: React.ReactNode;
8+
};
9+
10+
export default function ReduxContextProvider({ children }: Props) {
11+
const [store, setStore] = useState<any>(null);
12+
13+
// Store creation currently fails on the server, so we delay and only create
14+
// the store on mount for now.
15+
useEffect(() => {
16+
const store = createStore();
17+
setStore(store);
18+
}, []);
19+
if (store == null) {
20+
return null;
21+
}
22+
return <Provider store={store}>{children}</Provider>;
23+
}

packages/skin-database/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"main": "index.js",
55
"license": "MIT",
66
"dependencies": {
7+
"@next/third-parties": "^15.3.3",
78
"@sentry/node": "^5.27.3",
89
"@sentry/tracing": "^5.27.3",
910
"algoliasearch": "^4.3.0",

packages/skin-museum-client/src/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ function App(props) {
6363

6464
return (
6565
<div>
66-
<Head />
67-
<Header />
66+
{props.next || <Head />}
67+
<Header next={props.next} />
6868
<div {...getRootProps()}>
6969
{props.uploadViewOpen || isDragActive ? (
7070
<UploadGrid

packages/skin-museum-client/src/Header.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as Utils from "./utils";
44
import * as Selectors from "./redux/selectors";
55
import * as Actions from "./redux/actionCreators";
66
import { useActionCreator, useWindowSize } from "./hooks";
7-
import { ReactComponent as AlgoliaLogo } from "./searchByAlgoliaDarkbBackground.svg";
7+
import AlgoliaLogo from "./searchByAlgoliaDarkbBackground.svg";
88
import algoliaLogoSmallUrl from "./searchByAlgoliaSmall.png";
99
import FeedbackIcon from "./components/icons/FeedbackIcon";
1010
import AboutIcon from "./components/icons/AboutIcon";
@@ -15,7 +15,7 @@ import UploadIcon from "./components/icons/UploadIcon";
1515
function SearchLogo() {
1616
const { windowWidth } = useWindowSize();
1717
if (windowWidth > 500) {
18-
return <AlgoliaLogo />;
18+
return <AlgoliaLogo.ReactComponent />;
1919
}
2020
return (
2121
<img
@@ -52,7 +52,7 @@ function useFocusOnSlash() {
5252
return setInput;
5353
}
5454

55-
function Header() {
55+
function Header({ next }) {
5656
const searchQuery = useSelector(Selectors.getSearchQuery);
5757
const uploadViewOpen = useSelector(Selectors.getUploadViewOpen);
5858
const setSearchQuery = useActionCreator(Actions.searchQueryChanged);
@@ -89,7 +89,7 @@ function Header() {
8989
transition: "opacity ease-in 300ms",
9090
}}
9191
>
92-
<SearchLogo />
92+
{next || <SearchLogo />}
9393
</a>
9494
<input
9595
type="search"

packages/skin-museum-client/src/redux/epics.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -441,36 +441,6 @@ const uploadAllFilesEpic = (actions, state) =>
441441
})
442442
);
443443

444-
const loggingEpic = (actions, state) =>
445-
actions.pipe(
446-
tap((action) => {
447-
// ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
448-
switch (action.type) {
449-
case "CONCENTS_TO_NSFW":
450-
case "DOES_NOT_CONCENT_TO_NSFW":
451-
case "CLOSE_UPLOAD_FILES":
452-
case "GOT_FILE_MD5":
453-
case "ARCHIVED_SKIN":
454-
case "TRY_TO_UPLOAD_FILE":
455-
case "UPLOAD_FAILED":
456-
case "STARTING_FILE_UPLOAD":
457-
case "TRY_TO_UPLOAD_ALL_FILES":
458-
case "INVALID_FILE_EXTENSION":
459-
case "GOT_FILE":
460-
case "GOT_MISSING_AND_FOUND_MD5S":
461-
case "REQUESTED_RANDOM_SKIN":
462-
case "MARK_NSFW":
463-
case "INVALID_ARCHIVE":
464-
case "SET_SCALE":
465-
window.ga("send", "event", "redux", action.type);
466-
break;
467-
default: {
468-
}
469-
}
470-
}),
471-
ignoreElements()
472-
);
473-
474444
const urlEpic = (actions, state) => {
475445
return actions.pipe(
476446
map(() => Selectors.getUrl(state.value)),
@@ -492,8 +462,6 @@ const urlEpic = (actions, state) => {
492462

493463
const newUrl = proposedUrl.toString();
494464

495-
window.ga("set", "page", newUrl);
496-
497465
window.history.replaceState({}, Selectors.getPageTitle(state), newUrl);
498466
}),
499467
ignoreElements()
@@ -573,7 +541,6 @@ export default combineEpics(
573541
uploadSingleFileEpic,
574542
checkIfUploadsAreMissingEpic,
575543
urlEpic,
576-
loggingEpic,
577544
skinDataEpic,
578545
markNsfwEpic,
579546
alertEpic

yarn.lock

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,6 +3728,13 @@
37283728
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.3.3.tgz#c0e33e069d7922dd0546cac77a0247ad81d4a1aa"
37293729
integrity sha512-4QZG6F8enl9/S2+yIiOiju0iCTFd93d8VC1q9LZS4p/Xuk81W2QDjCFeoogmrWWkAD59z8ZxepBQap2dKS5ruw==
37303730

3731+
"@next/third-parties@^15.3.3":
3732+
version "15.3.3"
3733+
resolved "https://registry.yarnpkg.com/@next/third-parties/-/third-parties-15.3.3.tgz#8637d3d9a8c1da4419f95cf74a97d171e7c44070"
3734+
integrity sha512-kwhDkK/3klTvW6SuNkmIMSqzEk9Rnc7PkpGeAi3x0mcbPJhFTwdC/qTEd/HZt53J2yFv73YohOBk6dUG3TEIkQ==
3735+
dependencies:
3736+
third-party-capital "1.0.20"
3737+
37313738
"@nicolo-ribaudo/eslint-scope-5-internals@5.1.1-v1":
37323739
version "5.1.1-v1"
37333740
resolved "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz"
@@ -15390,16 +15397,11 @@ graphql-yoga@^5.10.10:
1539015397
lru-cache "^10.0.0"
1539115398
tslib "^2.8.1"
1539215399

15393-
graphql@^16.8.1:
15400+
graphql@16.8.1, graphql@^16.8.1, graphql@^16.9.0:
1539415401
version "16.8.1"
1539515402
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07"
1539615403
integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==
1539715404

15398-
graphql@^16.9.0:
15399-
version "16.10.0"
15400-
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.10.0.tgz#24c01ae0af6b11ea87bf55694429198aaa8e220c"
15401-
integrity sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ==
15402-
1540315405
grats@^0.0.31:
1540415406
version "0.0.31"
1540515407
resolved "https://registry.yarnpkg.com/grats/-/grats-0.0.31.tgz#f094786584a0f2fb345b38e6c37330d3f4f391cd"
@@ -27526,6 +27528,11 @@ thenify-all@^1.0.0:
2752627528
dependencies:
2752727529
any-promise "^1.0.0"
2752827530

27531+
third-party-capital@1.0.20:
27532+
version "1.0.20"
27533+
resolved "https://registry.yarnpkg.com/third-party-capital/-/third-party-capital-1.0.20.tgz#e218a929a35bf4d2245da9addb8ab978d2f41685"
27534+
integrity sha512-oB7yIimd8SuGptespDAZnNkzIz+NWaJCu2RMsbs4Wmp9zSDUM8Nhi3s2OOcqYuv3mN4hitXc8DVx+LyUmbUDiA==
27535+
2752927536
throat@^6.0.1:
2753027537
version "6.0.2"
2753127538
resolved "https://registry.npmjs.org/throat/-/throat-6.0.2.tgz"

0 commit comments

Comments
 (0)