From e86e216408e51016eaad501a4c860a2a8a5bce0b Mon Sep 17 00:00:00 2001 From: happycastle <41810556+happycastle114@users.noreply.github.com> Date: Wed, 23 Aug 2023 22:05:41 +0900 Subject: [PATCH 1/4] Refactor: Remove unused config --- lib/constants/constants.dart | 11 ----------- lib/utils/fcmToken.dart | 6 ++++-- lib/utils/pushHandler.dart | 8 +++----- lib/utils/remoteConfigController.dart | 12 ++---------- lib/utils/token.dart | 10 ++++++---- 5 files changed, 15 insertions(+), 32 deletions(-) delete mode 100644 lib/constants/constants.dart diff --git a/lib/constants/constants.dart b/lib/constants/constants.dart deleted file mode 100644 index 81b3bf7..0000000 --- a/lib/constants/constants.dart +++ /dev/null @@ -1,11 +0,0 @@ -import "package:dio/dio.dart"; -import 'package:flutter_dotenv/flutter_dotenv.dart'; -import 'package:taxiapp/utils/remoteConfigController.dart'; - -String address = RemoteConfigController().backUrl; - -final BaseOptions connectionOptions = BaseOptions( - baseUrl: address, - connectTimeout: Duration(seconds: 150), - receiveTimeout: Duration(seconds: 130), -); diff --git a/lib/utils/fcmToken.dart b/lib/utils/fcmToken.dart index c591753..3be83dc 100644 --- a/lib/utils/fcmToken.dart +++ b/lib/utils/fcmToken.dart @@ -1,13 +1,13 @@ import "package:dio/dio.dart"; import 'package:firebase_messaging/firebase_messaging.dart'; -import 'package:taxiapp/constants/constants.dart'; +import 'package:taxiapp/utils/remoteConfigController.dart'; class FcmToken { String token; static FcmToken? _instance; - final Dio _dio = Dio(connectionOptions); + final Dio _dio = Dio(); FcmToken._internal({required this.token}); @@ -32,6 +32,7 @@ class FcmToken { String get fcmToken => token; Future registerToken(String accessToken) async { + _dio.options.baseUrl = RemoteConfigController().backUrl; return _dio.post("auth/app/device", data: { "accessToken": accessToken, "deviceToken": token, @@ -43,6 +44,7 @@ class FcmToken { } Future removeToken(String accessToken) async { + _dio.options.baseUrl = RemoteConfigController().backUrl; return _dio.delete("auth/app/device", data: { "accessToken": accessToken, "deviceToken": token, diff --git a/lib/utils/pushHandler.dart b/lib/utils/pushHandler.dart index bb8c0ae..f92094f 100644 --- a/lib/utils/pushHandler.dart +++ b/lib/utils/pushHandler.dart @@ -33,11 +33,9 @@ Future handleMessage(RemoteMessage message) async { var details = NotificationDetails(android: androidNotiDetails, iOS: iOSNotiDetails); - if (message.data != null) { - flutterLocalNotificationsPlugin.show(Random().nextInt(100000000), - message.data['title'], message.data['body'], details, - payload: message.data['url']); - } + flutterLocalNotificationsPlugin.show(Random().nextInt(100000000), + message.data['title'], message.data['body'], details, + payload: message.data['url']); } Future _getByteArrayFromUrl(String url) async { diff --git a/lib/utils/remoteConfigController.dart b/lib/utils/remoteConfigController.dart index 2754eab..7d035c3 100644 --- a/lib/utils/remoteConfigController.dart +++ b/lib/utils/remoteConfigController.dart @@ -1,5 +1,3 @@ -import "package:dio/dio.dart"; -import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_remote_config/firebase_remote_config.dart'; import 'package:package_info/package_info.dart'; @@ -29,10 +27,7 @@ class RemoteConfigController { ios_version == null || android_version == null) { return _instance ??= RemoteConfigController._internal( - backUrl: 'https://taxi.sparcs.org/api/', - frontUrl: 'https://taxi.sparcs.org', - ios_version: '', - android_version: ''); + backUrl: '', frontUrl: '', ios_version: '', android_version: ''); } _instance = RemoteConfigController._internal( backUrl: backUrl, @@ -40,10 +35,7 @@ class RemoteConfigController { ios_version: ios_version, android_version: android_version); return _instance ??= RemoteConfigController._internal( - backUrl: 'https://taxi.sparcs.org/api/', - frontUrl: 'https://taxi.sparcs.org', - ios_version: '', - android_version: ''); + backUrl: '', frontUrl: '', ios_version: '', android_version: ''); } Future init() async { diff --git a/lib/utils/token.dart b/lib/utils/token.dart index c58c12b..4755516 100644 --- a/lib/utils/token.dart +++ b/lib/utils/token.dart @@ -1,11 +1,11 @@ import 'dart:io'; import "package:dio/dio.dart"; -import 'package:taxiapp/constants/constants.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:cookie_jar/cookie_jar.dart'; import 'package:dio_cookie_manager/dio_cookie_manager.dart'; import 'package:taxiapp/utils/fcmToken.dart'; +import 'package:taxiapp/utils/remoteConfigController.dart'; class Token { String accessToken; @@ -13,7 +13,7 @@ class Token { static Token? _instance; static final _storage = FlutterSecureStorage(); - final Dio _dio = Dio(connectionOptions); + final Dio _dio = Dio(); final CookieJar _cookieJar = CookieJar(); Token._internal({required this.accessToken, required this.refreshToken}); @@ -56,6 +56,7 @@ class Token { } Future getSession() async { + _dio.options.baseUrl = RemoteConfigController().backUrl; _dio.interceptors.add(CookieManager(_cookieJar)); return _dio.get("/auth/app/token/login", queryParameters: { "accessToken": accessToken, @@ -74,8 +75,8 @@ class Token { return null; } if (response.statusCode == 200) { - List cookies = await _cookieJar.loadForRequest( - Uri.parse(connectionOptions.baseUrl + "auth/app/token/login")); + List cookies = await _cookieJar.loadForRequest(Uri.parse( + RemoteConfigController().backUrl + "auth/app/token/login")); for (Cookie cookie in cookies) { if (cookie.name == "connect.sid") { return cookie.value; @@ -90,6 +91,7 @@ class Token { } Future updateAccessTokenUsingRefreshToken() { + _dio.options.baseUrl = RemoteConfigController().backUrl; return _dio.get("/auth/app/token/refresh", queryParameters: { "accessToken": accessToken, "refreshToken": refreshToken, From 64e9011547192c7764d60566c48efe62a937c5cc Mon Sep 17 00:00:00 2001 From: happycastle <41810556+happycastle114@users.noreply.github.com> Date: Wed, 23 Aug 2023 22:10:07 +0900 Subject: [PATCH 2/4] Refactor: Remove unused logout url handler --- lib/views/taxiView.dart | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/lib/views/taxiView.dart b/lib/views/taxiView.dart index 1b80ef7..3b550a2 100644 --- a/lib/views/taxiView.dart +++ b/lib/views/taxiView.dart @@ -388,30 +388,6 @@ class TaxiView extends HookWidget { } } }, - onUpdateVisitedHistory: - (controller, url, androidIsReload) async { - // 로그아웃 링크 감지 - if (url.toString().contains("logout") && isAuthLogin.value) { - await controller.stopLoading(); - try { - await FcmToken().removeToken(Token().getAccessToken()); - await Token().deleteAll(); - isLogin.value = false; - isAuthLogin.value = false; - await _cookieManager.deleteAllCookies(); - await _controller.value!.loadUrl( - urlRequest: URLRequest(url: Uri.parse(address))); - } catch (e) { - // TODO - Fluttertoast.showToast( - msg: "서버와의 연결에 실패했습니다.", - toastLength: Toast.LENGTH_SHORT, - textColor: Colors.black, - backgroundColor: Colors.white); - isAuthLogin.value = false; - } - } - }, onLoadResourceCustomScheme: (controller, url) async { if (Platform.isAndroid) { if (url.scheme == 'intent') { From 632d1b7a019915a9278f0867c41a0b4a9db8bb2e Mon Sep 17 00:00:00 2001 From: happycastle <41810556+happycastle114@users.noreply.github.com> Date: Wed, 23 Aug 2023 22:54:46 +0900 Subject: [PATCH 3/4] Fix: Remove error Code Check --- lib/views/taxiView.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/views/taxiView.dart b/lib/views/taxiView.dart index 1b80ef7..36a987b 100644 --- a/lib/views/taxiView.dart +++ b/lib/views/taxiView.dart @@ -441,9 +441,7 @@ class TaxiView extends HookWidget { // 될 때까지 리로드 if (!isLoaded.value && LoadCount.value < 10) { LoadCount.value++; - } - - if (code == -2) { + } else if (isServerError.value == false) { Fluttertoast.showToast( msg: "서버와의 연결에 실패했습니다.", toastLength: Toast.LENGTH_SHORT, From 464d2acd2e3aeb4616d212fcdf4a7f57bacde3fa Mon Sep 17 00:00:00 2001 From: happycastle <41810556+happycastle114@users.noreply.github.com> Date: Wed, 23 Aug 2023 23:27:07 +0900 Subject: [PATCH 4/4] Refactor: Change Kotlin Version --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 88720e4..9f980fc 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.9.10' repositories { google() mavenCentral()