Skip to content

Commit

Permalink
slight fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dtemkin1 committed Jan 7, 2025
1 parent b231f55 commit c8ba07b
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 25 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"@solid-primitives/utils": "^6.2.3",
"@solidjs/meta": "^0.29.4",
"@solidjs/router": "^0.15.2",
"@solidjs/start": "^1.0.10",
"@solidjs/start": "^1.0.11",
"localforage": "^1.10.0",
"lucide-solid": "^0.469.0",
"solid-js": "^1.9.3",
"ua-parser-js": "^2.0.0",
Expand Down
32 changes: 27 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions src/components/Auth.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { cookieStorage, makePersisted } from "@solid-primitives/storage";
import { useNavigate, useParams, useSearchParams } from "@solidjs/router";
import {
type Accessor,
type Component,
For,
type Setter,
Show,
createEffect,
createMemo,
Expand Down Expand Up @@ -49,18 +51,18 @@ export type AuthRef = {
(props: {
deleteRoad: (roadName: string) => void;
retrieveRoad: (roadID: string) => Promise<RoadResponse | undefined>;
newRoads: string[];
setNewRoads: (newRoads: string[]) => void;
newRoads: Accessor<string[]>;
setNewRoads: Setter<string[]>;
save: (roadID: string) => void;
gettingUserData: boolean;
gettingUserData: Accessor<boolean>;
changeSemester: (year: number) => void;
}): void;
deleteRoad: (roadName: string) => void;
retrieveRoad: (roadID: string) => Promise<RoadResponse | undefined>;
newRoads: string[];
setNewRoads: (newRoads: string[]) => void;
newRoads: Accessor<string[]>;
setNewRoads: Setter<string[]>;
save: (roadID: string) => void;
gettingUserData: boolean;
gettingUserData: Accessor<boolean>;
changeSemester: (year: number) => void;
};

Expand Down Expand Up @@ -860,8 +862,8 @@ const Auth: Component<{
props.ref?.({
deleteRoad: deleteRoadInternal,
retrieveRoad,
newRoads: newRoadsRef(),
gettingUserData: gettingUserData(),
newRoads: newRoadsRef,
gettingUserData,
setNewRoads: setNewRoadsRef,
save,
changeSemester,
Expand Down
20 changes: 13 additions & 7 deletions src/context/component.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { makePersisted, storageSync } from "@solid-primitives/storage";
import { makePersisted } from "@solid-primitives/storage";
import { type ParentComponent, createResource } from "solid-js";
import { createStore, produce, reconcile, unwrap } from "solid-js/store";
import { createStore, produce, reconcile } from "solid-js/store";
import { isServer } from "solid-js/web";

import { CourseDataContext, type defaultActions, defaultState } from "./create";
import type { Subject, SubjectFull } from "./types";
import localforage from "localforage";

import {
CourseDataContext,
type defaultActions,
defaultState,
} from "~/context/create";
import type { Subject, SubjectFull } from "~/context/types";

const CourseDataProvider: ParentComponent = (props) => {
const [store, setStore, init] = makePersisted(
createStore(structuredClone(defaultState)),
{
name: "courseRoadStore",
sync: storageSync,
storage: !isServer ? localforage : undefined,
},
);

Expand Down Expand Up @@ -248,8 +255,7 @@ const CourseDataProvider: ParentComponent = (props) => {
},

getRoadKeys: () => {
if (!store.roads) return [];
return Object.keys(store.roads);
return Object.getOwnPropertyNames(store.roads);
},

getMatchingAttributes: (gir, hass, ci) => {
Expand Down
12 changes: 8 additions & 4 deletions src/routes/road/[[road]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function RoadPage() {
on(activeRoad, (newRoad) => {
if (
store.unretrieved.indexOf(newRoad) >= 0 &&
!authComponentRef?.gettingUserData
!authComponentRef?.gettingUserData()
) {
authComponentRef?.retrieveRoad(newRoad).then(() => {
setRetrieved(newRoad);
Expand Down Expand Up @@ -130,7 +130,7 @@ export default function RoadPage() {
ss: SimplifiedSelectedSubjects = Array.from(Array(16), () => []),
overrides: Record<string, number> = {},
) => {
const tempRoadID = `$${authComponentRef?.newRoads.length}$`;
const tempRoadID = `$${authComponentRef?.newRoads().length}$`;
const newContents = {
coursesOfStudy: cos,
selectedSubjects: ss,
Expand All @@ -152,10 +152,14 @@ export default function RoadPage() {
});
resetFulfillmentNeeded();
setActiveRoad(tempRoadID);
authComponentRef?.setNewRoads([...authComponentRef.newRoads, tempRoadID]);
console.log(authComponentRef?.newRoads());
authComponentRef?.setNewRoads([...authComponentRef.newRoads(), tempRoadID]);
console.log(authComponentRef?.newRoads());
};

const [roadKeys, setRoadKeys] = createSignal(["$defaultroad$"] as string[]);
// TODO: find a way to make this nicer,
// but creatememo doesnt work for some reason...
const [roadKeys, setRoadKeys] = createSignal(["$defaultroad$"]);
createEffect(() => {
setRoadKeys(getRoadKeys());
});
Expand Down

0 comments on commit c8ba07b

Please sign in to comment.