From 4903d23364420f43b08094c37fccc8caa54d771f Mon Sep 17 00:00:00 2001 From: HuyNguyen Date: Fri, 18 Oct 2024 11:19:07 +0700 Subject: [PATCH 1/2] Hotfix: Update auth path for build --- config.sample.json | 3 ++- lib/config/app_config.dart | 5 +++++ lib/presentation/mixins/connect_page_mixin.dart | 13 +++++++++---- lib/utils/string_extension.dart | 11 +++++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/config.sample.json b/config.sample.json index 4641e6c726..27ce4416f8 100644 --- a/config.sample.json +++ b/config.sample.json @@ -12,5 +12,6 @@ "app_grid_dashboard_available": true, "homeserver": "https://example.com/", "platform": "platform", - "default_max_upload_avatar_size_in_bytes": 1000000 + "default_max_upload_avatar_size_in_bytes": 1000000, + "dev_mode": false } diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index f933c6a657..bfb5030408 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -124,6 +124,8 @@ abstract class AppConfig { static int defaultMaxUploadAvtarSizeInBytes = 10 * (1024 * 1024); + static bool devMode = false; + static const String appGridConfigurationPath = "configurations/app_dashboard.json"; @@ -243,5 +245,8 @@ abstract class AppConfig { defaultMaxUploadAvtarSizeInBytes = json['default_max_upload_avatar_size_in_bytes']; } + if (json['dev_mode'] is bool) { + devMode = json['dev_mode']; + } } } diff --git a/lib/presentation/mixins/connect_page_mixin.dart b/lib/presentation/mixins/connect_page_mixin.dart index 62f3bf02c3..65d2510610 100644 --- a/lib/presentation/mixins/connect_page_mixin.dart +++ b/lib/presentation/mixins/connect_page_mixin.dart @@ -217,9 +217,11 @@ mixin ConnectPageMixin { String _generatePostLogoutRedirectUrl() { if (kIsWeb) { if (AppConfig.issueId != null && AppConfig.issueId!.isNotEmpty) { - return '${html.window.location.href.getBaseUrlBeforeHash()}/twake-on-matrix/${AppConfig.issueId}/auth.html'; + return '${html.window.location.href.getBaseUrlBeforeHash()}auth.html'; } - return '${html.window.location.href.getBaseUrlBeforeHash()}web/auth.html'; + return html.window.location.href + .getBaseUrlBeforeHash() + .generateAuthPath(isDevMode: AppConfig.devMode); } return '${AppConfig.appOpenUrlScheme.toLowerCase()}://redirect'; } @@ -231,9 +233,12 @@ mixin ConnectPageMixin { homeserverParam = '?homeserver=$homeserver'; } if (AppConfig.issueId != null && AppConfig.issueId!.isNotEmpty) { - return '${html.window.location.href.getBaseUrlBeforeHash()}/twake-on-matrix/${AppConfig.issueId}/auth.html$homeserverParam'; + return '${html.window.location.href.getBaseUrlBeforeHash()}auth.html$homeserverParam'; } - return '${html.window.location.href.getBaseUrlBeforeHash()}web/auth.html$homeserverParam'; + return html.window.location.href.getBaseUrlBeforeHash().generateAuthPath( + homeserverParams: homeserverParam, + isDevMode: AppConfig.devMode, + ); } return '${AppConfig.appOpenUrlScheme.toLowerCase()}://login'; } diff --git a/lib/utils/string_extension.dart b/lib/utils/string_extension.dart index 2bde62a822..ee10d85bb5 100644 --- a/lib/utils/string_extension.dart +++ b/lib/utils/string_extension.dart @@ -381,4 +381,15 @@ extension StringCasingExtension on String { final fragmentIndex = indexOf('#/'); return fragmentIndex != -1 ? substring(0, fragmentIndex) : this; } + + String generateAuthPath({ + String? homeserverParams, + bool isDevMode = false, + }) { + if (isDevMode) { + return '${this}web/auth.html$homeserverParams'; + } else { + return '${this}auth.html$homeserverParams'; + } + } } From bf25d1c3ab58d807d6a2bde43eafde0661378a50 Mon Sep 17 00:00:00 2001 From: HuyNguyen Date: Fri, 18 Oct 2024 11:55:41 +0700 Subject: [PATCH 2/2] Hotfix: Update ADR for config.file --- docs/configurations/config_web_app_for_public_platform.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/configurations/config_web_app_for_public_platform.md b/docs/configurations/config_web_app_for_public_platform.md index 308fb8fd9d..09bef71ac2 100644 --- a/docs/configurations/config_web_app_for_public_platform.md +++ b/docs/configurations/config_web_app_for_public_platform.md @@ -27,7 +27,8 @@ in [config.sample.json](https://github.com/linagora/twake-on-matrix/blob/main/co "app_grid_dashboard_available": true, "homeserver": "https://example.com/", "platform": "platform" - "default_max_upload_avatar_size_in_bytes": 1000000 + "default_max_upload_avatar_size_in_bytes": 1000000, + "dev_mode": false } ``` @@ -45,5 +46,6 @@ in [config.sample.json](https://github.com/linagora/twake-on-matrix/blob/main/co - `homeserver`: Homeserver - `platform`: Platform, `saas` for the case of public platform - `default_max_upload_avatar_size_in_bytes`: Default max upload avatar size +- `dev_mode`: Enable to run app in IDE If you want to disable it, please change the value or remove this from `config.sample.json` \ No newline at end of file