Skip to content

Commit

Permalink
Glitchy Login Fix Merge (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
shah-esha authored Feb 21, 2025
1 parent 21bfff4 commit 82a7f87
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ npx prisma migrate dev --name my_migration
- **Jesse Cheng** - Developer
- **Temi Adebowale** - Developer
- **Frank Dai** - Developer
- **Esha Shah** - Developer
- **Happy Li** - Designer
- **Ashley Paik** - Designer
- **Jessica Liu** - Designer
Expand Down
17 changes: 14 additions & 3 deletions game/lib/api/game_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,24 @@ class ApiClient extends ChangeNotifier {
IO.OptionBuilder()
.setTransports(["websocket"])
.disableAutoConnect()
.disableReconnection()
.setAuth({'token': _accessToken})
.build());

socket.onDisconnect((data) {
_serverApi = null;
notifyListeners();
print("Server Disconnected!");
// Check if user is logged out
if (_refreshToken == null) {
_serverApi = null;
notifyListeners();
}
});

socket.onReconnectFailed((_) async {
// Try to reconnect
final refreshResult = await _accessRefresher();
if (!refreshResult) {
_serverApi = null;
}
});

socket.onConnect((data) {
Expand Down
1 change: 0 additions & 1 deletion game/lib/journeys/search_bar.dart

This file was deleted.

15 changes: 15 additions & 0 deletions game/lib/loading_page/loading_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ import 'package:flutter/material.dart';
import 'package:game/navigation_page/bottom_navbar.dart';
import 'package:game/splash_page/splash_page.dart';

/**
* `LoadingPageWidget` - Displays a loading screen while awaiting the result of a re-login attempt
* and redirects the user based on the result.
*
* @remarks
* This widget is used to show a loading indicator while the app awaits the result of a re-login attempt.
* Once the result is available, it navigates to the appropriate screen:
* - If the re-login is successful, the user is redirected to the main app page.
* - If the re-login fails, the user is redirected to the splash screen.
* The widget ensures that any necessary updates, such as notifying listeners, are completed before navigating.
*
* @param relogResult - The [Future<bool>] representing the result of the re-login operation.
* - `true`: If the re-login attempt is successful, the user is redirected to the main page.
* - `false`: If the re-login attempt fails, the user is redirected to the splash screen.
*/
class LoadingPageWidget extends StatelessWidget {
final Future<bool> relogResult;
LoadingPageWidget(this.relogResult, {Key? key}) : super(key: key);
Expand Down

0 comments on commit 82a7f87

Please sign in to comment.