From d0e1b4518b404f9ba41d29a63e86951e9bbc7266 Mon Sep 17 00:00:00 2001 From: TaYaKi71751 Date: Sat, 5 Oct 2024 17:34:16 +0900 Subject: [PATCH] Try jsonDecode in try/catch Fix #552 --- .../pages/settings/login/ehentai_login.dart | 8 ++-- violet/lib/pages/settings/settings_page.dart | 44 ++++++++++--------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/violet/lib/pages/settings/login/ehentai_login.dart b/violet/lib/pages/settings/login/ehentai_login.dart index 581130d7d..c38416968 100644 --- a/violet/lib/pages/settings/login/ehentai_login.dart +++ b/violet/lib/pages/settings/login/ehentai_login.dart @@ -62,9 +62,11 @@ class _LoginScreenState extends State { Future _checkCookie() async { final controller = await _webViewController.future; - final cookieString = jsonDecode( - await controller.runJavascriptReturningResult('document.cookie')) - as String; + var cookieString = + await controller.runJavascriptReturningResult('document.cookie'); + try { + cookieString = jsonDecode(cookieString) as String; + } catch (e) {} final cookies = parseCookies(cookieString); developer.log('Get cookies: $cookies'); diff --git a/violet/lib/pages/settings/settings_page.dart b/violet/lib/pages/settings/settings_page.dart index 1350da41e..e8e848fd3 100644 --- a/violet/lib/pages/settings/settings_page.dart +++ b/violet/lib/pages/settings/settings_page.dart @@ -872,27 +872,29 @@ class _SettingsPageState extends State actions: [okButton, cancelButton], title: const Text('E-Hentai Categories'), contentPadding: const EdgeInsets.fromLTRB(12, 8, 12, 8), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const Text('f_cats: '), - ...[ - TextField( - controller: catsController, - readOnly: true, - ), - doujinshiButton, - mangaButton, - artistcgButton, - gamecgButton, - westernButton, - nonhButton, - imagesetButton, - cosplayButton, - asianpornButton, - miscButton, - ].map((e) => Row(children: [Expanded(child: e)])), - ], + content: new SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('f_cats: '), + ...[ + TextField( + controller: catsController, + readOnly: true, + ), + doujinshiButton, + mangaButton, + artistcgButton, + gamecgButton, + westernButton, + nonhButton, + imagesetButton, + cosplayButton, + asianpornButton, + miscButton, + ].map((e) => Row(children: [Expanded(child: e)])), + ], + ), ), ), );