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

Glitchy Login Fix #248

Merged
merged 9 commits into from
Feb 21, 2025
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
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
Loading