From 1cca278baac0f50012e524eac7c441c998f4d8c3 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 15 Jul 2023 19:20:37 +0200 Subject: add timeline / current checkins --- lib/Travelynx.pm | 1 + lib/Travelynx/Controller/Profile.pm | 24 ++++++++++++++++++++++++ lib/Travelynx/Controller/Traveling.pm | 14 +++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 5b8680e..c529cb7 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -2201,6 +2201,7 @@ sub startup { $authed_r->post('/delete')->to('account#delete'); $authed_r->post('/logout')->to('account#do_logout'); $authed_r->post('/set_token')->to('api#set_token'); + $authed_r->get('/timeline/in-transit')->to('profile#checked_in'); } diff --git a/lib/Travelynx/Controller/Profile.pm b/lib/Travelynx/Controller/Profile.pm index b8812f8..03f3b0d 100755 --- a/lib/Travelynx/Controller/Profile.pm +++ b/lib/Travelynx/Controller/Profile.pm @@ -546,4 +546,28 @@ sub status_card { ); } +sub checked_in { + my ($self) = @_; + + my $uid = $self->current_user->{id}; + my @journeys = $self->in_transit->get_timeline( + uid => $uid, + with_data => 1 + ); + + if ( $self->param('ajax') ) { + delete $self->stash->{layout}; + $self->render( + '_timeline-checked-in', + journeys => [@journeys], + ); + } + else { + $self->render( + 'timeline-checked-in', + journeys => [@journeys], + ); + } +} + 1; diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index f283762..fe9b4f5 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -382,7 +382,13 @@ sub compute_effective_visibility { sub homepage { my ($self) = @_; if ( $self->is_user_authenticated ) { - my $status = $self->get_user_status; + my $uid = $self->current_user->{id}; + my $status = $self->get_user_status; + my @timeline = $self->in_transit->get_timeline( + uid => $uid, + short => 1 + ); + $self->stash( timeline => [@timeline] ); my @recent_targets; if ( $status->{checked_in} ) { my $journey_visibility @@ -457,6 +463,12 @@ sub status_card { delete $self->stash->{layout}; + my @timeline = $self->in_transit->get_timeline( + uid => $self->current_user->{id}, + short => 1 + ); + $self->stash( timeline => [@timeline] ); + if ( $status->{checked_in} ) { my $journey_visibility = $self->compute_effective_visibility( -- cgit v1.2.3