Merge branch 'master' into hm/bad-hosted-check

This commit is contained in:
Hunter Miller 2023-10-23 15:47:48 -05:00
commit d906e2c830
4 changed files with 31 additions and 6 deletions

View File

@ -1,7 +1,7 @@
:~ title+'Landscape'
info+'An app launcher for Urbit.'
color+0xee.5432
glob-http+['https://bootstrap.urbit.org/glob-0v7.8sf6i.lsri7.nj6ao.chudn.1cvhr.glob' 0v7.8sf6i.lsri7.nj6ao.chudn.1cvhr]
glob-http+['https://bootstrap.urbit.org/glob-0v2.ji1vg.n7bao.vqguf.iaodv.9rakq.glob' 0v2.ji1vg.n7bao.vqguf.iaodv.9rakq]
::glob-ames+~zod^0v0
base+'landscape'
version+[1 19 0]

4
ui/src/env.d.ts vendored
View File

@ -1,6 +1,8 @@
interface ImportMetaEnv extends Readonly<Record<string, string | boolean | undefined>> {
interface ImportMetaEnv
extends Readonly<Record<string, string | boolean | undefined>> {
readonly VITE_LAST_WIPE: string;
readonly VITE_STORAGE_VERSION: string;
readonly VITE_SHIP_URL: string;
}
interface ImportMeta {

View File

@ -3,6 +3,7 @@ import { StorageUpdate } from '@/gear';
import _ from 'lodash';
import { BaseStorageState } from '@/gear';
import { BaseState } from '../base';
import { hostingUploadURL } from '@/logic/utils';
export type StorageState = BaseStorageState & BaseState<BaseStorageState>;
@ -27,8 +28,10 @@ const configuration = (
buckets: new Set(data.buckets),
currentBucket: data.currentBucket,
region: data.region,
presignedUrl: data.presignedUrl,
service: data.service,
// if landscape is not up to date we need to default these so the
// client init logic still works
presignedUrl: data.presignedUrl || hostingUploadURL,
service: data.service || 'credentials',
};
}
return state;

View File

@ -8,6 +8,7 @@ import {
reduceStateN,
BaseState,
} from '../base';
import { hostingUploadURL, isHosted } from '@/logic/utils';
enableMapSet();
@ -25,7 +26,7 @@ export const useStorage = createState<BaseStorageState>(
buckets: new Set(),
currentBucket: '',
region: '',
presignedUrl: '',
presignedUrl: hostingUploadURL,
service: 'credentials',
},
credentials: null,
@ -44,7 +45,26 @@ export const useStorage = createState<BaseStorageState>(
}
numLoads += 1;
if (numLoads === 2) {
set({ loaded: true });
const {
s3: { credentials, configuration },
} = get();
if (!credentials?.endpoint && isHosted) {
set({
loaded: true,
s3: {
credentials,
configuration: {
...configuration,
presignedUrl:
configuration.presignedUrl || hostingUploadURL,
service: 'presigned-url',
},
},
});
} else {
set({ loaded: true });
}
}
}
),