Skip to content

Commit a80c44e

Browse files
committed
fix: Temporarily disable Transit features
1 parent 99161d9 commit a80c44e

9 files changed

Lines changed: 36 additions & 148 deletions

File tree

app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default {
7474
"et",
7575
],
7676
CADisableMinimumFrameDurationOnPhone: true,
77-
LSApplicationQueriesSchemes: ["transit", "maps"],
77+
LSApplicationQueriesSchemes: ["maps"],
7878
},
7979
supportsTablet: true,
8080
config: {

app/(modals)/address.tsx

Lines changed: 19 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ import {
1616
} from "react-native";
1717
import { useSafeAreaInsets } from "react-native-safe-area-context";
1818

19-
import Transit from "@/services/transit";
20-
import { PlaceSuggestion } from "@/services/transit/models/PlaceSuggestion";
21-
import { Stop } from "@/services/transit/models/Stop";
2219
import { TransportAddress } from "@/stores/account/types";
2320
import Button from "@/ui/components/Button";
2421
import Item, { Leading, Trailing } from "@/ui/components/Item";
@@ -91,27 +88,23 @@ export const AddressModal = ({
9188
const theme = useTheme();
9289
const { t } = useTranslation();
9390
const insets = useSafeAreaInsets();
94-
const transit = new Transit();
9591

9692
const [status, requestPermission] = Location.useForegroundPermissions();
9793
const [searchTerm, setSearchTerm] = useState("");
98-
const [searchPlaceResults, setSearchPlaceResults] = useState<
99-
PlaceSuggestion[]
100-
>([]);
101-
const [searchStopResults, setSearchStopResults] = useState<Stop[]>([]);
94+
const [searchResults, setSearchResults] = useState<TransportAddress[]>([]);
10295

103-
let timeout: number | null = null;
96+
let timeout: ReturnType<typeof setTimeout> | null = null;
10497

10598
const search = async () => {
106-
const location = await Location.getCurrentPositionAsync();
107-
const res = await transit.suggestions(
108-
location.coords.latitude,
109-
location.coords.longitude,
110-
searchTerm
111-
);
112-
113-
setSearchPlaceResults(res.suggestions.places);
114-
setSearchStopResults(res.suggestions.stops);
99+
const geocodes = await Location.geocodeAsync(searchTerm);
100+
const results = geocodes.slice(0, 5).map((item) => ({
101+
firstTitle: searchTerm,
102+
secondTitle: `${item.latitude.toFixed(5)}, ${item.longitude.toFixed(5)}`,
103+
address: searchTerm,
104+
latitude: item.latitude,
105+
longitude: item.longitude,
106+
}));
107+
setSearchResults(results);
115108
};
116109

117110
const currentLocationToTransportAddress =
@@ -127,41 +120,12 @@ export const AddressModal = ({
127120
});
128121
};
129122

130-
const placeToTransportAddress = async (
131-
place: PlaceSuggestion
132-
): Promise<TransportAddress> => {
133-
const details = await transit.locationDetails(place.place_id);
134-
135-
return {
136-
firstTitle: place.structured_formatting.main_text,
137-
secondTitle: place.structured_formatting.secondary_text,
138-
address: details.placeDetails.result.formatted_address,
139-
latitude: details.placeDetails.result.geometry.location.lat,
140-
longitude: details.placeDetails.result.geometry.location.lng,
141-
};
142-
};
143-
144-
const stopToTransportAddress = async (
145-
stop: Stop
146-
): Promise<TransportAddress> => {
147-
return new Promise(resolve => {
148-
resolve({
149-
firstTitle: stop.stop_name,
150-
secondTitle: stop.city_name,
151-
address: `${stop.stop_name}, ${stop.city_name}`,
152-
latitude: stop.stop_lat,
153-
longitude: stop.stop_lon,
154-
});
155-
});
156-
};
157-
158123
useEffect(() => {
159124
if (timeout !== null) {
160125
clearTimeout(timeout);
161126
}
162127
if (searchTerm.length === 0) {
163-
setSearchPlaceResults([]);
164-
setSearchStopResults([]);
128+
setSearchResults([]);
165129
return;
166130
}
167131
timeout = setTimeout(() => search(), 200);
@@ -251,39 +215,19 @@ export const AddressModal = ({
251215
</List>
252216
)}
253217

254-
{searchPlaceResults.length > 0 && (
218+
{searchResults.length > 0 && (
255219
<>
256220
<Typography variant={"h6"} color={"secondary"}>
257221
{t("Settings_Transport_Place")}
258222
</Typography>
259223
<List>
260-
{searchPlaceResults.map((item: PlaceSuggestion) => (
224+
{searchResults.map((item: TransportAddress, index: number) => (
261225
<AddressItem
262-
key={item.place_id}
226+
key={`${item.latitude}-${item.longitude}-${index}`}
263227
icon={"MapPin"}
264-
firstLine={item.structured_formatting.main_text}
265-
secondLine={item.structured_formatting.secondary_text}
266-
convertFunction={() => placeToTransportAddress(item)}
267-
save={onConfirm}
268-
/>
269-
))}
270-
</List>
271-
</>
272-
)}
273-
274-
{searchStopResults.length > 0 && (
275-
<>
276-
<Typography variant={"h6"} color={"secondary"}>
277-
{t("Settings_Transport_Stops")}
278-
</Typography>
279-
<List>
280-
{searchStopResults.map((item: Stop) => (
281-
<AddressItem
282-
key={item.raw_stop_id}
283-
icon={"Bus"}
284-
firstLine={item.stop_name}
285-
secondLine={item.city_name}
286-
convertFunction={() => stopToTransportAddress(item)}
228+
firstLine={item.firstTitle}
229+
secondLine={item.secondTitle}
230+
convertFunction={() => Promise.resolve(item)}
287231
save={onConfirm}
288232
/>
289233
))}
@@ -349,4 +293,4 @@ export const AddressModal = ({
349293
)}
350294
</View>
351295
);
352-
};
296+
};

app/(settings)/transport.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export default function TransportView() {
166166
}}
167167
/>
168168
</List.Leading>
169-
{(transport?.defaultApp ?? "transit") === service.id && (
169+
{(transport?.defaultApp ?? "google_maps") === service.id && (
170170
<List.Trailing>
171171
<Papicons name={"Check"} fill={"#E8901C"} />
172172
</List.Trailing>

app/(tabs)/calendar/components/CalendarDay.tsx

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { t } from "i18next";
33
import React, { useMemo, useRef } from "react";
44
import { Dimensions,FlatList, Platform, RefreshControl, StyleSheet, View } from 'react-native';
55

6-
import { Transit } from "@/components/Transit";
76
import { Course as SharedCourse, CourseStatus } from "@/services/shared/timetable";
87
import { TransportStorage } from "@/stores/account/types";
98
import Course from "@/ui/components/Course";
@@ -87,15 +86,6 @@ export const CalendarDay = React.memo(({ dayDate, courses, isRefreshing, onRefre
8786
if (!dayEvents || dayEvents.length === 0) {return dayEvents;}
8887
const result: any[] = [];
8988

90-
// Add transport departure
91-
if (transportInfo?.enabled ?? false) {
92-
result.push({
93-
type: "transit",
94-
isDeparture: true,
95-
targetTime: dayEvents[0].from.getTime() / 1000,
96-
});
97-
}
98-
9989
// Add separator between events
10090
for (let i = 0; i < dayEvents.length; i++) {
10191
result.push(dayEvents[i]);
@@ -117,15 +107,6 @@ export const CalendarDay = React.memo(({ dayDate, courses, isRefreshing, onRefre
117107
}
118108
}
119109

120-
// Add transport arrival
121-
if (transportInfo?.enabled ?? false) {
122-
result.push({
123-
type: "transit",
124-
isDeparture: false,
125-
targetTime: result[result.length - 1].to.getTime() / 1000,
126-
});
127-
}
128-
129110
return result;
130111
}, [dayEvents]);
131112

@@ -157,18 +138,6 @@ export const CalendarDay = React.memo(({ dayDate, courses, isRefreshing, onRefre
157138
keyExtractor={item => item.id || `${item.type}-${item.from || item.targetTime}`}
158139
ListEmptyComponent={<EmptyCalendar />}
159140
renderItem={({ item }: { item: SharedCourse }) => {
160-
if ((item as any).type === "transit") {
161-
return (
162-
<Transit
163-
isDeparture={item.isDeparture}
164-
homeAddress={transportInfo?.homeAddress}
165-
schoolAddress={transportInfo?.schoolAddress}
166-
targetTime={item.targetTime}
167-
service={transportInfo?.defaultApp ?? 'transit'}
168-
/>
169-
);
170-
}
171-
172141
if ((item as any).type === "separator") {
173142
return (
174143
<Course

app/devmode.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const HOSTS: Record<string, { title: string; icon: string }> = {
2727
"api.skolengo.com": { title: "Skolengo", icon: "Skolengo" },
2828
"analytics.papillon.bzh": { title: "Télémétrie", icon: "PapillonIcon" },
2929
"github.com": { title: "Ressource(s)", icon: "Code" },
30-
"transitapp.com": { title: "Transport", icon: "Metro" },
3130
"geopf.fr": { title: "Localisation", icon: "MapPin" },
3231
"raw.githubusercontent.com": { title: "GitHub", icon: "Code" }
3332
};
@@ -357,4 +356,4 @@ export default function DevMode() {
357356
</List>
358357
</View>
359358
);
360-
}
359+
}

constants/AvailableTransportServices.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,6 @@ import { Platform } from "react-native";
33
import { TransportAddress } from "@/stores/account/types";
44

55
export const AvailableTransportServices = [
6-
{
7-
id: "transit",
8-
name: "Transit",
9-
icon: require(`@/assets/images/transport/transit.png`),
10-
baseUrlScheme: "transit://",
11-
generateDeeplink: (
12-
from: TransportAddress,
13-
to: TransportAddress,
14-
isDeparture: boolean,
15-
targetTime: number
16-
): string => {
17-
return `transit://directions?from=${from.firstTitle === "current_location" ? "" : `${from.address}`}&to=${to.address}&${isDeparture ? `arrive_by=${targetTime}` : `leave_at=${targetTime}`}`;
18-
},
19-
},
206
Platform.OS === "ios" && {
217
id: "apple_maps",
228
name: "Apple Maps",
@@ -58,4 +44,4 @@ export const AvailableTransportServices = [
5844
isDeparture: boolean,
5945
targetTime: number
6046
) => string;
61-
}>;
47+
}>;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "papillon",
33
"main": "expo-router/entry",
4-
"version": "8.4.1",
4+
"version": "8.4.2",
55
"scripts": {
66
"start": "expo start",
77
"android": "expo run:android",

stores/account/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export const useAccountStore = create<AccountsStorage>()(
219219
longitude: -1,
220220
latitude: -1,
221221
},
222-
defaultApp: account.transport?.defaultApp ?? "transit",
222+
defaultApp: account.transport?.defaultApp ?? "google_maps",
223223
},
224224
};
225225
}
@@ -251,7 +251,7 @@ export const useAccountStore = create<AccountsStorage>()(
251251
transport: {
252252
...account.transport,
253253
enabled: true,
254-
defaultApp: account.transport?.defaultApp ?? "transit",
254+
defaultApp: account.transport?.defaultApp ?? "google_maps",
255255
homeAddress: address,
256256
},
257257
};
@@ -268,7 +268,7 @@ export const useAccountStore = create<AccountsStorage>()(
268268
transport: {
269269
...account.transport,
270270
enabled: true,
271-
defaultApp: account.transport?.defaultApp ?? "transit",
271+
defaultApp: account.transport?.defaultApp ?? "google_maps",
272272
schoolAddress: address,
273273
},
274274
};

utils/transport.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import { canOpenURL } from "expo-linking";
22
import * as Location from "expo-location";
33

44
import { AvailableTransportServices } from "@/constants/AvailableTransportServices";
5-
import Transit from "@/services/transit";
65
import { TransportAddress, TransportStorage } from "@/stores/account/types";
76
import { log } from "@/utils/logger/logger";
87

98
export const initializeTransport = async (address: string | undefined): Promise<TransportStorage> => {
109
let defaultApp = 'google_maps'; //We use Google Maps because it's a weblink !
11-
const transit = new Transit();
1210

1311
for (const service of AvailableTransportServices) {
1412
try {
@@ -25,23 +23,15 @@ export const initializeTransport = async (address: string | undefined): Promise<
2523
let schoolAddress: TransportAddress | undefined = undefined;
2624

2725
if (address !== undefined && address !== null && permission.granted) {
28-
const currentLocation = await Location.getCurrentPositionAsync();
29-
const result = await transit.suggestions(
30-
currentLocation.coords.latitude,
31-
currentLocation.coords.longitude,
32-
address
33-
);
34-
35-
if (result.suggestions.places.length > 0) {
36-
const place = result.suggestions.places[0];
37-
const geocode = await transit.locationDetails(place.place_id);
38-
26+
const geocodes = await Location.geocodeAsync(address);
27+
if (geocodes.length > 0) {
28+
const geocode = geocodes[0];
3929
schoolAddress = {
40-
firstTitle: place.structured_formatting.main_text,
41-
secondTitle: place.structured_formatting.secondary_text,
42-
address: geocode.placeDetails.result.formatted_address,
43-
longitude: geocode.placeDetails.result.geometry.location.lng,
44-
latitude: geocode.placeDetails.result.geometry.location.lat
30+
firstTitle: address,
31+
secondTitle: "",
32+
address,
33+
longitude: geocode.longitude,
34+
latitude: geocode.latitude
4535
};
4636
}
4737
}
@@ -58,4 +48,4 @@ export const initializeTransport = async (address: string | undefined): Promise<
5848
},
5949
schoolAddress,
6050
};
61-
}
51+
}

0 commit comments

Comments
 (0)