Skip to content

Commit

Permalink
Fix/working version (#11)
Browse files Browse the repository at this point in the history
* init eslint

* fix round #1

* fix round #2

* fix round #3

* fix round #4

* fix round #5

* fix round #6

* fix round #7

* fix round #8

* fix round #9
  • Loading branch information
xiduzo authored Nov 8, 2023
1 parent df70e4c commit 9a3bdf0
Show file tree
Hide file tree
Showing 86 changed files with 8,499 additions and 4,236 deletions.
9 changes: 3 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
/** @type {import("eslint").Linter.Config} */
const config = {
root: true,
extends: ["fissa"],
extends: ["@fissa/eslint-config"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
// @ts-ignore-next-line
tsconfigRootDir: __dirname,
project: [
"./tsconfig.json",
"./apps/*/tsconfig.json",
"./packages/*/tsconfig.json",
],
project: ["./tsconfig.json", "./apps/*/tsconfig.json", "./packages/*/tsconfig.json"],
},
settings: {
next: {
Expand Down
2 changes: 1 addition & 1 deletion apps/expo/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConfigContext, ExpoConfig } from "@expo/config";
import { type ConfigContext, type ExpoConfig } from "@expo/config";

const version = "3.1.5"; // EAS VERSION
// Should be bumped every time a new build is made
Expand Down
6 changes: 2 additions & 4 deletions apps/expo/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ const RootLayout = () => (
export default RootLayout;

const Updater = () => {
const handleUpdate = useCallback(async ({ type }: Updates.UpdateEvent) => {
const handleUpdate = useCallback(({ type }: Updates.UpdateEvent) => {
if (type === Updates.UpdateEventType.ERROR) {
// Handle error
} else if (type === Updates.UpdateEventType.NO_UPDATE_AVAILABLE) {
// Handle no update available
} else if (type === Updates.UpdateEventType.UPDATE_AVAILABLE) {
// Handle update available
toast.info({ message: "Installing update" });
await Updates.fetchUpdateAsync();

await Updates.reloadAsync();
Updates.fetchUpdateAsync().then(Updates.reloadAsync).catch(console.log);
}
}, []);

Expand Down
4 changes: 3 additions & 1 deletion apps/expo/app/fissa/[pin]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const Fissa = () => {

const invalidate = useInvalidateFissa();

useOnActiveApp(() => invalidate(String(pin)));
useOnActiveApp(() => {
invalidate(String(pin)).catch(console.log);
});

if (!pin) return null;

Expand Down
6 changes: 3 additions & 3 deletions apps/expo/app/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { View } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { Stack } from "expo-router";
import { theme } from "@fissa/tailwind-config";
import { logger, useSpotify } from "@fissa/utils";
import { useSpotify } from "@fissa/utils";

import {
Action,
Expand All @@ -29,7 +29,7 @@ const Home = () => {
.then((user) => {
setIsPremium(user.product === "premium");
})
.catch(logger.error);
.catch(console.log);
}, [spotify]);

return (
Expand Down Expand Up @@ -86,7 +86,7 @@ const AccountDetails = () => {
const handleSignOut = useCallback(() => {
toggleAccountDetails();
signOut();
}, [toggleAccountDetails]);
}, [toggleAccountDetails, signOut]);

return (
<>
Expand Down
21 changes: 12 additions & 9 deletions apps/expo/app/host/fromPlaylist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ const FromPlaylist = () => {
const { mutateAsync, isLoading } = useCreateFissa();

const start = useCallback(async () => {
const spotifyTracks = await getPlaylistTracks(selectedPlaylist!.id, spotify);
if (!selectedPlaylist) return;
const spotifyTracks = await getPlaylistTracks(selectedPlaylist.id, spotify);

await mutateAsync(spotifyTracks);

setSelectedPlaylist(null);
}, [selectedPlaylist]);
}, [selectedPlaylist, mutateAsync, spotify]);

return (
<SafeAreaView style={{ backgroundColor: theme["900"] }}>
Expand All @@ -43,13 +44,15 @@ const FromPlaylist = () => {
<Typography variant="h2" centered inverted className="mb-8" accessibilityElementsHidden>
Your fissa will start based on
</Typography>
<PlaylistListItem
playlist={selectedPlaylist!}
hasBorder
inverted
className="mb-8"
accessibilityElementsHidden
/>
{selectedPlaylist && (
<PlaylistListItem
playlist={selectedPlaylist}
hasBorder
inverted
className="mb-8"
accessibilityElementsHidden
/>
)}
<Button
title="Let's kick it"
inverted
Expand Down
17 changes: 13 additions & 4 deletions apps/expo/app/host/fromTracks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ import { useCreateFissa } from "../../src/hooks";
const FromTracks = () => {
const { mutateAsync, isLoading } = useCreateFissa();

const handleAddTracks = useCallback(async (tracks: SpotifyApi.TrackObjectFull[]) => {
await mutateAsync(tracks);
}, []);
const handleAddTracks = useCallback(
async (tracks: SpotifyApi.TrackObjectFull[]) => {
await mutateAsync(tracks);
},
[mutateAsync],
);

return <PickTracks onAddTracks={handleAddTracks} disabledAction={isLoading} actionTitle="Start fissa" />;
return (
<PickTracks
onAddTracks={handleAddTracks}
disabledAction={isLoading}
actionTitle="Start fissa"
/>
);
};

export default FromTracks;
10 changes: 7 additions & 3 deletions apps/expo/app/host/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ import { toast } from "../../src/utils";
const Host = () => {
const spotify = useSpotify();

const { mutateAsync, isLoading } = useCreateFissa();
const { mutateAsync, isLoading } = useCreateFissa({
onSettled: () => {
toast.hide();
},
});

const handleSurpriseMe = useCallback(async () => {
toast.info({
icon: "🦔",
message: "An explorer I see, making a fissa just for you",
duration: 5000,
duration: 60 * 1000,
});
const { items } = await spotify.getMyTopTracks();
const { tracks } = await spotify.getRecommendations({
Expand All @@ -30,7 +34,7 @@ const Host = () => {
});

await mutateAsync(tracks);
}, [spotify]);
}, [spotify, mutateAsync]);

return (
<SafeAreaView style={{ backgroundColor: theme["900"] }}>
Expand Down
8 changes: 4 additions & 4 deletions apps/expo/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useRef } from "react";
import React, { useEffect, useRef } from "react";
import { Animated, View } from "react-native";
import { Stack, useRouter } from "expo-router";
import * as SystemUI from "expo-system-ui";
Expand Down Expand Up @@ -61,8 +61,8 @@ const Index = () => {
replace("/home");
}, [user, replace]);

useMemo(async () => {
await SystemUI.setBackgroundColorAsync(theme["900"]);
useEffect(() => {
SystemUI.setBackgroundColorAsync(theme["900"]).catch(console.log);
}, []);

useEffect(() => {
Expand All @@ -89,7 +89,7 @@ const Index = () => {
replace("/home");
});
});
}, [replace]);
}, [replace, signedInAnimation, notSignedInAnimation, colorAnimation]);

return (
<Animated.View style={{ backgroundColor }} className="h-full items-center justify-between px-6">
Expand Down
11 changes: 5 additions & 6 deletions apps/expo/app/join.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { useCallback, useMemo, useRef, useState } from "react";
import {
NativeSyntheticEvent,
SafeAreaView,
TextInput,
TextInputChangeEventData,
TextInputTextInputEventData,
View,
type NativeSyntheticEvent,
type TextInputChangeEventData,
type TextInputTextInputEventData,
} from "react-native";
import { NotificationFeedbackType, notificationAsync } from "expo-haptics";
import { Stack, useRouter } from "expo-router";
import { theme } from "@fissa/tailwind-config";
import { logger } from "@fissa/utils";

import { Button, PageTemplate, Rejoin, Typography } from "../src/components";
import { toast } from "../src/utils/Toast";
Expand All @@ -24,7 +23,7 @@ const Join = () => {
enabled: !pin.includes(""),
onSuccess: ({ pin }) => {
toast.success({ message: "Enjoy the fissa", icon: "🎉" });
notificationAsync(NotificationFeedbackType.Success).catch(logger.warning);
notificationAsync(NotificationFeedbackType.Success).catch(console.warn);
replace(`/fissa/${pin}`);
},
onError: ({ message }) => {
Expand All @@ -47,7 +46,7 @@ const Join = () => {
current?.clear();
});
},
[],
[keys],
);

const handlePress = useCallback(
Expand Down
2 changes: 1 addition & 1 deletion apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@fissa/eslint-config": "*",
"@expo/config-plugins": "^6.0.1",
"@types/react": "^18.0.38",
"eslint": "^8.34.0",
"eslint-config-acme": "0.0.0",
"postcss": "^8.4.23",
"tailwindcss": "3.3.1",
"typescript": "^4.9.5"
Expand Down
6 changes: 3 additions & 3 deletions apps/expo/src/components/pages/PageTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from "react";
import { View, ViewProps } from "react-native";
import { VariantProps, cva } from "@fissa/utils";
import { type FC } from "react";
import { View, type ViewProps } from "react-native";
import { cva, type VariantProps } from "@fissa/utils";

export const PageTemplate: FC<Props> = ({ children, className, ...props }) => {
return (
Expand Down
7 changes: 4 additions & 3 deletions apps/expo/src/components/pages/fissa/ListEmptyComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useCallback } from "react";
import { useCallback, type FC } from "react";
import { NotificationFeedbackType, notificationAsync } from "expo-haptics";
import { useSearchParams } from "expo-router";
import { useIsOwner, useRestartFissa } from "@fissa/hooks";
Expand Down Expand Up @@ -28,15 +28,16 @@ export const ListEmptyComponent: FC<Props> = ({ isLoading }) => {

const handleDeviceSelect = useCallback(
(device: SpotifyApi.UserDevice) => async () => {
if (!device.id) return;
try {
await spotify.transferMyPlayback([device.id!]);
await spotify.transferMyPlayback([device.id]);
await mutateAsync();
} catch (e) {
toast.error({
message: `Failed to connect to ${device.name}`,
});
} finally {
fetchDevices();
fetchDevices().catch(console.log);
}
},
[spotify, fetchDevices, mutateAsync],
Expand Down
4 changes: 2 additions & 2 deletions apps/expo/src/components/pages/fissa/ListFooterComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from "react";
import { type FC } from "react";
import { View } from "react-native";

import { Typography } from "../../shared";
Expand All @@ -11,7 +11,7 @@ export const ListFooterComponent: FC<{ tracksShown: boolean }> = ({ tracksShown
<Typography variant="h1" className="mb-4">
🦦
</Typography>
<Typography variant="bodyM">Add songs or I'll fill the queue</Typography>
<Typography variant="bodyM">Add songs or I&apos;ll fill the queue</Typography>
</View>
);
};
13 changes: 3 additions & 10 deletions apps/expo/src/components/pages/fissa/SelectedTrackPopover.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
import { FC } from "react";
import { type FC } from "react";

import { Divider, Popover, TrackListItem } from "../../shared";
import { TrackActions } from "./TrackActions";

export const SelectedTrackPopover: FC<Props> = ({ currentTrackIndex, track, onRequestClose }) => {
export const SelectedTrackPopover: FC<Props> = ({ track, onRequestClose }) => {
return (
<Popover visible={!!track} onRequestClose={onRequestClose}>
{track && <TrackListItem inverted track={track} hasBorder />}
<Divider />
{track && (
<TrackActions
currentTrackIndex={currentTrackIndex}
track={track}
onPress={onRequestClose}
/>
)}
{track && <TrackActions track={track} onPress={onRequestClose} />}
</Popover>
);
};

interface Props {
track?: SpotifyApi.TrackObjectFull;
currentTrackIndex: number;
onRequestClose: () => void;
}
13 changes: 7 additions & 6 deletions apps/expo/src/components/pages/fissa/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FC, useCallback, useState } from "react";
import { useCallback, useState, type FC } from "react";
import { NotificationFeedbackType, notificationAsync } from "expo-haptics";
import { useRouter, useSearchParams } from "expo-router";
import { useGetTracks, useIsOwner } from "@fissa/hooks";
import { logger, splitInChunks, useSpotify, useTracks } from "@fissa/utils";
import { splitInChunks, useSpotify, useTracks } from "@fissa/utils";

import { useAuth } from "../../../providers";
import { toast } from "../../../utils";
Expand All @@ -21,7 +21,7 @@ export const Settings = () => {
const goToHome = useCallback(() => {
togglePopover();
push("/home");
}, []);
}, [togglePopover, push]);

if (!pin) return null;

Expand Down Expand Up @@ -59,26 +59,27 @@ const CreatePlaylistAction: FC<ActionProps> = ({ pin, onRequestClose }) => {
const [isCreatingPlaylist, setIsCreatingPlaylist] = useState(false);

const handleCreatePlaylist = useCallback(async () => {
if (!user) return;
setIsCreatingPlaylist(true);
await notificationAsync(NotificationFeedbackType.Success);
onRequestClose();
spotify
.createPlaylist(user!.id, {
.createPlaylist(user.id, {
name: `Fissa ${pin}`,
description: "Playlist created by Fissa",
})
.then(({ id }) => {
const uris = tracks?.map(({ uri }) => uri) ?? [];
const chunks = splitInChunks(uris, 100);
chunks.forEach((chunk) => {
spotify.addTracksToPlaylist(id, chunk).catch(logger.warning);
spotify.addTracksToPlaylist(id, chunk).catch(console.warn);
});
})
.finally(() => {
toast.success({ message: "Playlist created", icon: "🎉" });
setIsCreatingPlaylist(false);
});
}, [spotify, user, tracks, onRequestClose]);
}, [spotify, user, tracks, onRequestClose, pin]);

return (
<Action
Expand Down
Loading

1 comment on commit 9a3bdf0

@vercel
Copy link

@vercel vercel bot commented on 9a3bdf0 Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.