mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-24 16:32:45 -04:00
Actually fetch data from rspc
This commit is contained in:
@@ -17,14 +17,6 @@ import { RouteTitleContext } from '@sd/interface/hooks/useRouteTitle';
|
||||
|
||||
import '@sd/ui/style/style.scss';
|
||||
|
||||
import { useLocale } from '@sd/interface/hooks';
|
||||
|
||||
import { commands } from './commands';
|
||||
import { platform } from './platform';
|
||||
import { queryClient } from './query';
|
||||
import { createMemoryRouterWithHistory } from './router';
|
||||
import { createUpdater } from './updater';
|
||||
|
||||
// TODO: Bring this back once upstream is fixed up.
|
||||
// const client = hooks.createClient({
|
||||
// links: [
|
||||
@@ -34,13 +26,45 @@ import { createUpdater } from './updater';
|
||||
// tauriLink()
|
||||
// ]
|
||||
// });
|
||||
import SuperTokens from 'supertokens-web-js';
|
||||
import EmailPassword from 'supertokens-web-js/recipe/emailpassword';
|
||||
import Session from 'supertokens-web-js/recipe/session';
|
||||
import ThirdParty from 'supertokens-web-js/recipe/thirdparty';
|
||||
import getCookieHandler, {
|
||||
setAppReady
|
||||
} from '@sd/interface/app/$libraryId/settings/client/account/handlers/cookieHandler';
|
||||
import getWindowHandler from '@sd/interface/app/$libraryId/settings/client/account/handlers/windowHandler';
|
||||
import { useLocale } from '@sd/interface/hooks';
|
||||
|
||||
import { commands } from './commands';
|
||||
import { platform } from './platform';
|
||||
import { queryClient } from './query';
|
||||
import { createMemoryRouterWithHistory } from './router';
|
||||
import { createUpdater } from './updater';
|
||||
|
||||
SuperTokens.init({
|
||||
appInfo: {
|
||||
apiDomain: 'http://localhost:9420',
|
||||
apiBasePath: '/api/auth',
|
||||
appName: 'Spacedrive Auth Service'
|
||||
},
|
||||
cookieHandler: getCookieHandler,
|
||||
windowHandler: getWindowHandler,
|
||||
recipeList: [
|
||||
Session.init({ tokenTransferMethod: 'header' }),
|
||||
EmailPassword.init(),
|
||||
ThirdParty.init()
|
||||
]
|
||||
});
|
||||
|
||||
const startupError = (window as any).__SD_ERROR__ as string | undefined;
|
||||
|
||||
export default function App() {
|
||||
useEffect(() => {
|
||||
// This tells Tauri to show the current window because it's finished loading
|
||||
commands.appReady();
|
||||
commands.appReady().then(() => {
|
||||
setAppReady();
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -44,6 +44,7 @@ async function signInClicked(email: string, password: string) {
|
||||
// this may be a custom error message sent from the API by you.
|
||||
toast.error(err.message);
|
||||
} else {
|
||||
console.error(err);
|
||||
toast.error('Oops! Something went wrong.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { CookieHandlerInterface } from "supertokens-website/utils/cookieHandler/types";
|
||||
import { nonLibraryClient } from '@sd/client'
|
||||
|
||||
let APP_READY = false;
|
||||
|
||||
async function getCookiesFromStorage(): Promise<string> {
|
||||
if (!APP_READY) {
|
||||
return "";
|
||||
}
|
||||
const cookiesFromStorage = await nonLibraryClient.query(['keys.get'])
|
||||
|
||||
console.log("Cookies from storage (getCookie): ", cookiesFromStorage);
|
||||
@@ -57,6 +62,9 @@ async function getCookiesFromStorage(): Promise<string> {
|
||||
}
|
||||
|
||||
async function setCookieToStorage(cookieString: string): Promise<void> {
|
||||
if (!APP_READY) {
|
||||
return;
|
||||
}
|
||||
const cookieName = cookieString.split(";")[0]?.split("=")[0];
|
||||
console.log("Setting cookie: ", cookieName);
|
||||
|
||||
@@ -111,3 +119,7 @@ export default function getCookieHandler(original: CookieHandlerInterface): Cook
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function setAppReady() {
|
||||
APP_READY = true;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export const Component = () => {
|
||||
useEffect(() => {
|
||||
async function _() {
|
||||
console.log("Token data: ", token.data);
|
||||
const user_data = await fetch('http://localhost:9000/api/user', {
|
||||
const user_data = await fetch('http://localhost:9420/api/user', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token.data ?? ''}`
|
||||
|
||||
@@ -5,10 +5,6 @@ import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import { PropsWithChildren, Suspense } from 'react';
|
||||
import { I18nextProvider } from 'react-i18next';
|
||||
import { RouterProvider, RouterProviderProps } from 'react-router-dom';
|
||||
import SuperTokens from 'supertokens-web-js';
|
||||
import EmailPassword from 'supertokens-web-js/recipe/emailpassword';
|
||||
import Session from 'supertokens-web-js/recipe/session';
|
||||
import ThirdParty from 'supertokens-web-js/recipe/thirdparty';
|
||||
import {
|
||||
InteropProviderReact,
|
||||
P2PContextProvider,
|
||||
@@ -48,21 +44,6 @@ import('@sentry/browser').then(({ init, Integrations }) => {
|
||||
});
|
||||
});
|
||||
|
||||
SuperTokens.init({
|
||||
appInfo: {
|
||||
apiDomain: 'http://localhost:9000',
|
||||
apiBasePath: '/api/auth',
|
||||
appName: 'Spacedrive Auth Service'
|
||||
},
|
||||
cookieHandler: getCookieHandler,
|
||||
windowHandler: getWindowHandler,
|
||||
recipeList: [
|
||||
Session.init({ tokenTransferMethod: 'header' }),
|
||||
EmailPassword.init(),
|
||||
ThirdParty.init()
|
||||
]
|
||||
});
|
||||
|
||||
export type Router = RouterProviderProps['router'];
|
||||
|
||||
export function SpacedriveRouterProvider(props: {
|
||||
|
||||
Reference in New Issue
Block a user