Skip to content

Commit

Permalink
Several bugfixes: (#23)
Browse files Browse the repository at this point in the history
* Fix player auto-expanding again the first time you try and collapse it
* Fix tapping the notification bringing you to a "not found" screen
* Fix being able to navigate to the same screen over and over, causing a confusing navigation experience
  • Loading branch information
doughsay authored Oct 30, 2024
1 parent fbfddc8 commit 7f64ee0
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 16 deletions.
Binary file modified bun.lockb
Binary file not shown.
11 changes: 7 additions & 4 deletions src/app/(tabs)/(library)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useSessionStore } from "@/src/stores/session";
import { Redirect, Stack } from "expo-router";

const getId = ({ params }: { params?: Record<string, any> | undefined }) =>
params?.id;

export default function AppLayout() {
const session = useSessionStore((state) => state.session);

Expand All @@ -11,10 +14,10 @@ export default function AppLayout() {
return (
<Stack>
<Stack.Screen name="index" options={{ title: "Library" }} />
<Stack.Screen name="media/[id]" options={{ title: "" }} />
<Stack.Screen name="person/[id]" options={{ title: "" }} />
<Stack.Screen name="series/[id]" options={{ title: "" }} />
<Stack.Screen name="book/[id]" options={{ title: "" }} />
<Stack.Screen name="media/[id]" getId={getId} />
<Stack.Screen name="person/[id]" getId={getId} />
<Stack.Screen name="series/[id]" getId={getId} />
<Stack.Screen name="book/[id]" getId={getId} />
</Stack>
);
}
8 changes: 4 additions & 4 deletions src/app/(tabs)/(library)/media/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ function OtherEditions({
<View className="mt-8">
<Pressable
onPress={() => {
router.push({
router.navigate({
pathname: "/book/[id]",
params: { id: media[0].book.id },
});
Expand Down Expand Up @@ -881,7 +881,7 @@ function OtherBooksInSeries({
<View className="mt-8">
<Pressable
onPress={() => {
router.push({
router.navigate({
pathname: "/series/[id]",
params: { id: series.id },
});
Expand Down Expand Up @@ -1038,7 +1038,7 @@ function OtherBooksByAuthor({
<View className="mt-8">
<Pressable
onPress={() => {
router.push({
router.navigate({
pathname: "/person/[id]",
params: { id: author.person.id },
});
Expand Down Expand Up @@ -1212,7 +1212,7 @@ function OtherMediaByNarrator({
<View className="mt-8">
<Pressable
onPress={() => {
router.push({
router.navigate({
pathname: "/person/[id]",
params: { id: narrator.person.id },
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/(tabs)/downloads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function DownloadRow({ session, download }: DownloadRowProps) {
const [isModalVisible, setIsModalVisible] = useState(false);

const navigateToBook = () => {
router.push({
router.navigate({
pathname: "/media/[id]",
params: {
id: download.media.id,
Expand Down
15 changes: 15 additions & 0 deletions src/app/+native-intent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useTrackPlayerStore } from "@/src/stores/trackPlayer";

type PathArgs = {
path: string;
initial: boolean;
};

export function redirectSystemPath({ path }: PathArgs) {
if (path === "trackplayer://notification.click") {
useTrackPlayerStore.getState().requestExpandPlayer();
return null;
} else {
return path;
}
}
2 changes: 1 addition & 1 deletion src/app/sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useState } from "react";
import { Button, Text, TextInput, View } from "react-native";
import colors from "tailwindcss/colors";

export default function SignIn() {
export default function SignInScreen() {
const { session, error, isLoading, signIn, clearError } = useSessionStore(
(state) => state,
);
Expand Down
6 changes: 3 additions & 3 deletions src/components/TabBarWithPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export default function TabBarWithPlayer({
useEffect(() => {
if (!expanded && lastPlayerExpandRequest) {
expandLocal();
expandPlayerHandled();
}
expandPlayerHandled();
}, [expandLocal, expanded, lastPlayerExpandRequest, expandPlayerHandled]);

const tabBarHeight = 50 + insets.bottom;
Expand Down Expand Up @@ -333,7 +333,7 @@ export default function TabBarWithPlayer({
} else {
collapseLocal();
setTimeout(() => {
router.push({
router.navigate({
pathname: "/media/[id]",
params: { id: media.id, title: media.book.title },
});
Expand Down Expand Up @@ -400,7 +400,7 @@ export default function TabBarWithPlayer({
onPress={() => {
collapseLocal();
setTimeout(() => {
router.push({
router.navigate({
pathname: "/media/[id]",
params: { id: media.id, title: media.book.title },
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/Tiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ export function Tile({ book, media, seriesBook, style }: TileProps) {

const navigateToBook = () => {
if (media.length === 1) {
router.push({
router.navigate({
pathname: "/media/[id]",
params: { id: media[0].id, title: book.title },
});
} else {
router.push({
router.navigate({
pathname: "/book/[id]",
params: { id: book.id, title: book.title },
});
Expand Down Expand Up @@ -148,7 +148,7 @@ export function PersonTile(props: PersonTileProps) {
const router = useRouter();

const navigateToPerson = () => {
router.push({
router.navigate({
pathname: "/person/[id]",
params: { id: personId, title: realName },
});
Expand Down

0 comments on commit 7f64ee0

Please sign in to comment.