From a3f747645c787e4572bf0e8f94ad60e9f9fee04f Mon Sep 17 00:00:00 2001 From: Carlos Rodrigo Garcia Date: Mon, 3 Jun 2019 14:55:30 -0300 Subject: [PATCH] Order sessions by date --- .../ViewModel/ListSessions/ListSessionsViewModel.swift | 4 +++- .../StickySessions/ViewModel/SessionViewModel.swift | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/StickySessions/StickySessions/ViewModel/ListSessions/ListSessionsViewModel.swift b/StickySessions/StickySessions/ViewModel/ListSessions/ListSessionsViewModel.swift index bf52a83..92d0fc9 100644 --- a/StickySessions/StickySessions/ViewModel/ListSessions/ListSessionsViewModel.swift +++ b/StickySessions/StickySessions/ViewModel/ListSessions/ListSessionsViewModel.swift @@ -31,7 +31,9 @@ class ListSessionsViewModel: OnResponse { return } - sessionsViewModel = sessions.compactMap {SessionViewModel(session: $0)} + let orderedSessions = sessions.sorted(by: { $0.timestamp._seconds > $1.timestamp._seconds }) + + sessionsViewModel = orderedSessions.compactMap {SessionViewModel(session: $0)} self.updateSessions(sessionsViewModel) } diff --git a/StickySessions/StickySessions/ViewModel/SessionViewModel.swift b/StickySessions/StickySessions/ViewModel/SessionViewModel.swift index d548603..fbb82a6 100644 --- a/StickySessions/StickySessions/ViewModel/SessionViewModel.swift +++ b/StickySessions/StickySessions/ViewModel/SessionViewModel.swift @@ -25,7 +25,7 @@ struct SessionViewModel { mutating func defineSessionName(count:Int) { switch count { case 4: - self.sessionName = "Gain & Pain" + self.sessionName = "Gain & Pleasure" break case 5: self.sessionName = "Starfish"