Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: propagate hotfixes from master to develop #1200

Merged
merged 49 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e2e949f
March 2023 release (#1179)
bdmendes Mar 4, 2024
22aa8b5
Bump app version [no ci]
bdmendes Mar 4, 2024
a477bc2
hotfix: launch url with toast cast to bool
limwa Mar 5, 2024
14f018b
refactor: reuse launchUrlWithToast function
limwa Mar 5, 2024
8b2e33f
style: add trailing comma
limwa Mar 5, 2024
0218b6c
hotfix: add proper error handling to PlausibleProvider
limwa Mar 5, 2024
1bae2e9
hotfix: retrieve bus stops' csrf token
limwa Mar 5, 2024
d015d0a
hotfix: closed transaction in restaurants database
limwa Mar 5, 2024
d9d9ae1
hotfix: session provider has null state on 1st use
limwa Mar 5, 2024
7b7bac4
refactor: move profile provider after session provider
limwa Mar 5, 2024
1cc7990
fix: collect analytics from users without bat save capabilities
limwa Mar 5, 2024
3fbddeb
hotfix: null state on providers first use (#1182)
LuisDuarte1 Mar 5, 2024
d24c7fa
Bump app version [no ci]
LuisDuarte1 Mar 5, 2024
5365aab
hotfix: launch url with toast (#1186)
bdmendes Mar 5, 2024
396156c
hotfix: proper error handling in plausible provider (#1185)
bdmendes Mar 5, 2024
f5e5741
hotfix: retrieve bus stops' csrf token (#1184)
bdmendes Mar 5, 2024
4213325
Fix concurrency issue on deploy action
LuisDuarte1 Mar 5, 2024
2b1a735
Fix concurrency issue on deploy action (#1187)
LuisDuarte1 Mar 5, 2024
f3e5bd7
Bump app version [no ci]
LuisDuarte1 Mar 5, 2024
0b76807
hotfix: closed transaction in restaurants database (#1183)
limwa Mar 5, 2024
0dbf35d
hotfix: schedule parsing is aborted too soon
limwa Mar 6, 2024
a167d2a
docs: update terms and conditions date
limwa Mar 6, 2024
0dfbc5a
Solving race conditions
DGoiana Mar 6, 2024
0774db1
Handling deletion of directory
DGoiana Mar 7, 2024
33b3a0f
docs: update terms and conditions date (#1193)
limwa Mar 7, 2024
439673b
Bump app version [no ci]
limwa Mar 7, 2024
3ce8bdf
Use initial route instead of home widget
bdmendes Mar 6, 2024
1b9c52d
Notify listeners when invalidating provider state
bdmendes Mar 7, 2024
e72e1bd
Add try again button to lazy consumer error case
bdmendes Mar 7, 2024
3dc431e
Clear login inputs when login succeeds
bdmendes Mar 7, 2024
29b5663
Use initial route instead of home widget (#1190)
bdmendes Mar 7, 2024
7cf8f50
Bump app version [no ci]
bdmendes Mar 7, 2024
357c8f7
Merge branch 'master' into limwa/hotfix/schedule-parsing-is-aborted-t…
limwa Mar 7, 2024
d12d444
hotfix: schedule parsing is aborted too soon (#1192)
LuisDuarte1 Mar 7, 2024
934b341
Bump app version [no ci]
LuisDuarte1 Mar 7, 2024
bc644d1
Bump app version [no ci]
LuisDuarte1 Mar 7, 2024
d44a9b9
Avoiding deletion of .db files
DGoiana Mar 7, 2024
be1c3ae
hotfix: concurrent modification in bus stop provider
limwa Mar 7, 2024
ff4e87e
hotfix: concurrent modification in bus stop provider (#1197)
bdmendes Mar 8, 2024
54e5bd6
Bump app version [no ci]
bdmendes Mar 8, 2024
86649b0
refactor: send request information for bus debug
limwa Mar 7, 2024
86915a1
Merge branch 'master' into fix/path-access-exception
DGoiana Mar 8, 2024
ee0fec0
Removing unecessary cast
DGoiana Mar 8, 2024
577444f
Path exception error while trying to delete cached files (#1194)
limwa Mar 8, 2024
7f8f2b3
Bump app version [no ci]
limwa Mar 8, 2024
6f37a0d
Merge branch 'master' into limwa/refactor/send-request-information-fo…
DGoiana Mar 8, 2024
d021f27
refactor: send request information for bus debug (#1198)
limwa Mar 8, 2024
6339f6d
Bump app version [no ci]
limwa Mar 8, 2024
687fdf7
Merge branch 'develop' into limwa/chore/backport-hotfixes-20240308
limwa Mar 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion uni/assets/text/TermsAndConditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ If you would like to contact us to understand more about this Agreement or wish
concerning any matter relating to it, you may send an email to [[email protected]](mailto:[email protected]).
\
\
This document was last updated on February 28, 2023.
This document was last updated on March 6, 2024.
62 changes: 28 additions & 34 deletions uni/lib/controller/cleanup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:uni/controller/local_storage/database/app_bus_stop_database.dart';
Expand All @@ -22,24 +23,19 @@ Future<void> cleanupStoredData(BuildContext context) async {
final faculties = PreferencesController.getUserFaculties();
await prefs.clear();

unawaited(
Future.wait([
AppLecturesDatabase().deleteLectures(),
AppExamsDatabase().deleteExams(),
AppCoursesDatabase().deleteCourses(),
AppUserDataDatabase().deleteUserData(),
AppLastUserInfoUpdateDatabase().deleteLastUpdate(),
AppBusStopDatabase().deleteBusStops(),
AppCourseUnitsDatabase().deleteCourseUnits(),
NetworkRouter.killSigarraAuthentication(faculties),
]),
);
await Future.wait([
AppLecturesDatabase().deleteLectures(),
AppExamsDatabase().deleteExams(),
AppCoursesDatabase().deleteCourses(),
AppUserDataDatabase().deleteUserData(),
AppLastUserInfoUpdateDatabase().deleteLastUpdate(),
AppBusStopDatabase().deleteBusStops(),
AppCourseUnitsDatabase().deleteCourseUnits(),
NetworkRouter.killSigarraAuthentication(faculties),
]);

final path = (await getApplicationDocumentsDirectory()).path;
final directory = Directory(path);
if (directory.existsSync()) {
directory.deleteSync(recursive: true);
}
final toCleanDirectory = await getApplicationDocumentsDirectory();
await cleanDirectory(toCleanDirectory, DateTime.now());
}

Future<void> cleanupCachedFiles() async {
Expand All @@ -53,26 +49,24 @@ Future<void> cleanupCachedFiles() async {

final toCleanDirectory = await getApplicationDocumentsDirectory();
final threshold = DateTime.now().subtract(const Duration(days: 30));
final directories = toCleanDirectory.listSync(followLinks: false);

for (final directory in directories) {
if (directory is Directory) {
final files = directory.listSync(recursive: true, followLinks: false);
await cleanDirectory(toCleanDirectory, threshold);

final oldFiles = files.where((file) {
try {
final fileDate = File(file.path).lastModifiedSync();
return fileDate.isBefore(threshold);
} catch (e) {
return false;
}
});
await PreferencesController.setLastCleanUpDate(DateTime.now());
}

for (final file in oldFiles) {
await File(file.path).delete();
}
Future<void> cleanDirectory(Directory directory, DateTime threshold) async {
final entities = directory.listSync(recursive: true, followLinks: false);
final toDeleteEntities = entities.whereType<File>().where((file) {
try {
final fileDate = file.lastModifiedSync();
return fileDate.isBefore(threshold) && path.extension(file.path) != '.db';
} catch (e) {
return false;
}
}
});

await PreferencesController.setLastCleanUpDate(DateTime.now());
for (final entity in toDeleteEntities) {
entity.deleteSync();
}
}
52 changes: 34 additions & 18 deletions uni/lib/controller/fetchers/departures_fetcher.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:html/dom.dart';
import 'package:html/parser.dart';
import 'package:http/io_client.dart' as http;
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/model/entities/bus.dart';
import 'package:uni/model/entities/bus_stop.dart';
Expand All @@ -26,24 +28,38 @@ class DeparturesFetcher {

final response = await _client.get(url.toUri());
final htmlResponse = parse(response.body);

final scriptText = htmlResponse
.querySelectorAll('table script')
.where((element) => element.text.contains(_stopCode))
.map((e) => e.text)
.first;

final callParam = scriptText
.substring(scriptText.indexOf('('))
.split(',')
.firstWhere((element) => element.contains(')'));

final csrfToken = callParam.substring(
callParam.indexOf("'") + 1,
callParam.lastIndexOf("'"),
);

return csrfToken;
try {
final scriptText = htmlResponse
.querySelectorAll('table script')
.where((element) => element.text.contains(_stopCode))
.map((e) => e.text)
.first;

final callParam = scriptText
.substring(scriptText.indexOf('('))
.split(',')
.firstWhere((element) => element.contains(')'));

final csrfToken = callParam.substring(
callParam.indexOf("'") + 1,
callParam.lastIndexOf("'"),
);
return csrfToken;
} catch (e, stackTrace) {
unawaited(
Sentry.captureEvent(
SentryEvent(
throwable: e,
request: SentryRequest(
url: url,
data: response.body,
),
),
stackTrace: stackTrace,
),
);
rethrow;
}
}

void throwCSRFTokenError() {
Expand Down
13 changes: 6 additions & 7 deletions uni/lib/controller/parsers/parser_schedule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Future<List<Lecture>> parseScheduleMultipleRequests(
for (final (week, response) in responsesPerWeeks) {
lectures += await parseSchedule(response, week);
}

if (lectures.isEmpty) {
return Future.error(Exception('Found empty schedule'));
}

return lectures;
}

Expand Down Expand Up @@ -70,11 +75,5 @@ Future<List<Lecture>> parseSchedule(
lectures.add(lec);
}

final lecturesList = lectures.toList()..sort((a, b) => a.compare(b));

if (lecturesList.isEmpty) {
return Future.error(Exception('Found empty schedule'));
}

return lecturesList;
return lectures.toList()..sort((a, b) => a.compare(b));
}
13 changes: 7 additions & 6 deletions uni/lib/generated/intl/messages_all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
import 'package:intl/src/intl_helpers.dart';
Expand All @@ -20,8 +21,8 @@ import 'messages_pt_PT.dart' as messages_pt_pt;

typedef Future<dynamic> LibraryLoader();
Map<String, LibraryLoader> _deferredLibraries = {
'en': () => new Future.value(null),
'pt_PT': () => new Future.value(null),
'en': () => new SynchronousFuture(null),
'pt_PT': () => new SynchronousFuture(null),
};

MessageLookupByLibrary? _findExact(String localeName) {
Expand All @@ -36,18 +37,18 @@ MessageLookupByLibrary? _findExact(String localeName) {
}

/// User programs should call this before using [localeName] for messages.
Future<bool> initializeMessages(String localeName) async {
Future<bool> initializeMessages(String localeName) {
var availableLocale = Intl.verifiedLocale(
localeName, (locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null);
if (availableLocale == null) {
return new Future.value(false);
return new SynchronousFuture(false);
}
var lib = _deferredLibraries[availableLocale];
await (lib == null ? new Future.value(false) : lib());
lib == null ? new SynchronousFuture(false) : lib();
initializeInternalMessageLookup(() => new CompositeMessageLookup());
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
return new Future.value(true);
return new SynchronousFuture(true);
}

bool _messagesExistFor(String locale) {
Expand Down
14 changes: 8 additions & 6 deletions uni/lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
Expand All @@ -19,12 +20,12 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'en';

static m0(time) => "last refresh at ${time}";
static String m0(time) => "last refresh at ${time}";

static m1(time) =>
static String m1(time) =>
"${Intl.plural(time, zero: 'Refreshed ${time} minutes ago', one: 'Refreshed ${time} minute ago', other: 'Refreshed ${time} minutes ago')}";

static m2(title) => "${Intl.select(title, {
static String m2(title) => "${Intl.select(title, {
'horario': 'Schedule',
'exames': 'Exams',
'area': 'Personal Area',
Expand All @@ -41,7 +42,7 @@ class MessageLookup extends MessageLookupByLibrary {
})}";

final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function>{
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"about": MessageLookupByLibrary.simpleMessage("About us"),
"academic_services":
MessageLookupByLibrary.simpleMessage("Academic services"),
Expand Down Expand Up @@ -277,7 +278,8 @@ class MessageLookup extends MessageLookupByLibrary {
"terms": MessageLookupByLibrary.simpleMessage("Terms and Conditions"),
"theme": MessageLookupByLibrary.simpleMessage("Theme"),
"title": MessageLookupByLibrary.simpleMessage("Title"),
"uc_info": MessageLookupByLibrary.simpleMessage("Open UC page in app"),
"try_again": MessageLookupByLibrary.simpleMessage("Try again"),
"uc_info": MessageLookupByLibrary.simpleMessage("Open UC page"),
"unavailable": MessageLookupByLibrary.simpleMessage("Unavailable"),
"valid_email":
MessageLookupByLibrary.simpleMessage("Please enter a valid email"),
Expand Down
15 changes: 8 additions & 7 deletions uni/lib/generated/intl/messages_pt_PT.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
Expand All @@ -19,12 +20,12 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'pt_PT';

static m0(time) => "última atualização às ${time}";
static String m0(time) => "última atualização às ${time}";

static m1(time) =>
static String m1(time) =>
"${Intl.plural(time, zero: 'Atualizado há ${time} minutos', one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}";

static m2(title) => "${Intl.select(title, {
static String m2(title) => "${Intl.select(title, {
'horario': 'Horário',
'exames': 'Exames',
'area': 'Área Pessoal',
Expand All @@ -41,7 +42,7 @@ class MessageLookup extends MessageLookupByLibrary {
})}";

final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function>{
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"about": MessageLookupByLibrary.simpleMessage("Sobre nós"),
"academic_services":
MessageLookupByLibrary.simpleMessage("Serviços académicos"),
Expand Down Expand Up @@ -279,8 +280,8 @@ class MessageLookup extends MessageLookupByLibrary {
"terms": MessageLookupByLibrary.simpleMessage("Termos e Condições"),
"theme": MessageLookupByLibrary.simpleMessage("Tema"),
"title": MessageLookupByLibrary.simpleMessage("Título"),
"uc_info":
MessageLookupByLibrary.simpleMessage("Abrir página da UC na app"),
"try_again": MessageLookupByLibrary.simpleMessage("Tentar de novo"),
"uc_info": MessageLookupByLibrary.simpleMessage("Abrir página da UC"),
"unavailable": MessageLookupByLibrary.simpleMessage("Indisponível"),
"valid_email": MessageLookupByLibrary.simpleMessage(
"Por favor insere um email válido"),
Expand Down
10 changes: 10 additions & 0 deletions uni/lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion uni/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,7 @@
"confirm_logout": "Do you really want to log out? Your local data will be deleted and you will have to log in again.",
"@confirm_logout": {},
"collect_usage_stats": "Collect usage statistics",
"@usage_stats": {}
"@usage_stats": {},
"try_again": "Try again",
"@try_again": {}
}
4 changes: 3 additions & 1 deletion uni/lib/l10n/intl_pt_PT.arb
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,7 @@
"confirm_logout": "Tens a certeza de que queres terminar sessão? Os teus dados locais serão apagados e terás de iniciar sessão novamente.",
"@confirm_logout": {},
"collect_usage_stats": "Partilhar estatísticas de uso",
"@collect_usage_stats": {}
"@collect_usage_stats": {},
"try_again": "Tentar de novo",
"@try_again": {}
}
Loading
Loading