Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Fix no token public courses #287

Merged
merged 5 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 23 additions & 23 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@ PODS:
- connectivity_plus (0.0.1):
- Flutter
- ReachabilitySwift
- Firebase/CoreOnly (10.18.0):
- FirebaseCore (= 10.18.0)
- Firebase/Messaging (10.18.0):
- Firebase/CoreOnly (10.20.0):
- FirebaseCore (= 10.20.0)
- Firebase/Messaging (10.20.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 10.18.0)
- firebase_core (2.24.2):
- Firebase/CoreOnly (= 10.18.0)
- FirebaseMessaging (~> 10.20.0)
- firebase_core (2.25.4):
- Firebase/CoreOnly (= 10.20.0)
- Flutter
- firebase_messaging (14.7.10):
- Firebase/Messaging (= 10.18.0)
- firebase_messaging (14.7.15):
- Firebase/Messaging (= 10.20.0)
- firebase_core
- Flutter
- FirebaseCore (10.18.0):
- FirebaseCore (10.20.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.12)
- GoogleUtilities/Logger (~> 7.12)
- FirebaseCoreInternal (10.20.0):
- FirebaseCoreInternal (10.21.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseInstallations (10.20.0):
- FirebaseInstallations (10.21.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- FirebaseMessaging (10.18.0):
- FirebaseMessaging (10.20.0):
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
- GoogleDataTransport (~> 9.2)
- GoogleDataTransport (~> 9.3)
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Reachability (~> 7.8)
Expand Down Expand Up @@ -155,14 +155,14 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
Firebase: 414ad272f8d02dfbf12662a9d43f4bba9bec2a06
firebase_core: 0af4a2b24f62071f9bf283691c0ee41556dcb3f5
firebase_messaging: 90e8a6db84b6e1e876cebce4f30f01dc495e7014
FirebaseCore: 2322423314d92f946219c8791674d2f3345b598f
FirebaseCoreInternal: efeeb171ac02d623bdaefe121539939821e10811
FirebaseInstallations: 558b1da7d65afeb996fd5c814332f013234ece4e
FirebaseMessaging: 9bc34a98d2e0237e1b121915120d4d48ddcf301e
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Firebase: 10c8cb12fb7ad2ae0c09ffc86cd9c1ab392a0031
firebase_core: a46c312d8bae4defa3d009b2aa7b5b413aeb394e
firebase_messaging: 40d7dd2f3e88a6367c7326cf601f84633d477582
FirebaseCore: 28045c1560a2600d284b9c45a904fe322dc890b6
FirebaseCoreInternal: 43c1788eaeee9d1b97caaa751af567ce11010d00
FirebaseInstallations: 390ea1d10a4d02b20c965cbfd527ee9b3b412acb
FirebaseMessaging: 06c414a21b122396a26847c523d5c370f8325df5
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_inappwebview: 3d32228f1304635e7c028b0d4252937730bbc6cf
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
GoogleDataTransport: 57c22343ab29bc686febbf7cbb13bad167c2d8fe
Expand All @@ -178,8 +178,8 @@ SPEC CHECKSUMS:
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579
wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47
webview_flutter_wkwebview: 4f3e50f7273d31e5500066ed267e3ae4309c5ae4
webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36

PODFILE CHECKSUM: 7be2f5f74864d463a8ad433546ed1de7e0f29aef

COCOAPODS: 1.15.0
COCOAPODS: 1.15.2
3 changes: 2 additions & 1 deletion lib/base/networking/api/handler/auth_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class AuthHandler {
.i('Received HTTP response with status code: ${response.statusCode}');
} catch (e) {
_logger.e(
'Error during basic authentication for user: $username, Error: $e');
'Error during basic authentication for user: $username, Error: $e',
);
throw AppError.userError();
}
try {
Expand Down
3 changes: 1 addition & 2 deletions lib/base/networking/api/handler/token_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ class TokenHandler {
final token = await _storage.read(key: key);
if (token == null) {
_logger.w('Token not found for key: $key');
throw AppError.authenticationError();
return '';
}

_logger.i('Token successfully loaded for key: $key');
return token;
} catch (e) {
Expand Down
13 changes: 0 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:gocast_mobile/models/user/user_state_model.dart';
Expand Down Expand Up @@ -42,18 +41,6 @@ class App extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final connectivityStatus = ref.watch(connectivityProvider);
connectivityStatus.whenData((result) {
if(result == ConnectivityResult.none) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (ModalRoute.of(context)?.settings.name != '/downloads') {
Navigator.of(context).pushNamed('/downloads');
return;
}
});
}
});

