Skip to content

Commit

Permalink
refactor: useless methods
Browse files Browse the repository at this point in the history
  • Loading branch information
GaspardBBY committed Apr 9, 2024
1 parent 9d378f2 commit 9ab0787
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
21 changes: 18 additions & 3 deletions expo/components/player/RoomPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import Player from "./Player";
import PlayerControls from "./PlayerControls";
import buildAudioRemote, { PlayerRemote } from "../../lib/audioRemote";
import { ActiveRoom } from "../../lib/useRoom";
import Button from "../Button";
import Warning from "../Warning";

type RoomPlayerProps = {
room: ActiveRoom;
socket: Socket<ServerToClientEvents, ClientToServerEvents>;
isHost: boolean;
};

const RoomPlayer: React.FC<RoomPlayerProps> = ({ room, socket }) => {
const isHost = true;
const RoomPlayer: React.FC<RoomPlayerProps> = ({ room, socket, isHost }) => {
const [remote, setRemote] = useState<PlayerRemote>();
const [error, setError] = useState<string>();

Expand All @@ -43,6 +44,18 @@ const RoomPlayer: React.FC<RoomPlayerProps> = ({ room, socket }) => {
});
}, [socket]);

// const playCoolSong = async () => {
// if (!remote) return;

// if (room.streaming_services?.service_name === "Spotify") {
// await remote.playTrack("spotify:track:6afdNrotJ1PCt9DoFiHpLj");
// } else if (room.streaming_services?.service_name === "SoundCloud") {
// await remote.playTrack(
// "https://soundcloud.com/martingarrix/martin-garrix-lloyiso-real-love"
// );
// }
// };

return (
<>
{error && <Warning label={error} variant="error" />}
Expand All @@ -53,13 +66,15 @@ const RoomPlayer: React.FC<RoomPlayerProps> = ({ room, socket }) => {
socket={socket}
/>
)}
<Player state={playbackState} />
<Player state={playbackState} isHost={isHost} />

{isHost && remote && (
<View style={{ paddingTop: 32 }}>
<PlayerControls state={playbackState} remote={remote} />
</View>
)}
</View>
{/* <Button onPress={playCoolSong}>Play song</Button> */}
</>
);
};
Expand Down
18 changes: 0 additions & 18 deletions expo/lib/room-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,3 @@ export async function getRoomId(
if (roomsError) return { data: null, error: roomsError };
return { data: room.id, error: null };
}

export async function getRoomHostedByUser(
roomId: string,
userProfile: UserProfile | null,
isActive: boolean
): Promise<{ data: Room[] | null }> {
if (!userProfile) return { data: null };

const { data: room } = await supabase
.from("rooms")
.select("*")
.eq("id", roomId)
.eq("host_user_profile_id", userProfile.user_profile_id)
.eq("is_active", isActive);

if (!room) return { data: null };
return { data: room };
}

0 comments on commit 9ab0787

Please sign in to comment.