Fixed API baseurl for nightly front and mobiles and fixed wrong start message to the scorometer
This commit is contained in:
19
front/API.ts
19
front/API.ts
@@ -65,11 +65,22 @@ export class ValidationError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
function getBaseAPIUrl() {
|
||||
if (Platform.OS === 'web') {
|
||||
if (__DEV__ && process.env.EXPO_PUBLIC_API_URL) {
|
||||
return process.env.EXPO_PUBLIC_API_URL;
|
||||
}
|
||||
return '/api';
|
||||
}
|
||||
if (process.env.EXPO_PUBLIC_API_URL) {
|
||||
return process.env.EXPO_PUBLIC_API_URL;
|
||||
}
|
||||
// fallback since some mobile build seems to not have the env variable
|
||||
return 'https://nightly.chroma.octohub.app/api';
|
||||
}
|
||||
|
||||
export default class API {
|
||||
public static readonly baseUrl =
|
||||
Platform.OS === 'web' && !(__DEV__ && process.env.EXPO_PUBLIC_API_URL)
|
||||
? '/api'
|
||||
: process.env.EXPO_PUBLIC_API_URL!;
|
||||
public static readonly baseUrl = getBaseAPIUrl();
|
||||
public static async fetch(
|
||||
params: FetchParams,
|
||||
handle: Pick<Required<HandleParams>, 'raw'>
|
||||
|
||||
@@ -1,43 +1,48 @@
|
||||
{
|
||||
"expo": {
|
||||
"name": "Chromacase",
|
||||
"slug": "Chromacase",
|
||||
"version": "1.0.0",
|
||||
"orientation": "portrait",
|
||||
"icon": "./assets/icon.png",
|
||||
"userInterfaceStyle": "light",
|
||||
"splash": {
|
||||
"image": "./assets/splash.png",
|
||||
"resizeMode": "cover",
|
||||
"backgroundColor": "#ffffff"
|
||||
},
|
||||
"assetBundlePatterns": ["**/*"],
|
||||
"ios": {
|
||||
"supportsTablet": true
|
||||
},
|
||||
"android": {
|
||||
"adaptiveIcon": {
|
||||
"foregroundImage": "./assets/icon.png",
|
||||
"backgroundColor": "#ffffff"
|
||||
},
|
||||
"permissions": ["android.permission.RECORD_AUDIO"],
|
||||
"package": "com.arthichaud.Chromacase"
|
||||
},
|
||||
"web": {
|
||||
"favicon": "./assets/favicon.png"
|
||||
},
|
||||
"extra": {
|
||||
"eas": {
|
||||
"projectId": "dade8e5e-3e2c-49f7-98c5-cf8834c7ebb2"
|
||||
}
|
||||
},
|
||||
"plugins": [
|
||||
[
|
||||
"expo-image-picker",
|
||||
{
|
||||
"photosPermission": "The app accesses your photos to let you set your personal avatar."
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
"expo": {
|
||||
"name": "Chromacase",
|
||||
"slug": "Chromacase",
|
||||
"version": "1.0.0",
|
||||
"orientation": "portrait",
|
||||
"icon": "./assets/icon.png",
|
||||
"userInterfaceStyle": "light",
|
||||
"splash": {
|
||||
"image": "./assets/splash.png",
|
||||
"resizeMode": "cover",
|
||||
"backgroundColor": "#ffffff"
|
||||
},
|
||||
"assetBundlePatterns": [
|
||||
"**/*"
|
||||
],
|
||||
"ios": {
|
||||
"supportsTablet": true
|
||||
},
|
||||
"android": {
|
||||
"adaptiveIcon": {
|
||||
"foregroundImage": "./assets/icon.png",
|
||||
"backgroundColor": "#ffffff"
|
||||
},
|
||||
"permissions": [
|
||||
"android.permission.RECORD_AUDIO"
|
||||
],
|
||||
"package": "com.arthichaud.Chromacase"
|
||||
},
|
||||
"web": {
|
||||
"favicon": "./assets/favicon.png"
|
||||
},
|
||||
"extra": {
|
||||
"eas": {
|
||||
"projectId": "dade8e5e-3e2c-49f7-98c5-cf8834c7ebb2"
|
||||
}
|
||||
},
|
||||
"plugins": [
|
||||
[
|
||||
"expo-image-picker",
|
||||
{
|
||||
"photosPermission": "The app accesses your photos to let you set your personal avatar."
|
||||
}
|
||||
]
|
||||
],
|
||||
"owner": "arthi-chaud"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,13 @@ const getCursorToPlay = (
|
||||
}
|
||||
};
|
||||
|
||||
const PartitionMagic = ({ timestamp, songID, onEndReached, onError, onReady }: ParitionMagicProps) => {
|
||||
const PartitionMagic = ({
|
||||
timestamp,
|
||||
songID,
|
||||
onEndReached,
|
||||
onError,
|
||||
onReady,
|
||||
}: ParitionMagicProps) => {
|
||||
const { data, isLoading, isError } = useQuery(API.getSongCursorInfos(songID));
|
||||
const currentCurIdx = React.useRef(-1);
|
||||
const [endPartitionReached, setEndPartitionReached] = React.useState(false);
|
||||
@@ -65,24 +71,24 @@ const PartitionMagic = ({ timestamp, songID, onEndReached, onError, onReady }: P
|
||||
setEndPartitionReached(true);
|
||||
}
|
||||
|
||||
// React.useEffect(() => {
|
||||
// if (!pianoSounds.current) {
|
||||
// Promise.all(
|
||||
// Object.entries(PianoNotes).map(([midiNumber, noteResource]) =>
|
||||
// Audio.Sound.createAsync(noteResource, {
|
||||
// volume: 1,
|
||||
// progressUpdateIntervalMillis: 100,
|
||||
// }).then((sound) => [midiNumber, sound.sound] as const)
|
||||
// )
|
||||
// ).then(
|
||||
// (res) =>
|
||||
// (pianoSounds.current = res.reduce(
|
||||
// (prev, curr) => ({ ...prev, [curr[0]]: curr[1] }),
|
||||
// {}
|
||||
// ))
|
||||
// );
|
||||
// }
|
||||
// }, []);
|
||||
React.useEffect(() => {
|
||||
if (!pianoSounds.current) {
|
||||
Promise.all(
|
||||
Object.entries(PianoNotes).map(([midiNumber, noteResource]) =>
|
||||
Audio.Sound.createAsync(noteResource, {
|
||||
volume: 1,
|
||||
progressUpdateIntervalMillis: 100,
|
||||
}).then((sound) => [midiNumber, sound.sound] as const)
|
||||
)
|
||||
).then((res) => {
|
||||
pianoSounds.current = res.reduce(
|
||||
(prev, curr) => ({ ...prev, [curr[0]]: curr[1] }),
|
||||
{}
|
||||
);
|
||||
console.log('sound loaded');
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
const partitionDims = React.useMemo<[number, number]>(() => {
|
||||
return [data?.pageWidth ?? 0, data?.pageHeight ?? 1];
|
||||
}, [data]);
|
||||
|
||||
@@ -21,7 +21,7 @@ import { RootState } from '../state/Store';
|
||||
import { Translate, translate } from '../i18n/i18n';
|
||||
import { ColorSchemeType } from 'native-base/lib/typescript/components/types';
|
||||
import { useStopwatch } from 'react-use-precision-timer';
|
||||
// import { MIDIAccess, MIDIMessageEvent, requestMIDIAccess } from '@arthi-chaud/react-native-midi';
|
||||
import { MIDIAccess, MIDIMessageEvent, requestMIDIAccess } from '@arthi-chaud/react-native-midi';
|
||||
import * as Linking from 'expo-linking';
|
||||
import url from 'url';
|
||||
import { PianoCanvasContext } from '../models/PianoGame';
|
||||
@@ -260,7 +260,7 @@ const PlayView = ({ songId, route }: RouteProps<PlayViewProps>) => {
|
||||
ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE).catch(() => {});
|
||||
const interval = setInterval(() => {
|
||||
setTime(() => getElapsedTime()); // Countdown
|
||||
}, 300);
|
||||
}, 200);
|
||||
|
||||
return () => {
|
||||
ScreenOrientation.unlockAsync().catch(() => {});
|
||||
@@ -291,10 +291,10 @@ const PlayView = ({ songId, route }: RouteProps<PlayViewProps>) => {
|
||||
if (navigation.getState().routes.at(-1)?.name != route.name) {
|
||||
return;
|
||||
}
|
||||
if (song.data && !webSocket.current) {
|
||||
// requestMIDIAccess().then(onMIDISuccess).catch(onMIDIFailure);
|
||||
if (playType && song.data && !webSocket.current) {
|
||||
requestMIDIAccess().then(onMIDISuccess).catch(onMIDIFailure);
|
||||
}
|
||||
}, [song.data]);
|
||||
}, [song.data, playType]);
|
||||
|
||||
if (!song.data) {
|
||||
return <LoadingView />;
|
||||
|
||||
Reference in New Issue
Block a user