Nin
Nin
Explore posts from servers
SSolidJS
Created by Nin on 9/21/2023 in #support
Navigate user in login/logout functions
I think I'm mixing two things up together. Will look into this by making my AuthGuard a simple function that just guards, and make the provider the one that actually retrieves the session
5 replies
SSolidJS
Created by Nin on 9/21/2023 in #support
Navigate user in login/logout functions
@martnart Maybe I should make my Auth Guard and Auth Provider just a single component? This is currently my Auth Guard component which I have in the root.tsx file.
import type { ComponentProps } from "solid-js"

import { useNavigate } from "@solidjs/router"

import { AuthContext, authContext } from "~/lib/providers/auth-provider"
import supabase from "~/lib/supabase"

export default function AuthGuard(props: ComponentProps<"div">) {
const navigate = useNavigate()


supabase.auth.getSession().then(({ data, error }) => {
const { session } = data

if (session === null || error) {
navigate("/auth/signin")
} else {
authContext.login(session)
}
})

return <AuthContext.Provider value={authContext}>{props.children}</AuthContext.Provider>
}
import type { ComponentProps } from "solid-js"

import { useNavigate } from "@solidjs/router"

import { AuthContext, authContext } from "~/lib/providers/auth-provider"
import supabase from "~/lib/supabase"

export default function AuthGuard(props: ComponentProps<"div">) {
const navigate = useNavigate()


supabase.auth.getSession().then(({ data, error }) => {
const { session } = data

if (session === null || error) {
navigate("/auth/signin")
} else {
authContext.login(session)
}
})

return <AuthContext.Provider value={authContext}>{props.children}</AuthContext.Provider>
}
Root.tsx
<AuthGuard>
<Navbar />
<Routes>
<Route path="/auth">
<Route path={["/signin", "/signup"]} component={Authentication} data={determineAuthMode} />
</Route>
<FileRoutes />
</Routes>
</AuthGuard>
<AuthGuard>
<Navbar />
<Routes>
<Route path="/auth">
<Route path={["/signin", "/signup"]} component={Authentication} data={determineAuthMode} />
</Route>
<FileRoutes />
</Routes>
</AuthGuard>
5 replies
SSolidJS
Created by Nin on 9/21/2023 in #support
Multiple Path Routes still Re-rendering, why?
Solved it. I was using the Kobalte <Link.Root> component. After switching to an A component by Solid Start it's working as expected.
2 replies
SSolidJS
Created by Nin on 9/18/2023 in #support
How to mutate a createResource storage
Alright that makes sense then yeah. I thought it would return the setter from the store to be the mutate function and was trying to use the setter API. This makes it easy though. I'll give it a shot and report back here once I've done so. Right now a pizza is waiting for me so have to run
18 replies
SSolidJS
Created by Nin on 9/18/2023 in #support
How to mutate a createResource storage
Interesting, OK, going to give that a shot! Thanks a lot @foolswisdom
18 replies
SSolidJS
Created by Nin on 9/18/2023 in #support
How to mutate a createResource storage
So I just call update with the new array in this case?
18 replies
SSolidJS
Created by Nin on 2/8/2023 in #support
createResource State gets updated without directly doing so
Then this is the checkbox component itself
<For each={clients()?.taskList[care_task]}>
{(task) => (
<Checkbox
size="lg"
value={task}
checked={state.selectedTasks[
care_task
].includes(task)}
onChange={handleCheckboxChange(care_task)}
>
{getLabelMapping(care_task).tasks[task]}
</Checkbox>
)}
</For>
<For each={clients()?.taskList[care_task]}>
{(task) => (
<Checkbox
size="lg"
value={task}
checked={state.selectedTasks[
care_task
].includes(task)}
onChange={handleCheckboxChange(care_task)}
>
{getLabelMapping(care_task).tasks[task]}
</Checkbox>
)}
</For>
2 replies
SSolidJS
Created by Casacobra on 12/22/2022 in #support
Solid Cache
Whole other topic @lxsmnsyc - How would we invalidate a key? Since it's a string we can't really give it a time to live in an object and check based on this. Our situation right now is where we have cached a page of results on page 1, we add something new which would then be listed on page 1, however after returning to page 1 after creation, the key being the same we get a cached result
53 replies
SSolidJS
Created by Casacobra on 12/22/2022 in #support
Solid Cache
Yeah sorry we were pair programming so yes, we did have it mounted as it worked on the other one we just created a new CacheBoundary to log a to be defined key to see if we could get the values that way
53 replies
SSolidJS
Created by Casacobra on 12/22/2022 in #support
Solid Cache
Also how would one console.log by key? Currently getting an error that says "Missing CacheBoundary"
53 replies
SSolidJS
Created by Nin on 12/4/2022 in #support
Rerender child component with updated props
Aaaaaaaaaaaa. This makes so much sense now. Of course, the createEffect runs, then it registers how it needs to behave on all subsequent runs. If the first time setTotalPages isn't set because the if is false, it'll never send the signal onwards the moment it does update.
34 replies
SSolidJS
Created by Nin on 12/4/2022 in #support
Rerender child component with updated props
@lxsmnsyc Sorry for mentioning but wanted to get your opinion on this once more and considering it's old I'm not sure if it'll pass your eyes again. To me this sounds like very strange behaviour and wrapping it in an if statement should be considered good practice(?)
34 replies
SSolidJS
Created by Nin on 12/4/2022 in #support
Rerender child component with updated props
Removed the if statement in here and voila
34 replies
SSolidJS
Created by Nin on 12/4/2022 in #support
Rerender child component with updated props
createEffect(() => {
if (!query.loading && !query.error) {
setTotalPages(Math.ceil(query().count / pageSize()))
console.log('Running effect, setting totalPages to:', totalPages())
}
})
createEffect(() => {
if (!query.loading && !query.error) {
setTotalPages(Math.ceil(query().count / pageSize()))
console.log('Running effect, setting totalPages to:', totalPages())
}
})
34 replies