This commit is contained in:
kodjomoustapha 2024-11-12 09:15:11 +01:00
parent af6c409e26
commit f3597d7023
4 changed files with 35 additions and 40 deletions

View file

@ -173,7 +173,7 @@ class _MangaWebViewState extends ConsumerState<MangaWebView> {
final ua = await controller.evaluateJavascript(
source: "navigator.userAgent") ??
"";
await MClient.setCookie(url.toString(), ua);
await MClient.setCookie(url.toString(), ua, controller);
final canGoback = await controller.canGoBack();
final canGoForward = await controller.canGoForward();
final title = await controller.getTitle();

View file

@ -8,7 +8,6 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'
as flutter_inappwebview;
import 'package:mangayomi/models/settings.dart';
import 'package:http/io_client.dart';
import 'package:mangayomi/utils/extensions/string_extensions.dart';
import 'package:mangayomi/utils/log/log.dart';
import 'package:mangayomi/services/http/rhttp/rhttp.dart' as rhttp;
@ -66,21 +65,17 @@ class MClient {
return {HttpHeaders.cookieHeader: cookies};
}
static Future<void> setCookie(String url, String ua, {String? cookie}) async {
static Future<void> setCookie(String url, String ua,
flutter_inappwebview.InAppWebViewController webViewController,
{String? cookie}) async {
List<String> cookies = [];
final cookieList = (await flutter_inappwebview.CookieManager.instance(
webViewEnvironment: webViewEnvironment)
.getCookies(url: flutter_inappwebview.WebUri(url)));
if (Platform.isWindows) {
cookies = cookieList
.where((e) =>
((e.domain ?? "").substringAfter(".") == Uri.parse(url).host))
.map((e) => "${e.name}=${e.value}")
.toList();
} else {
cookies = cookieList.map((e) => "${e.name}=${e.value}").toList();
}
cookies = (await flutter_inappwebview.CookieManager.instance(
webViewEnvironment: webViewEnvironment)
.getCookies(
url: flutter_inappwebview.WebUri(url),
webViewController: webViewController))
.map((e) => "${e.name}=${e.value}")
.toList();
if (cookies.isNotEmpty) {
final host = Uri.parse(url).host;
final newCookie = cookies.join("; ");

View file

@ -479,8 +479,8 @@ packages:
dependency: "direct main"
description:
path: flutter_inappwebview
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
resolved-ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
resolved-ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
url: "https://github.com/pichillilorenzo/flutter_inappwebview.git"
source: git
version: "6.2.0-beta.2"
@ -488,8 +488,8 @@ packages:
dependency: "direct overridden"
description:
path: flutter_inappwebview_android
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
resolved-ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
resolved-ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
url: "https://github.com/pichillilorenzo/flutter_inappwebview.git"
source: git
version: "1.2.0-beta.2"
@ -497,8 +497,8 @@ packages:
dependency: transitive
description:
path: "dev_packages/flutter_inappwebview_internal_annotations"
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
resolved-ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
resolved-ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
url: "https://github.com/pichillilorenzo/flutter_inappwebview.git"
source: git
version: "1.2.0"
@ -506,8 +506,8 @@ packages:
dependency: "direct overridden"
description:
path: flutter_inappwebview_ios
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
resolved-ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
resolved-ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
url: "https://github.com/pichillilorenzo/flutter_inappwebview.git"
source: git
version: "1.2.0-beta.2"
@ -515,8 +515,8 @@ packages:
dependency: "direct overridden"
description:
path: flutter_inappwebview_macos
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
resolved-ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
resolved-ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
url: "https://github.com/pichillilorenzo/flutter_inappwebview.git"
source: git
version: "1.2.0-beta.2"
@ -524,8 +524,8 @@ packages:
dependency: "direct overridden"
description:
path: flutter_inappwebview_platform_interface
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
resolved-ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
resolved-ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
url: "https://github.com/pichillilorenzo/flutter_inappwebview.git"
source: git
version: "1.4.0-beta.2"
@ -533,8 +533,8 @@ packages:
dependency: transitive
description:
path: flutter_inappwebview_web
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
resolved-ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
resolved-ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
url: "https://github.com/pichillilorenzo/flutter_inappwebview.git"
source: git
version: "1.2.0-beta.2"
@ -542,9 +542,9 @@ packages:
dependency: "direct overridden"
description:
path: flutter_inappwebview_windows
ref: fix_windows_get_cookies
resolved-ref: "22dfdc54d26001a739030ca261284837ef7e923f"
url: "https://github.com/kodjodevf/flutter_inappwebview.git"
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
resolved-ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
url: "https://github.com/pichillilorenzo/flutter_inappwebview.git"
source: git
version: "0.7.0-beta.2"
flutter_launcher_icons:

View file

@ -95,34 +95,34 @@ dependency_overrides:
flutter_inappwebview_windows:
git:
url: https://github.com/kodjodevf/flutter_inappwebview.git
url: https://github.com/pichillilorenzo/flutter_inappwebview.git
path: flutter_inappwebview_windows
ref: fix_windows_get_cookies
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
flutter_inappwebview_android:
git:
url: https://github.com/pichillilorenzo/flutter_inappwebview.git
path: flutter_inappwebview_android
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
flutter_inappwebview_ios:
git:
url: https://github.com/pichillilorenzo/flutter_inappwebview.git
path: flutter_inappwebview_ios
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
flutter_inappwebview_macos:
git:
url: https://github.com/pichillilorenzo/flutter_inappwebview.git
path: flutter_inappwebview_macos
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
flutter_inappwebview_platform_interface:
git:
url: https://github.com/pichillilorenzo/flutter_inappwebview.git
path: flutter_inappwebview_platform_interface
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
flutter_inappwebview:
git:
url: https://github.com/pichillilorenzo/flutter_inappwebview.git
path: flutter_inappwebview
ref: abf95722cb8d6df66c07e4feebac9e6154706d4f
ref: fe5949f7fa8478943e98e748b19152a9fdc36be4
dev_dependencies:
flutter_test: