Skip to content

Commit 51ac539

Browse files
committed
finish upgrade fixes
1 parent 6390e84 commit 51ac539

File tree

19 files changed

+102
-75
lines changed

19 files changed

+102
-75
lines changed

apps/app/src/app/(home)/(timeline)/[id]/delete.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export default function DeleteTask() {
1616

1717
const onSuccess = () => {
1818
void utils.task.timeline.refetch({ daysBack, daysForward })
19-
router.push("/")
19+
router.back()
2020
}
2121
const deleteTask = api.task.delete.useMutation({ onSuccess })
2222
const deleteFutureTasks = api.task.delete.useMutation({ onSuccess })
2323
const handleDelete = (shouldDeleteFuture: boolean) => {
24-
if (!id) return router.push("/")
24+
if (!id) return router.back()
2525
if (!shouldDeleteFuture) return deleteTask.mutate({ id: id as string })
2626
return deleteFutureTasks.mutate({ id: id as string, shouldDeleteFuture })
2727
}

apps/app/src/app/(home)/(timeline)/[id]/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ function EditTaskForm({ task }: { task: Task }) {
5757

5858
const update = api.task.update.useMutation({
5959
onSuccess: (updatedTask) => {
60-
utils.task.timeline.setData({ daysBack, daysForward }, (old) => {
61-
if (!old) return old
62-
return old.map((t) =>
63-
t.id === task.id
64-
? { ...t, ...updatedTask, date: dayjs(updatedTask.date!).startOf("day").add(12, "hours").format("YYYY-MM-DD") }
65-
: t,
66-
)
67-
})
60+
const date = updatedTask.date
61+
if (date) {
62+
utils.task.timeline.setData({ daysBack, daysForward }, (old) => {
63+
if (!old) return old
64+
// gota keep the old order as thats never manually updated
65+
return old.map((t) => (t.id === task.id ? { ...t, ...updatedTask, order: t.order, date } : t))
66+
})
67+
}
6868
utils.task.byId.setData({ id: task.id }, updatedTask)
6969
router.back()
7070
},

apps/app/src/app/(home)/(timeline)/backlog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function TaskItem({ task }: { task: RouterOutputs["task"]["backlog"][number] })
100100
<View className="flex flex-1 flex-row space-x-2 p-3">
101101
<TouchableOpacity
102102
onLongPress={handleOpenMenu}
103-
onPress={() => router.push({ pathname: "index", params: { id: task.id } })}
103+
onPress={() => router.navigate({ pathname: "/[id]", params: { id: task.id } })}
104104
className="flex-1 flex-row justify-between"
105105
>
106106
<Text

apps/app/src/app/(home)/(timeline)/elements/[elementId]/_layout.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { useBackgroundColor } from "~/lib/tailwind"
55
export default function ElementsLayout() {
66
const backgroundColor = useBackgroundColor()
77
return (
8-
<Stack initialRouteName="index" screenOptions={{ contentStyle: { backgroundColor }, headerShown: false }}>
8+
<Stack
9+
initialRouteName="index"
10+
screenOptions={{ contentStyle: { backgroundColor }, headerShown: false, presentation: "modal" }}
11+
>
912
<Stack.Screen name="index" />
10-
11-
<Stack.Screen name="move" options={{ presentation: "modal" }} />
13+
<Stack.Screen name="move" />
1214
</Stack>
1315
)
1416
}

apps/app/src/app/(home)/(timeline)/elements/[elementId]/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function ElementDetail() {
2525
if (router.canGoBack()) {
2626
router.back()
2727
} else {
28-
router.replace("/")
28+
router.navigate("/")
2929
}
3030
},
3131
})

apps/app/src/app/(home)/(timeline)/elements/[elementId]/move.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function ElementsDetailMove() {
1818
onSuccess: () => {
1919
void utils.element.grouped.refetch()
2020
if (router.canGoBack()) return router.back()
21-
void router.replace("/elements")
21+
void router.navigate("/elements")
2222
},
2323
})
2424
return (

apps/app/src/app/(home)/(timeline)/elements/create.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ScrollView } from "react-native"
2-
import { AllRoutes, Href, useGlobalSearchParams, useRouter } from "expo-router"
2+
import { type AllRoutes, useGlobalSearchParams, useRouter } from "expo-router"
33

44
import { ElementForm } from "~/components/ElementForm"
55
import { ModalView } from "~/components/ModalView"
@@ -15,8 +15,8 @@ export default function CreateElement() {
1515
onSuccess: async (data) => {
1616
void utils.element.grouped.refetch()
1717
await utils.element.all.refetch()
18-
// if (!redirect) return router.back()
19-
router.replace({ pathname: redirect as Href<AllRoutes>, params: { ...params, elementId: data.id } })
18+
if (!redirect) return router.back()
19+
router.navigate({ pathname: redirect as AllRoutes, params: { ...params, elementId: data.id } })
2020
},
2121
})
2222

apps/app/src/app/(home)/(timeline)/elements/index.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ function ElementItem({ element }: { element: RouterOutputs["element"]["grouped"]
5555
void utils.element.all.refetch()
5656
void utils.element.grouped.refetch()
5757
void utils.task.timeline.refetch({ daysBack, daysForward })
58-
if (router.canGoBack()) {
59-
router.back()
60-
} else {
61-
router.replace("/")
62-
}
6358
},
6459
})
6560
const { showActionSheetWithOptions } = useActionSheet()
@@ -77,7 +72,7 @@ function ElementItem({ element }: { element: RouterOutputs["element"]["grouped"]
7772
break
7873
case 1:
7974
// Edit
80-
router.push({ pathname: `/(home)/(timeline)/elements/[elementId]/`, params: { elementId: element.id } })
75+
router.push(`/elements/${element.id}/`)
8176
break
8277
case 2:
8378
// Move
@@ -93,7 +88,7 @@ function ElementItem({ element }: { element: RouterOutputs["element"]["grouped"]
9388
return (
9489
<View>
9590
<TouchableOpacity
96-
onPress={() => router.push({ pathname: `/(home)/(timeline)/elements/[elementId]/`, params: { elementId: element.id } })}
91+
onPress={() => router.push(`/elements/${element.id}/`)}
9792
onLongPress={handleOpenMenu}
9893
activeOpacity={0.7}
9994
className="flex flex-row items-center space-x-2 py-1"

apps/app/src/app/(home)/(timeline)/elements/select.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react"
22
import { ActivityIndicator, Pressable, ScrollView, View } from "react-native"
33
import dayjs from "dayjs"
4-
import { useGlobalSearchParams, useRouter } from "expo-router"
4+
import { type AllRoutes, useGlobalSearchParams, useRouter } from "expo-router"
55
import { matchSorter } from "match-sorter"
66

77
import { join } from "@element/shared"
@@ -29,7 +29,7 @@ export default function SelectElement() {
2929
const router = useRouter()
3030
const onSelect = (element: { id: string; color: string; name: string }) => {
3131
if (!redirect) return router.back()
32-
router.push({ pathname: redirect as string, params: { ...params, elementId: element.id } })
32+
router.navigate({ pathname: redirect as AllRoutes, params: { ...params, elementId: element.id } })
3333
}
3434
return (
3535
<ModalView title="Select element">

apps/app/src/app/(home)/(timeline)/repeat-select.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ScrollView, TouchableOpacity } from "react-native"
2-
import { useGlobalSearchParams, useRouter } from "expo-router"
2+
import { type AllRoutes, useGlobalSearchParams, useRouter } from "expo-router"
33

44
import { type TaskRepeat } from "@element/database/types"
55
import { join } from "@element/shared"
@@ -14,7 +14,7 @@ export default function RepeatSelect() {
1414

1515
const handleTo = (repeat: TaskRepeat) => {
1616
if (!redirect) return router.back()
17-
router.push({ params: { ...params, repeat }, pathname: redirect as string })
17+
router.navigate({ params: { ...params, repeat }, pathname: redirect as AllRoutes })
1818
}
1919

2020
return (

0 commit comments

Comments
 (0)