From 0aa828b073102b971e67088a2b7f8c395c410467 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 20 Aug 2023 23:19:14 +0100 Subject: [PATCH 1/5] Fix calendar parsing --- uni/lib/view/calendar/calendar.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/uni/lib/view/calendar/calendar.dart b/uni/lib/view/calendar/calendar.dart index 48b0ef1fa..f1c69d671 100644 --- a/uni/lib/view/calendar/calendar.dart +++ b/uni/lib/view/calendar/calendar.dart @@ -46,6 +46,14 @@ class CalendarPageViewState extends GeneralPageViewState { } Widget getTimeline(BuildContext context, List calendar) { + // Filter out events where name or date is a non-breaking space + final filteredCalendar = calendar + .where( + (event) => + event.name.trim() != ' ' && event.date.trim() != ' ', + ) + .toList(); + return FixedTimeline.tileBuilder( theme: TimelineTheme.of(context).copyWith( connectorTheme: TimelineTheme.of(context) @@ -60,7 +68,7 @@ class CalendarPageViewState extends GeneralPageViewState { contentsBuilder: (context, index) => Padding( padding: const EdgeInsets.all(24), child: Text( - calendar[index].name, + filteredCalendar[index].name, style: Theme.of(context) .textTheme .titleLarge @@ -70,13 +78,13 @@ class CalendarPageViewState extends GeneralPageViewState { oppositeContentsBuilder: (context, index) => Padding( padding: const EdgeInsets.all(24), child: Text( - calendar[index].date, + filteredCalendar[index].date, style: Theme.of(context).textTheme.titleMedium?.copyWith( fontStyle: FontStyle.italic, ), ), ), - itemCount: calendar.length, + itemCount: filteredCalendar.length, ), ); } From 437f379ef804280a95680e55a2f02311385da376 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Thu, 24 Aug 2023 22:52:55 +0100 Subject: [PATCH 2/5] Filter at parse lever --- uni/lib/controller/parsers/parser_calendar.dart | 11 ++++++++++- uni/lib/view/calendar/calendar.dart | 14 +++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/uni/lib/controller/parsers/parser_calendar.dart b/uni/lib/controller/parsers/parser_calendar.dart index 77af03e39..e98d5467d 100644 --- a/uni/lib/controller/parsers/parser_calendar.dart +++ b/uni/lib/controller/parsers/parser_calendar.dart @@ -7,7 +7,7 @@ Future> getCalendarFromHtml(Response response) async { final calendarHtml = document.querySelectorAll('tr'); - return calendarHtml + final eventList = calendarHtml .map( (event) => CalendarEvent( event.children[0].innerHtml, @@ -15,4 +15,13 @@ Future> getCalendarFromHtml(Response response) async { ), ) .toList(); + + final filteredCalendar = eventList + .where( + (event) => + event.name.trim() != ' ' && event.date.trim() != ' ', + ) + .toList(); + + return filteredCalendar; } diff --git a/uni/lib/view/calendar/calendar.dart b/uni/lib/view/calendar/calendar.dart index f1c69d671..48b0ef1fa 100644 --- a/uni/lib/view/calendar/calendar.dart +++ b/uni/lib/view/calendar/calendar.dart @@ -46,14 +46,6 @@ class CalendarPageViewState extends GeneralPageViewState { } Widget getTimeline(BuildContext context, List calendar) { - // Filter out events where name or date is a non-breaking space - final filteredCalendar = calendar - .where( - (event) => - event.name.trim() != ' ' && event.date.trim() != ' ', - ) - .toList(); - return FixedTimeline.tileBuilder( theme: TimelineTheme.of(context).copyWith( connectorTheme: TimelineTheme.of(context) @@ -68,7 +60,7 @@ class CalendarPageViewState extends GeneralPageViewState { contentsBuilder: (context, index) => Padding( padding: const EdgeInsets.all(24), child: Text( - filteredCalendar[index].name, + calendar[index].name, style: Theme.of(context) .textTheme .titleLarge @@ -78,13 +70,13 @@ class CalendarPageViewState extends GeneralPageViewState { oppositeContentsBuilder: (context, index) => Padding( padding: const EdgeInsets.all(24), child: Text( - filteredCalendar[index].date, + calendar[index].date, style: Theme.of(context).textTheme.titleMedium?.copyWith( fontStyle: FontStyle.italic, ), ), ), - itemCount: filteredCalendar.length, + itemCount: calendar.length, ), ); } From bfb18c6002d8f1a5f3adee2178ad2a82a8a5fd27 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 20 Aug 2023 23:19:14 +0100 Subject: [PATCH 3/5] Fix calendar parsing --- uni/lib/view/calendar/calendar.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/uni/lib/view/calendar/calendar.dart b/uni/lib/view/calendar/calendar.dart index 48b0ef1fa..f1c69d671 100644 --- a/uni/lib/view/calendar/calendar.dart +++ b/uni/lib/view/calendar/calendar.dart @@ -46,6 +46,14 @@ class CalendarPageViewState extends GeneralPageViewState { } Widget getTimeline(BuildContext context, List calendar) { + // Filter out events where name or date is a non-breaking space + final filteredCalendar = calendar + .where( + (event) => + event.name.trim() != ' ' && event.date.trim() != ' ', + ) + .toList(); + return FixedTimeline.tileBuilder( theme: TimelineTheme.of(context).copyWith( connectorTheme: TimelineTheme.of(context) @@ -60,7 +68,7 @@ class CalendarPageViewState extends GeneralPageViewState { contentsBuilder: (context, index) => Padding( padding: const EdgeInsets.all(24), child: Text( - calendar[index].name, + filteredCalendar[index].name, style: Theme.of(context) .textTheme .titleLarge @@ -70,13 +78,13 @@ class CalendarPageViewState extends GeneralPageViewState { oppositeContentsBuilder: (context, index) => Padding( padding: const EdgeInsets.all(24), child: Text( - calendar[index].date, + filteredCalendar[index].date, style: Theme.of(context).textTheme.titleMedium?.copyWith( fontStyle: FontStyle.italic, ), ), ), - itemCount: calendar.length, + itemCount: filteredCalendar.length, ), ); } From d514742882d93b6a5b145280c6dec2edf4f557d2 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Thu, 24 Aug 2023 22:52:55 +0100 Subject: [PATCH 4/5] Filter at parse lever --- uni/lib/controller/parsers/parser_calendar.dart | 11 ++++++++++- uni/lib/view/calendar/calendar.dart | 14 +++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/uni/lib/controller/parsers/parser_calendar.dart b/uni/lib/controller/parsers/parser_calendar.dart index 77af03e39..e98d5467d 100644 --- a/uni/lib/controller/parsers/parser_calendar.dart +++ b/uni/lib/controller/parsers/parser_calendar.dart @@ -7,7 +7,7 @@ Future> getCalendarFromHtml(Response response) async { final calendarHtml = document.querySelectorAll('tr'); - return calendarHtml + final eventList = calendarHtml .map( (event) => CalendarEvent( event.children[0].innerHtml, @@ -15,4 +15,13 @@ Future> getCalendarFromHtml(Response response) async { ), ) .toList(); + + final filteredCalendar = eventList + .where( + (event) => + event.name.trim() != ' ' && event.date.trim() != ' ', + ) + .toList(); + + return filteredCalendar; } diff --git a/uni/lib/view/calendar/calendar.dart b/uni/lib/view/calendar/calendar.dart index f1c69d671..48b0ef1fa 100644 --- a/uni/lib/view/calendar/calendar.dart +++ b/uni/lib/view/calendar/calendar.dart @@ -46,14 +46,6 @@ class CalendarPageViewState extends GeneralPageViewState { } Widget getTimeline(BuildContext context, List calendar) { - // Filter out events where name or date is a non-breaking space - final filteredCalendar = calendar - .where( - (event) => - event.name.trim() != ' ' && event.date.trim() != ' ', - ) - .toList(); - return FixedTimeline.tileBuilder( theme: TimelineTheme.of(context).copyWith( connectorTheme: TimelineTheme.of(context) @@ -68,7 +60,7 @@ class CalendarPageViewState extends GeneralPageViewState { contentsBuilder: (context, index) => Padding( padding: const EdgeInsets.all(24), child: Text( - filteredCalendar[index].name, + calendar[index].name, style: Theme.of(context) .textTheme .titleLarge @@ -78,13 +70,13 @@ class CalendarPageViewState extends GeneralPageViewState { oppositeContentsBuilder: (context, index) => Padding( padding: const EdgeInsets.all(24), child: Text( - filteredCalendar[index].date, + calendar[index].date, style: Theme.of(context).textTheme.titleMedium?.copyWith( fontStyle: FontStyle.italic, ), ), ), - itemCount: filteredCalendar.length, + itemCount: calendar.length, ), ); } From 183f7ea5ad4455e328ae3d8b93983c7d763929e3 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 3 Sep 2023 21:52:35 +0100 Subject: [PATCH 5/5] Cleaning code --- uni/lib/controller/parsers/parser_calendar.dart | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/uni/lib/controller/parsers/parser_calendar.dart b/uni/lib/controller/parsers/parser_calendar.dart index e98d5467d..0d3cb2bad 100644 --- a/uni/lib/controller/parsers/parser_calendar.dart +++ b/uni/lib/controller/parsers/parser_calendar.dart @@ -7,21 +7,16 @@ Future> getCalendarFromHtml(Response response) async { final calendarHtml = document.querySelectorAll('tr'); - final eventList = calendarHtml + return calendarHtml .map( (event) => CalendarEvent( event.children[0].innerHtml, event.children[1].innerHtml, ), ) - .toList(); - - final filteredCalendar = eventList .where( (event) => event.name.trim() != ' ' && event.date.trim() != ' ', ) .toList(); - - return filteredCalendar; }