add is_pinned functionality
This commit is contained in:
@ -20,18 +20,24 @@ pub struct Day {
|
||||
day: NaiveDate,
|
||||
planned_events: Vec<PlannedEventWithUserAndTriptype>,
|
||||
trips: Vec<TripWithUserAndType>,
|
||||
is_pinned: bool,
|
||||
}
|
||||
|
||||
impl Day {
|
||||
pub async fn new(db: &SqlitePool, day: NaiveDate) -> Self {
|
||||
pub async fn new(db: &SqlitePool, day: NaiveDate, is_pinned: bool) -> Self {
|
||||
let planned_events = match is_pinned {
|
||||
true => PlannedEvent::get_pinned_for_day(db, day).await,
|
||||
false => PlannedEvent::get_for_day(db, day).await,
|
||||
};
|
||||
Self {
|
||||
day,
|
||||
planned_events: PlannedEvent::get_for_day(db, day).await,
|
||||
planned_events,
|
||||
trips: Trip::get_for_day(db, day).await,
|
||||
is_pinned,
|
||||
}
|
||||
}
|
||||
pub async fn new_guest(db: &SqlitePool, day: NaiveDate) -> Self {
|
||||
let mut day = Self::new(db, day).await;
|
||||
pub async fn new_guest(db: &SqlitePool, day: NaiveDate, is_pinned: bool) -> Self {
|
||||
let mut day = Self::new(db, day, is_pinned).await;
|
||||
|
||||
day.planned_events.retain(|e| e.planned_event.allow_guests);
|
||||
day.trips.retain(|t| t.trip.allow_guests);
|
||||
|
Reference in New Issue
Block a user