Skip to content

Commit

Permalink
Try jsonDecode in try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
TaYaKi71751 committed Oct 6, 2024
1 parent 54162b8 commit d0e1b45
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
8 changes: 5 additions & 3 deletions violet/lib/pages/settings/login/ehentai_login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ class _LoginScreenState extends State<LoginScreen> {

Future<void> _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');

Expand Down
44 changes: 23 additions & 21 deletions violet/lib/pages/settings/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -872,27 +872,29 @@ class _SettingsPageState extends State<SettingsPage>
actions: [okButton, cancelButton],
title: const Text('E-Hentai Categories'),
contentPadding: const EdgeInsets.fromLTRB(12, 8, 12, 8),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
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: <Widget>[
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)])),
],
),
),
),
);
Expand Down

0 comments on commit d0e1b45

Please sign in to comment.