Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardoperra committed Oct 30, 2024
1 parent a84c210 commit 40c9f87
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
8 changes: 4 additions & 4 deletions packages/app/src/components/Home/CurrentUser/CurrentUser.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createAsync, useAction, useSubmission} from '@solidjs/router';
import {getUser, logout} from '~/lib/server/session';
import {Show, useTransition} from 'solid-js';
import {loggedInUser, logout} from '~/lib/server/session';
import {Show} from 'solid-js';
import {badge, currentUser} from './CurrentUser.css';
import {Models} from 'appwrite';
import {Icon} from '#ui/components/Icon';
Expand All @@ -11,10 +11,10 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from '@codeui/kit';
import {signupWithGithub} from '../../../lib/server/appwrite';
import {signupWithGithub} from '~/lib/server/appwrite';

export function CurrentUserBar() {
const user = createAsync(() => getUser());
const user = createAsync(() => loggedInUser());

const initials = (user: Models.User<any>) => {
if (user.name) {
Expand Down
11 changes: 3 additions & 8 deletions packages/app/src/components/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ import {
Show,
Suspense,
} from 'solid-js';
import {StateProvider} from 'statebuilder';
import {
getGithubData,
getGithubRepo,
getGithubRepoWorkflowFiles,
} from '~/lib/githubApi';
import {getGithubData} from '~/lib/githubApi';
import {loggedInUser} from '~/lib/server/session';
import {createScratch} from '../../lib/scratchApi';
import {getLoggedInUser} from '../../lib/server/appwrite';
import {CurrentUserBar} from './CurrentUser/CurrentUser';
import {HomeFooter} from './Footer/Footer';
import {
Expand Down Expand Up @@ -53,7 +48,7 @@ export const route = {
};

export function Home() {
const user = createAsync(() => getLoggedInUser(), {deferStream: true});
const user = createAsync(() => loggedInUser());
const isCreatingScratch = useSubmission(createScratch);
const [params] = useSearchParams();

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/lib/server/appwrite.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Account, Client, Databases, OAuthProvider} from 'node-appwrite';
import {getHeaders} from 'vinxi/http';
import {getSession} from './session';
import {action, redirect} from '@solidjs/router';
import {action, cache, redirect} from '@solidjs/router';

export async function createSessionClient() {
'use server';
Expand Down
6 changes: 4 additions & 2 deletions packages/app/src/lib/server/session.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useSession} from 'vinxi/http';
import {action, cache, redirect} from '@solidjs/router';
import {Models as NodeModels} from 'node-appwrite';
import {useSession} from 'vinxi/http';
import {getLoggedInUser} from './appwrite';
import {action, redirect} from '@solidjs/router';

export function getSession() {
'use server';
Expand All @@ -20,6 +20,8 @@ export async function getUser(): Promise<NodeModels.User<any> | null> {
return getLoggedInUser();
}

export const loggedInUser = cache(async () => getLoggedInUser(), 'logged-user');

export async function logoutSession() {
'use server';
try {
Expand Down

0 comments on commit 40c9f87

Please sign in to comment.