Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

HMR Config and Authentication Fallback Spinner #7987

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.local.default
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ APP_URL=https://localhost:3000
APP_HOST=localhost:3000
APP_PORT=3000

VITE_HMR=false

# Vite variables - Exposed to client side
VITE_FORCE_CLIENT_LOG_AGGREGATE=false
VITE_GA_TRACKING_ID=
Expand Down
1 change: 1 addition & 0 deletions packages/client-core/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"loader": {
"connecting": "Connecting...",
"authenticating": "Authenticating...",
"starting": "Starting...",
"loadingLocation": "Loading locations...",
"loadingEngine": "Loading engine...",
Expand Down
2 changes: 1 addition & 1 deletion packages/client-core/src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine'

import primusClient from './util/primus-client'

type FeathersClient = FeathersApplication<ServiceTypes> &
export type FeathersClient = FeathersApplication<ServiceTypes> &
AuthenticationClient & {
primus: Primus
authentication: AuthenticationClient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { API } from '../API'
import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine'

import { FeathersClient } from '../API'

async function waitForClientAuthenticated(): Promise<void> {
//console.log('Client authenticated?', client.authentication?.authenticated)
if (API.instance.client.authentication?.authenticated === true) return Promise.resolve()
const api = Engine.instance.api as FeathersClient
console.log('Client authenticated?', api.authentication?.authenticated)
if (api.authentication?.authenticated === true) return
else
return await new Promise((resolve) =>
setTimeout(async () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/client/src/route/public.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
AdminClientSettingsState,
ClientSettingsServiceReceptor
} from '@etherealengine/client-core/src/admin/services/Setting/ClientSettingService'
import { FeathersClient } from '@etherealengine/client-core/src/API'
import ErrorBoundary from '@etherealengine/client-core/src/common/components/ErrorBoundary'
import { ProjectServiceReceptor } from '@etherealengine/client-core/src/common/services/ProjectService'
import {
Expand All @@ -21,6 +22,7 @@ import {
import { LoadingCircle } from '@etherealengine/client-core/src/components/LoadingCircle'
import { LocationServiceReceptor } from '@etherealengine/client-core/src/social/services/LocationService'
import { AuthService, AuthServiceReceptor } from '@etherealengine/client-core/src/user/services/AuthService'
import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine'
import { addActionReceptor, getMutableState, removeActionReceptor, useHookstate } from '@etherealengine/hyperflux'

import $404 from '../pages/404'
Expand Down Expand Up @@ -101,6 +103,10 @@ function RouterComp() {
return routesReady.set(true)
}, [clientSettingsState.client.length, authSettingsState.authSettings.length, customRoutes])

if (!(Engine.instance.api as FeathersClient).authentication?.authenticated) {
return <LoadingCircle message={t('common:loader.authenticating')} />
}

if (!routesReady.value) {
return <LoadingCircle message={t('common:loader.loadingRoutes')} />
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default defineConfig(async () => {

const returned = {
server: {
hmr: true,
hmr: process.env.VITE_HMR,
host: process.env['VITE_APP_HOST'],
port: process.env['VITE_APP_PORT'],
headers: {
Expand Down