final userState = ref.watch(userViewModelProvider);

bool isLoggedIn = ref.watch(userViewModelProvider).user != null;
Expand Down
1 change: 0 additions & 1 deletion lib/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,3 @@ final playbackSpeedsProvider = StateProvider<List<double>>((ref) {
final connectivityProvider = StreamProvider<ConnectivityResult>((ref) {
return Connectivity().onConnectivityChanged;
});

16 changes: 12 additions & 4 deletions lib/view_models/chat_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class ChatViewModel extends StateNotifier<ChatState> {
final messages =
await ChatHandlers(_grpcHandler).getChatMessages(streamId);
state = state.copyWith(
messages: messages, isLoading: false, accessDenied: false);
messages: messages,
isLoading: false,
accessDenied: false,
);
} catch (e) {
state = state.copyWith(
error: e as AppError,
Expand All @@ -38,10 +41,15 @@ class ChatViewModel extends StateNotifier<ChatState> {
final messages =
await ChatHandlers(_grpcHandler).getChatMessages(streamId);
final combinedMessages = List<ChatMessage>.from(state.messages ?? [])
..addAll(messages
.where((newMessage) => !state.messages!.contains(newMessage)));
..addAll(
messages
.where((newMessage) => !state.messages!.contains(newMessage)),
);
state = state.copyWith(
messages: combinedMessages, isLoading: false, accessDenied: false);
messages: combinedMessages,
isLoading: false,
accessDenied: false,
);
} catch (e) {
state = state.copyWith(
error: e as AppError,
Expand Down
18 changes: 12 additions & 6 deletions lib/view_models/download_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ class DownloadViewModel extends StateNotifier<DownloadState> {
}
}

Future<String> downloadVideo(String videoUrl, Stream stream,
String streamName, String streamDate) async {
Future<String> downloadVideo(
String videoUrl,
Stream stream,
String streamName,
String streamDate,
) async {
try {
final directory = await getApplicationDocumentsDirectory();
final filePath =
Expand All @@ -60,10 +64,12 @@ class DownloadViewModel extends StateNotifier<DownloadState> {
final videoDetailsMap = {
'filePath': filePath,
'name': streamName,
'duration': Tools.formatDuration(stream.end
.toDateTime()
.difference(stream.start.toDateTime())
.inMinutes),
'duration': Tools.formatDuration(
stream.end
.toDateTime()
.difference(stream.start.toDateTime())
.inMinutes,
),
'description': stream.description,
'date': streamDate,
};
Expand Down
3 changes: 2 additions & 1 deletion lib/views/chat_view/chat_view_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class ChatViewState extends ConsumerState<ChatView> {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'You are sending messages too fast. Please wait a 60 seconds.'),
'You are sending messages too fast. Please wait a 60 seconds.',
),
),
);
});
Expand Down
3 changes: 2 additions & 1 deletion lib/views/chat_view/poll_view_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ class PollViewState extends ConsumerState<PollView> {

return Padding(
padding: const EdgeInsets.all(
8.0), // Consistent padding with the rest of the layout
8.0,
), // Consistent padding with the rest of the layout
child: ElevatedButton(
onPressed: selectedOptions.containsKey(poll.id)
? () {
Expand Down
8 changes: 5 additions & 3 deletions lib/views/chat_view/suggested_streams_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class SuggestedStreamsWidget extends StatelessWidget {
final stream = suggestedStreams[index];
return ListTile(
leading: const Icon(Icons.play_circle_outline),
title: Text(stream.name != ''
? stream.name
: 'Lecture: ${DateFormat('EEEE. dd', Localizations.localeOf(context).toString()).format(stream.start.toDateTime())}'),
title: Text(
stream.name != ''
? stream.name
: 'Lecture: ${DateFormat('EEEE. dd', Localizations.localeOf(context).toString()).format(stream.start.toDateTime())}',
),
subtitle: Text(
DateFormat('dd MMMM yyyy').format(stream.start.toDateTime()),
),
Expand Down
7 changes: 5 additions & 2 deletions lib/views/course_view/components/course_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ class CourseCard extends StatelessWidget {
child: _buildCourseTitle(themeData.textTheme),
),
if (isPinned)
Icon(Icons.push_pin,
color: themeData.primaryColor, size: 16),
Icon(
Icons.push_pin,
color: themeData.primaryColor,
size: 16,
),
],
),
),
Expand Down
10 changes: 8 additions & 2 deletions lib/views/course_view/components/small_stream_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,20 @@ class SmallStreamCard extends StatelessWidget {
}

Widget _buildStreamCard(
BuildContext context, ThemeData themeData, double cardWidth) {
BuildContext context,
ThemeData themeData,
double cardWidth,
) {
return (isDownloaded != null && showDeleteConfirmationDialog != null)
? _buildDownloadedCard(context, themeData, cardWidth)
: _buildLiveCard(themeData, cardWidth);
}

Widget _buildDownloadedCard(
BuildContext context, ThemeData themeData, double cardWidth) {
BuildContext context,
ThemeData themeData,
double cardWidth,
) {
return Slidable(
key: Key(courseId.toString()),
closeOnScroll: true,
Expand Down
10 changes: 6 additions & 4 deletions lib/views/course_view/components/stream_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ class StreamCardState extends ConsumerState<StreamCard> {
),
padding: const EdgeInsets.all(5),
child: Text(
Tools.formatDuration(widget.stream.end
.toDateTime()
.difference(widget.stream.start.toDateTime())
.inMinutes),
Tools.formatDuration(
widget.stream.end
.toDateTime()
.difference(widget.stream.start.toDateTime())
.inMinutes,
),
style: themeData.textTheme.labelSmall?.copyWith(
fontSize: 12,
color: Colors.white,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ class DownloadCoursesContentView extends ConsumerWidget {
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 295.0),
child: Text(AppLocalizations.of(context)!
.no_downloaded_courses),
child: Text(
AppLocalizations.of(context)!.no_downloaded_courses,
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DownloadedCoursesState extends ConsumerState<DownloadedCourses> {
title: AppLocalizations.of(context)!.download,
filterOptions: [
AppLocalizations.of(context)!.newest_first,
AppLocalizations.of(context)!.oldest_first
AppLocalizations.of(context)!.oldest_first,
],
onClick: (String choice) {
// Handle filter option click
Expand Down
15 changes: 10 additions & 5 deletions lib/views/notifications_view/notifications_screen_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ class NotificationsScreen extends ConsumerWidget {
scrollDirection: Axis.vertical,
children: [
_buildSectionHeader(
AppLocalizations.of(context)!.banner_notification),
AppLocalizations.of(context)!.banner_notification,
),
for (var alert in bannerAlerts) _buildBannerAlert(alert),
_buildSectionHeader(
AppLocalizations.of(context)!.feature_notifications),
AppLocalizations.of(context)!.feature_notifications,
),
for (var notification in featureNotifications)
_buildFeatureNotification(notification),
_buildSectionHeader(
AppLocalizations.of(context)!.recent_uploads),
AppLocalizations.of(context)!.recent_uploads,
),
for (var notification in pushNotifications)
_buildPushNotification(notification),
],
Expand Down Expand Up @@ -76,8 +79,10 @@ class NotificationsScreen extends ConsumerWidget {
children: <Widget>[
Expanded(
child: Center(
child: Text(AppLocalizations.of(context)!
.no_notifications_found)),
child: Text(
AppLocalizations.of(context)!.no_notifications_found,
),
),
),
],
),
Expand Down
Loading
Loading