diff --git a/app/native-modules/geolocation/android.ts b/app/native-modules/geolocation/android.ts index 8c3299a73..bd0d9dfdf 100644 --- a/app/native-modules/geolocation/android.ts +++ b/app/native-modules/geolocation/android.ts @@ -125,7 +125,6 @@ export class AndroidService implements LianeGeolocation { const status = await request( this.Platform.Version === 29 ? PERMISSIONS.ANDROID.ACCESS_BACKGROUND_LOCATION : PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION ); - //console.log(status); if (status === "granted") { return true; } else { diff --git a/app/src/api/storage.ts b/app/src/api/storage.ts index 37cb9947c..4487452a6 100644 --- a/app/src/api/storage.ts +++ b/app/src/api/storage.ts @@ -6,7 +6,7 @@ import { AppStorage as CommonAppStorage, AuthResponse, AuthUser, FullUser, Geolo export type AppSettings = Readonly<{ "map.lianeTrafficAsWidth": boolean; "map.lianeTrafficAsColor": boolean; - geolocation: GeolocationLevel | null; + geolocation?: GeolocationLevel; }>; export class ReactNativeStorage implements CommonAppStorage { @@ -139,15 +139,15 @@ export class ReactNativeStorage implements CommonAppStorage { } getSettings() { - return this.retrieveAsync("settings", { "map.lianeTrafficAsWidth": false, "map.lianeTrafficAsColor": false, geolocation: null }); + return this.retrieveAsync("settings", { + "map.lianeTrafficAsWidth": false, + "map.lianeTrafficAsColor": false, + geolocation: undefined + }); } - async getSetting(name: T): Promise { - const setting = (await this.getSettings())?.[name]; - if (setting === undefined) { - throw new Error("Setting not found: " + name); - } - return setting; + async getSetting(name: T): Promise { + return (await this.getSettings())?.[name]; } async saveSetting(name: T, value: AppSettings[T]) { diff --git a/app/src/components/WheelPicker.tsx b/app/src/components/WheelPicker.tsx index 063fe2d3b..c01e83826 100644 --- a/app/src/components/WheelPicker.tsx +++ b/app/src/components/WheelPicker.tsx @@ -112,7 +112,6 @@ export const WheelPicker: React.FC = ({ let index = Math.floor(Math.floor(offsetY) / itemHeight); if (index <= 0 && offsetY <= 0) { - // console.log("shouldT", options.length, oldVal.current, index); oldVal.current = options.length; flatListRef.current?.scrollToOffset({ animated: false, @@ -149,9 +148,7 @@ export const WheelPicker: React.FC = ({ * This ensures that what the user sees as selected in the picker always corresponds to the value state. */ useEffect(() => { - // console.log(selectedIndex, oldVal.current, "->", options.length); if (selectedIndex !== oldVal.current) { - // console.log("o"); flatListRef.current?.scrollToIndex({ index: selectedIndex, animated: true diff --git a/app/src/components/map/AppMapView.tsx b/app/src/components/map/AppMapView.tsx index 487e1c0ba..9035051cd 100644 --- a/app/src/components/map/AppMapView.tsx +++ b/app/src/components/map/AppMapView.tsx @@ -114,7 +114,6 @@ const AppMapView = forwardRef( const b = await mapRef.current?.getVisibleBounds()!; const ne = await mapRef.current?.getPointInView(b[0])!; const sw = await mapRef.current?.getPointInView(b[1])!; - //console.log(ne, sw); return mapRef.current?.queryRenderedFeaturesInRect([sw[1] * scale, ne[0] * scale, 0, 0], filter, layersId); } }, diff --git a/app/src/components/map/layers/LianeMatchRouteLayer.tsx b/app/src/components/map/layers/LianeMatchRouteLayer.tsx index 49ac52c91..d3db5f15d 100644 --- a/app/src/components/map/layers/LianeMatchRouteLayer.tsx +++ b/app/src/components/map/layers/LianeMatchRouteLayer.tsx @@ -33,7 +33,6 @@ export const LianeMatchRouteLayer = (props: { match: LianeMatch; to?: RallyingPo return trip.wayPoints; //.slice(trip.departureIndex, trip.arrivalIndex + 1); }, [fromPoint, match, toPoint]); - //console.log(to, from, wayPoints); const { data, isLoading } = useQuery(["match", from?.id, to?.id!, match.trip.id!], () => { const wp = [...(isSamePickup ? [] : [from!.location]), ...wayPoints.map(w => w.rallyingPoint.location), ...(isSameDeposit ? [] : [to!.location])]; diff --git a/app/src/components/trip/TripSurveyView.tsx b/app/src/components/trip/TripSurveyView.tsx index cab4f88e6..6348f5d15 100644 --- a/app/src/components/trip/TripSurveyView.tsx +++ b/app/src/components/trip/TripSurveyView.tsx @@ -2,16 +2,17 @@ import { ActivityIndicator, View } from "react-native"; import { AppText } from "@/components/base/AppText.tsx"; import { AppColorPalettes, AppColors, ContextualColors } from "@/theme/colors.ts"; import { AppLocalization } from "@/api/i18n.ts"; -import { capitalize, CoLiane, Liane, MessageContentTrip, TypedLianeMessage } from "@liane/common"; -import React, { useContext, useMemo } from "react"; +import { capitalize, CoLiane, Liane, LianeMessage, TripMessage } from "@liane/common"; +import React, { useCallback, useContext, useMemo } from "react"; import { Column, Row } from "@/components/base/AppLayout.tsx"; import { UserPicture } from "@/components/UserPicture.tsx"; import { AppIcon } from "@/components/base/AppIcon.tsx"; import { AppPressableOverlay } from "@/components/base/AppPressable.tsx"; import { WayPointView } from "@/components/trip/WayPointsView.tsx"; -import { useQuery } from "react-query"; -import { LianeDetailQueryKey } from "@/screens/user/MyTripsScreen.tsx"; +import { useQuery, useQueryClient } from "react-query"; +import { JoinRequestsQueryKey, LianeDetailQueryKey } from "@/screens/user/MyTripsScreen.tsx"; import { AppContext } from "@/components/context/ContextProvider.tsx"; +import { AppStorage } from "@/api/storage.ts"; const LoadedTripSurveyView = ({ coLiane, trip }: { coLiane: CoLiane; trip: Liane }) => { const members = useMemo(() => { @@ -44,7 +45,8 @@ const LoadedTripSurveyView = ({ coLiane, trip }: { coLiane: CoLiane; trip: Liane ); }; -export const TripSurveyView = ({ survey, coLiane }: { survey: TypedLianeMessage; coLiane: CoLiane }) => { + +export const TripSurveyView = ({ survey, coLiane }: { survey: LianeMessage; coLiane: CoLiane }) => { const date = useMemo(() => { return capitalize(AppLocalization.formatMonthDay(new Date(survey.createdAt!))); }, [survey.createdAt]); @@ -63,24 +65,52 @@ export const TripSurveyView = ({ survey, coLiane }: { survey: TypedLianeMessage< } }); + const joinRequest = useQuery({ + queryKey: JoinRequestsQueryKey, + queryFn: async () => { + const joinRequests = (await services.liane.listJoinRequests()).data; + return joinRequests.find(j => j.targetTrip.id === survey.content.value); + } + }); + + const queryClient = useQueryClient(); + + const handleJoinTrip = useCallback(async () => { + if (!trip.data) { + return; + } + if (trip.data.isMember) { + return; + } + + const geolocationLevel = await AppStorage.getSetting("geolocation"); + const query = { liane: coLiane.id!, trip: trip.data.liane.id!, geolocationLevel }; + console.log("Joining trip", query); + await services.community.joinTrip(query); + await queryClient.invalidateQueries(JoinRequestsQueryKey); + }, [queryClient, coLiane.id, services.community, trip.data]); + return ( - {trip.isLoading && } + {(trip.isLoading || joinRequest.isLoading) && } {trip.isError && Erreur de chargement} {!!trip.data && ( <> - + {trip.data?.createdBy?.user.pseudo} propose le trajet pour{" "} {date} {trip.data.isMember && En attente de membres} - {!trip.data.isMember && ( + {!trip.data.isMember && joinRequest.data && ( + Demande en attente + )} + {!trip.data.isMember && !joinRequest.data && ( {}}> + onPress={handleJoinTrip}> Participer diff --git a/app/src/screens/communities/CommunitiesChatScreen.tsx b/app/src/screens/communities/CommunitiesChatScreen.tsx index dcd8a27ea..ac753789c 100644 --- a/app/src/screens/communities/CommunitiesChatScreen.tsx +++ b/app/src/screens/communities/CommunitiesChatScreen.tsx @@ -9,12 +9,10 @@ import { LianeMessage, MatchGroup, MatchSingle, - MessageContentTrip, PaginatedResponse, Ref, ResolvedLianeRequest, - TypedLianeMessage, - UnionUtils, + TripMessage, User } from "@liane/common"; import React, { useContext, useEffect, useMemo, useState } from "react"; @@ -105,9 +103,13 @@ export const CommunitiesChatScreen = () => { const [request, setRequest] = useState(undefined); const [tripModalVisible, setTripModalVisible] = useState(false); - const members: { [k: string]: User } | undefined = useMemo( - () => chat?.currentGroup?.members?.reduce((a: { [k: string]: User }, b) => ((a[b.user.id!] = b.user), a), {}), - [chat?.currentGroup?.members, liane] + const members = useMemo( + () => + chat?.currentGroup?.members?.reduce((acc, b) => { + acc[b.user.id!] = b.user; + return acc; + }, {} as { [k: string]: User }), + [chat?.currentGroup?.members] ); const sendMessage = async (value: string) => { @@ -140,7 +142,7 @@ export const CommunitiesChatScreen = () => { if (lianeTemp && lianeTemp.id) { try { - const updatedLianeRequest = await services.community.sendMessage(lianeTemp.id, { + await services.community.sendMessage(lianeTemp.id, { type: "Text", value: value }); @@ -155,7 +157,7 @@ export const CommunitiesChatScreen = () => { } else { if (lianeTemp && lianeTemp.id && value && value.length > 0) { try { - const updatedLianeRequest = await chat?.send({ + await chat?.send({ type: "Text", value: value }); @@ -195,12 +197,12 @@ export const CommunitiesChatScreen = () => { } }; - if (liane) { - const me = liane.members.find(m => m.user.id === user!.id)!; - const todayIndex = (new Date().getDay() + 6) % 7; - const x = me.lianeRequest.weekDays.substring(todayIndex).concat(me.lianeRequest.weekDays.substring(0, todayIndex)).indexOf("1"); - console.log(todayIndex, x, me.lianeRequest.weekDays); - } + // if (liane) { + // const me = liane.members.find(m => m.user.id === user!.id)!; + // const todayIndex = (new Date().getDay() + 6) % 7; + // const x = me.lianeRequest.weekDays.substring(todayIndex).concat(me.lianeRequest.weekDays.substring(0, todayIndex)).indexOf("1"); + // console.log(todayIndex, x, me.lianeRequest.weekDays); + // } const me = useMemo(() => liane?.members.find(m => m.user.id === user!.id), [liane?.members, user]); const nextDayIndex = useMemo(() => { @@ -227,7 +229,7 @@ export const CommunitiesChatScreen = () => { const addDays = (nextDayIndex - todayIndex + 7) % 7; const departureTime = addSeconds(time[0], addDays * 3600 * 24).toISOString(); const returnTime = time[1] ? addSeconds(time[1], addDays * 3600 * 24).toISOString() : undefined; - console.log(time[0], nextDayIndex, todayIndex, addDays, departureTime); + //console.log(time[0], nextDayIndex, todayIndex, addDays, departureTime); const created = await services.liane.post({ departureTime, @@ -267,7 +269,7 @@ export const CommunitiesChatScreen = () => { } }; - console.log("PARAMS", route.params); + // console.log("PARAMS", route.params); if (route.params.liane) { // Lorsqu'on arrive directement par une liane setLiane(route.params.liane); @@ -285,7 +287,7 @@ export const CommunitiesChatScreen = () => { //TODO recup Liane fetchLiane(route.params.lianeId).then(); } - }, [route.params]); + }, [route.params, services.community]); useEffect(() => { if (liane && liane.id) { @@ -310,6 +312,7 @@ export const CommunitiesChatScreen = () => { }); } }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [liane, services.realTimeHub]); const sendButton = ( @@ -325,7 +328,7 @@ export const CommunitiesChatScreen = () => { ); - console.debug(JSON.stringify(messages)); + // console.debug(JSON.stringify(messages)); return ( {chat && ( @@ -335,9 +338,9 @@ export const CommunitiesChatScreen = () => { keyExtractor={m => m.id!} renderItem={({ item, index }) => members ? ( - UnionUtils.isInstanceOf(item.content, "Trip") && !!liane ? ( + item.content.type === "Trip" && !!liane ? ( - } coLiane={liane!} /> + } coLiane={liane!} /> ) : ( !!members[item.createdBy!] && ( @@ -504,7 +507,6 @@ const LaunchTripModal = ({ const launch = () => { launchTrip(selectedTime); }; - console.log(weekdays); return ( diff --git a/app/src/screens/home/HomeBottomSheet.tsx b/app/src/screens/home/HomeBottomSheet.tsx index 2bf020df2..239551a7d 100644 --- a/app/src/screens/home/HomeBottomSheet.tsx +++ b/app/src/screens/home/HomeBottomSheet.tsx @@ -46,7 +46,6 @@ export const HomeBottomSheetContainer = ( machine.off(transitionListener); }; }, []); - //console.log(Platform.OS, h, insets, StatusBar.currentHeight, bottomSpace); if (props.display === "none") { return ; diff --git a/app/src/screens/home/HomeScreen.tsx b/app/src/screens/home/HomeScreen.tsx index bd2de86ba..684b92d6e 100644 --- a/app/src/screens/home/HomeScreen.tsx +++ b/app/src/screens/home/HomeScreen.tsx @@ -99,7 +99,6 @@ const HomeScreenView = ({ displaySource }: { displaySource: Observable<[FeatureC return true; }} onSelectFeature={placeFeature => { - console.log("place selected", JSON.stringify(placeFeature)); if (placeFeature.bbox) { appMapRef.current?.fitBounds( getBoundingBox( diff --git a/app/src/screens/home/LianeMatchDetailView.tsx b/app/src/screens/home/LianeMatchDetailView.tsx index 870bb659d..796a4efb0 100644 --- a/app/src/screens/home/LianeMatchDetailView.tsx +++ b/app/src/screens/home/LianeMatchDetailView.tsx @@ -169,7 +169,6 @@ export const LianeMatchDetailView = () => { setStep(firstEdit ? step + 1 : 3); }, [firstEdit, step]); useEffect(() => { - //console.log(step, isSeatsStep, isReturnStep); if (step === 1 && !isSeatsStep) { nextStep(); } else if (step === 2 && !isReturnStep) { diff --git a/app/src/screens/home/TripGeolocationWizard.tsx b/app/src/screens/home/TripGeolocationWizard.tsx index dfc3a81f2..a991e568f 100644 --- a/app/src/screens/home/TripGeolocationWizard.tsx +++ b/app/src/screens/home/TripGeolocationWizard.tsx @@ -29,7 +29,6 @@ export const TripGeolocationWizard = WithFullscreenModal( const allowed = permission !== GeolocationPermission.Denied; AppStorage.getSetting("geolocation") .then(setting => { - //console.log("setting", setting); if (setting) { const settingAllowed = setting !== "None"; setPage(!allowed && settingAllowed ? 1 : 2); @@ -79,7 +78,7 @@ export const TripGeolocationWizard = WithFullscreenModal( { - AppStorage.saveSetting("geolocation", null).then(prev); + AppStorage.saveSetting("geolocation", undefined).then(prev); }} /> )} @@ -200,7 +199,7 @@ const Page1 = (props: { next: () => void; showAs: "driver" | "passenger" }) => ( const Page3 = (props: { next: () => void; prev: () => void }) => { const { route } = useAppNavigation<"TripGeolocationWizard">(); const [loading, setLoading] = useState(false); - const [trackedLevel, setTrackedLevel] = useState(null); + const [trackedLevel, setTrackedLevel] = useState(); useEffect(() => { AppStorage.getSetting("geolocation").then(setTrackedLevel); }, []); diff --git a/app/src/screens/publish/PublishScreen.tsx b/app/src/screens/publish/PublishScreen.tsx index 462d9aa56..66e42a58b 100644 --- a/app/src/screens/publish/PublishScreen.tsx +++ b/app/src/screens/publish/PublishScreen.tsx @@ -122,9 +122,6 @@ export const PublishScreenView = () => { const isOverviewStep = state.matches("overview"); const isSubmittingStep = state.matches("submitting"); - //console.log("[PublishScreen] State Value:", state.value); - //console.log("[PublishScreen] State Request:", state.context.request); - const step = useSharedValue(0); const { width } = useWindowDimensions(); const stepperIndicatorStyle = useAnimatedStyle(() => { diff --git a/app/src/screens/user/RallyingPointRequestsScreen.tsx b/app/src/screens/user/RallyingPointRequestsScreen.tsx index f930e2dbd..1198c6d33 100644 --- a/app/src/screens/user/RallyingPointRequestsScreen.tsx +++ b/app/src/screens/user/RallyingPointRequestsScreen.tsx @@ -68,7 +68,6 @@ export function NewRallyingPointRequestScreen() { const [showConfirmation, setShowConfirmation] = useState(false); const onSubmit: SubmitHandler = async data => { - console.log("xc"); AppLogger.debug("RALLYING_POINT", "Submitting..."); setLoading(true); try { diff --git a/app/src/screens/user/SettingsScreen.tsx b/app/src/screens/user/SettingsScreen.tsx index 3b4525600..f8b26c374 100644 --- a/app/src/screens/user/SettingsScreen.tsx +++ b/app/src/screens/user/SettingsScreen.tsx @@ -15,14 +15,14 @@ const geolocationValues = { Hidden: "Activée (position masquée)" } as const; export const SettingsScreen = () => { - const [geoloc, setGeoloc] = useState(null); + const [geoloc, setGeoloc] = useState(); const { navigation } = useAppNavigation(); const focused = useIsFocused(); useEffect(() => { if (!focused) { return; } - AppStorage.getSetting("geolocation").then(s => setGeoloc(s)); + AppStorage.getSetting("geolocation").then(setGeoloc); }, [focused]); return ( @@ -35,7 +35,7 @@ export const SettingsScreen = () => { { - AppStorage.saveSetting("geolocation", null).then(() => + AppStorage.saveSetting("geolocation", undefined).then(() => navigation.navigate("TripGeolocationWizard", { showAs: null, lianeId: undefined }) ); }}> diff --git a/back/src/Liane/Liane.Service/Internal/Community/LianeMatcher.cs b/back/src/Liane/Liane.Service/Internal/Community/LianeMatcher.cs index b22f1902d..e69d56ab6 100644 --- a/back/src/Liane/Liane.Service/Internal/Community/LianeMatcher.cs +++ b/back/src/Liane/Liane.Service/Internal/Community/LianeMatcher.cs @@ -16,10 +16,23 @@ namespace Liane.Service.Internal.Community; public sealed class LianeMatcher( LianeRequestFetcher lianeRequestFetcher, - LianeFetcher fetcher, + LianeFetcher lianeFetcher, IRallyingPointService rallyingPointService ) { + public async Task FindMatchesBetween(IDbConnection connection, + Guid a, Guid b, IDbTransaction? tx = null) + { + var lianeRawMatches = await FindRawMatches(connection, new[] { a }, tx); + var lianeRawMatch = lianeRawMatches.FirstOrDefault(m => m.LianeRequest == b); + if (lianeRawMatch is null) + { + return null; + } + + return await ToSingleMatch(async id => await lianeRequestFetcher.FetchLianeRequest(connection, id, tx), lianeRawMatch); + } + public async Task> FindMatches( IDbConnection connection, IEnumerable lianeRequestsId, @@ -30,7 +43,7 @@ public async Task> FindMatches( var allLianes = rawMatches.FilterSelect(r => r.Lianes) .SelectMany(r => r) .Distinct(); - var lianes = (await fetcher.FetchLianes(connection, allLianes)) + var lianes = (await lianeFetcher.FetchLianes(connection, allLianes)) .ToImmutableDictionary(l => Guid.Parse(l.Id)); var fetchLianeRequests = (await lianeRequestFetcher.FetchLianeRequests(connection, rawMatches.Select(m => m.LianeRequest))) .ToImmutableDictionary(r => r.Id!.Value); @@ -122,7 +135,6 @@ private async Task> GroupMatchByLiane(IEnumerable m.Score) .ThenByDescending(m => m switch { @@ -138,9 +150,12 @@ private async Task> GroupMatchByLiane(IEnumerable ToSingleMatch(ImmutableDictionary fetchLianeRequests, LianeRawMatch match) + private Task ToSingleMatch(ImmutableDictionary fetcher, LianeRawMatch match) + => ToSingleMatch(i => Task.FromResult(fetcher.GetValueOrDefault(i)), match); + + private async Task ToSingleMatch(Func> fetcher, LianeRawMatch match) { - var lianeRequest = fetchLianeRequests.GetValueOrDefault(match.LianeRequest); + var lianeRequest = await fetcher(match.LianeRequest); if (lianeRequest is null) { return null; diff --git a/back/src/Liane/Liane.Service/Internal/Community/LianeServiceImpl.cs b/back/src/Liane/Liane.Service/Internal/Community/LianeServiceImpl.cs index a49c7732f..ff11eddd6 100644 --- a/back/src/Liane/Liane.Service/Internal/Community/LianeServiceImpl.cs +++ b/back/src/Liane/Liane.Service/Internal/Community/LianeServiceImpl.cs @@ -216,12 +216,10 @@ public async Task JoinTrip(JoinTripQuery query) var userId = currentContext.CurrentUser().Id; var lianeId = Guid.Parse(query.Liane); var member = await CheckIsMember(connection, lianeId, userId, tx); - var lianeRequest = await lianeRequestFetcher.FetchLianeRequest(connection, member.LianeRequestId, tx); + var trip = await tripService.Get(query.Trip); + var driver = await CheckIsMember(connection, lianeId, trip.Driver.User, tx); - var from = await lianeRequest.WayPoints[0].Resolve(rallyingPointService.Get); - var to = await lianeRequest.WayPoints[^1].Resolve(rallyingPointService.Get); - - var match = await tripService.GetNewTrip(query.Trip, from, to, false); + var match = await matcher.FindMatchesBetween(connection, member.LianeRequestId, driver.LianeRequestId, tx); if (match is null) { return; diff --git a/common/src/event.ts b/common/src/event.ts index 30b95844b..b614e5ad2 100644 --- a/common/src/event.ts +++ b/common/src/event.ts @@ -4,57 +4,47 @@ import { IUnion } from "./union"; export type LianeEvent = JoinRequest | MemberAccepted | MemberRejected | MemberHasLeft | MemberPing; -export type JoinRequest = Readonly< - { - liane: Ref; - from: Ref; - to: Ref; - seats: number; - takeReturnTrip: boolean; - message: string; - geolocationLevel: GeolocationLevel | null; - } & IUnion<"JoinRequest"> ->; +export type JoinRequest = { + liane: Ref; + from: Ref; + to: Ref; + seats: number; + takeReturnTrip: boolean; + message: string; + geolocationLevel?: GeolocationLevel; +} & IUnion<"JoinRequest">; -export type MemberAccepted = Readonly< - { - liane: Ref; - member: Ref; - from: Ref; - to: Ref; - seats: number; - takeReturnTrip: boolean; - } & IUnion<"MemberAccepted"> ->; +export type MemberAccepted = { + liane: Ref; + member: Ref; + from: Ref; + to: Ref; + seats: number; + takeReturnTrip: boolean; +} & IUnion<"MemberAccepted">; -export type MemberRejected = Readonly< - { - liane: Ref; - member: Ref; - from: Ref; - to: Ref; - seats: number; - takeReturnTrip: boolean; - reason: string | undefined; - } & IUnion<"MemberRejected"> ->; +export type MemberRejected = { + liane: Ref; + member: Ref; + from: Ref; + to: Ref; + seats: number; + takeReturnTrip: boolean; + reason: string | undefined; +} & IUnion<"MemberRejected">; -export type MemberHasLeft = Readonly< - { - liane: Ref; - } & IUnion<"MemberHasLeft"> ->; +export type MemberHasLeft = { + liane: Ref; +} & IUnion<"MemberHasLeft">; -export type MemberPing = Readonly< - { - liane: Ref; - timestamp: number; - } & ( - | { delay: TimeInSeconds; coordinate?: LatLng } - | { - coordinate: LatLng; - delay?: TimeInSeconds; - } - ) & - IUnion<"MemberPing"> ->; +export type MemberPing = { + liane: Ref; + timestamp: number; +} & ( + | { delay: TimeInSeconds; coordinate?: LatLng } + | { + coordinate: LatLng; + delay?: TimeInSeconds; + } +) & + IUnion<"MemberPing">; diff --git a/common/src/services/chat.ts b/common/src/services/chat.ts index fd45df27d..52a889da8 100644 --- a/common/src/services/chat.ts +++ b/common/src/services/chat.ts @@ -72,7 +72,6 @@ export class Chat { this.logger.info("CHAT", "received : msg", convId, message, this.currentGroup?.id); if (this.currentGroup?.id === convId && this.onReceiveMessageCallback) { - console.log("onReceiveMessageCallback", message); this.onReceiveMessageCallback(message); return true; } diff --git a/common/src/services/community.ts b/common/src/services/community.ts index 2597cbbc7..1c830fbcd 100644 --- a/common/src/services/community.ts +++ b/common/src/services/community.ts @@ -1,4 +1,15 @@ -import { DayOfWeekFlag, Entity, Liane, PaginatedRequestParams, PaginatedResponse, RallyingPoint, Ref, User, UTCDateTime } from "../api"; +import { + DayOfWeekFlag, + Entity, + GeolocationLevel, + Liane, + PaginatedRequestParams, + PaginatedResponse, + RallyingPoint, + Ref, + User, + UTCDateTime +} from "../api"; import { HttpClient } from "./http"; import { TimeRange } from "./time"; import { IUnion } from "../union"; @@ -65,14 +76,15 @@ export type CoLianeMember = { lastReadAt?: UTCDateTime; }; +export type JoinTripQuery = { liane: Ref; trip: Ref; geolocationLevel?: GeolocationLevel }; + export type CoMatch = MatchSingle | MatchGroup; -export type MessageContentText = { value: string } & IUnion<"Text">; -export type MessageContentTrip = { value: Ref } & IUnion<"Trip">; -export type MessageContent = MessageContentText | MessageContentTrip; +export type TextMessage = { value: string } & IUnion<"Text">; +export type TripMessage = { value: Ref } & IUnion<"Trip">; +export type MessageContent = TextMessage | TripMessage; -export type LianeMessage = Entity & { content: MessageContent }; -export type TypedLianeMessage = LianeMessage & { content: T }; +export type LianeMessage = Entity & { content: T }; export interface CommunityService { list(): Promise; @@ -89,6 +101,8 @@ export interface CommunityService { join(lianeRequestId: string, liane: string): Promise; + joinTrip(query: JoinTripQuery): Promise; + updateLiane(lianeRequestId: string, request: CoLianeUpdate): Promise; leave(liane: string): Promise; @@ -127,6 +141,10 @@ export class CommunityServiceClient implements CommunityService { return this.http.postAs(`/community/liane/${id}/join/${liane}`); } + async joinTrip(query: JoinTripQuery) { + await this.http.post("/community/liane/join_trip", { body: query }); + } + updateLiane(lianeId: string, request: CoLianeUpdate) { return this.http.postAs(`/community/liane/${lianeId}`, { body: request }); } diff --git a/common/tests/e2e/actors/login.ts b/common/tests/e2e/actors/login.ts index eee8590fd..00557a340 100644 --- a/common/tests/e2e/actors/login.ts +++ b/common/tests/e2e/actors/login.ts @@ -47,7 +47,6 @@ export class LoginActor { service.onTransition(state => { states.push(state.value); const stateStrings = state.toStrings(); - console.log(stateStrings); if (state.matches("done")) { onDone(state.context); } else if (stateStrings[stateStrings.length - 1].endsWith("failure")) {