From e21e431817f81d5bcc70e08c35be7f463321698e Mon Sep 17 00:00:00 2001 From: Yoorim Choi Date: Wed, 15 Jan 2025 20:03:22 +0900 Subject: [PATCH] Fix timeplace glitch while searching (#325) Fix glitch while searching --- SNUTT-2022/SNUTT/Models/Lecture.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/SNUTT-2022/SNUTT/Models/Lecture.swift b/SNUTT-2022/SNUTT/Models/Lecture.swift index 898b8eaf..bca1cec8 100644 --- a/SNUTT-2022/SNUTT/Models/Lecture.swift +++ b/SNUTT-2022/SNUTT/Models/Lecture.swift @@ -95,9 +95,15 @@ struct Lecture: Identifiable { if timePlaces.isEmpty { return "" } - let places = timePlaces - .compactMap { $0.place.isEmpty ? nil : $0.place } - .reduce(into: Set()) { $0.insert($1) } + var places: [String] = [] + timePlaces + .sorted { $0.day.rawValue < $1.day.rawValue && $0.startMinute < $1.startMinute } + .compactMap { $0.place == " " ? nil : $0.place } + .forEach { place in + if !places.contains(where: { $0 == place }) { + places.append(place) + } + } if places.isEmpty { return "" }