Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/room-wireframe-integration #156

Merged
merged 9 commits into from
Apr 9, 2024
13 changes: 12 additions & 1 deletion backend/src/RoomStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,18 @@ export default class RoomStorage {
const newPlaybackState = newPlaybackStateResponse.data;
room.setPlaybackState(newPlaybackState);

if (!newPlaybackState) return console.debug("No music is playing");
if (!newPlaybackState) {
if (
room.getQueue().length > 0 &&
room.getStreamingService().isClientSide()
) {
const nextTrack = room.shiftQueue();
if (!nextTrack) return console.debug("No more tracks in the queue");
return remote.playTrack(nextTrack.url);
}

return console.debug("No music is playing");
}

const remainingTime =
newPlaybackState.duration - newPlaybackState.currentTime;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/socketio/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class Room {
room.setRemote(remote);
roomStorage.addRoom(room);
} else {
room.setHostSocket(hostSocket);
if (hostSocket) room.setHostSocket(hostSocket);
}

return { data: room, error: null };
Expand Down
6 changes: 5 additions & 1 deletion expo/app/(tabs)/rooms/[id]/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Alert from "../../../../components/Alert";
import ErrorBoundary from "../../../../components/ErrorBoundary";
import RoomErrorBoundary from "../../../../components/ErrorComponent/RoomError";
import WebsocketError from "../../../../components/ErrorComponent/WebsocketError";
import HeaderBack from "../../../../components/HeaderBack";
import { useAsyncError } from "../../../../lib/AsyncError";
import { getApiUrl } from "../../../../lib/apiUrl";
import SocketIo from "../../../../lib/socketio";
Expand Down Expand Up @@ -94,7 +95,10 @@ export default function RoomTabLayout() {
<ErrorBoundary fallback={<RoomErrorBoundary />}>
<WebSocketProvider roomId={id}>
<Stack>
<Stack.Screen name="index" options={{ title: "Nom de la salle" }} />
<Stack.Screen
name="index"
options={{ header: () => <HeaderBack /> }}
/>
<Stack.Screen
name="invite"
options={{ presentation: "modal", title: "Menu d'invitation" }}
Expand Down
43 changes: 31 additions & 12 deletions expo/app/(tabs)/rooms/[id]/invite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useEffect, useState } from "react";
import { Alert, Platform, StyleSheet } from "react-native";

import Button from "../../../../components/Button";
import CustomTextInput from "../../../../components/CustomTextInput";
import { View } from "../../../../components/Themed";
import { supabase } from "../../../../lib/supabase";

Expand Down Expand Up @@ -60,19 +61,26 @@ export default function InvitationModal() {

return (
<View style={styles.modalContent}>
<View style={styles.shareButtonsContainer}>
{isCopied ? (
<Button block prependIcon={<Check />}>
Lien copié
<View style={styles.shareOptions}>
<CustomTextInput
value={room?.code || "no code"}
style={styles.code}
disabled
/>
<View style={styles.shareButtonsContainer}>
{isCopied ? (
<Button block prependIcon={<Check />}>
Lien copié
</Button>
) : (
<Button block onPress={handleShare} prependIcon={<Share />}>
Copier le lien
</Button>
)}
<Button type="outline" icon={<QrCode />} href={`/rooms/${id}/qrcode`}>
Afficher le QR code
</Button>
) : (
<Button block onPress={handleShare} prependIcon={<Share />}>
Copier le lien
</Button>
)}
<Button type="outline" icon={<QrCode />} href={`/rooms/${id}/qrcode`}>
Afficher le QR code
</Button>
</View>
</View>
<Button block href={`/rooms/${id}`} prependIcon={<ArrowRight />}>
Retour à la salle d'écoute
Expand Down Expand Up @@ -122,4 +130,15 @@ const styles = StyleSheet.create({
gap: 16,
alignSelf: "stretch",
},
shareOptions: {
gap: 16,
flexDirection: "column",
maxWidth: 390,
},
code: {
textAlign: "center",
fontFamily: "Outfit-Bold",
borderRadius: 16,
borderWidth: 0,
},
});
9 changes: 9 additions & 0 deletions expo/app/(tabs)/rooms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,14 @@ const styles = StyleSheet.create({
marginHorizontal: 24,
marginVertical: 21,
gap: 36,
maxHeight: 270,
},
buttonContainer: {
gap: 8,
},
title: {
fontSize: 32,
fontFamily: "Outfit-Bold",
maxWidth: 354,
},
});
Loading
Loading