Bug fixes
This commit is contained in:
@@ -62,14 +62,20 @@ class BookmarkForm extends _$BookmarkForm {
|
||||
}
|
||||
|
||||
void initializeProviderUrl(String url) {
|
||||
final decoded = Uri.decodeComponent(url);
|
||||
var value = decoded.contains(":~:text=") ? decoded.split(":~:text=")[1] : null;
|
||||
state.urlController.text = value ?? decoded;
|
||||
if (Regexps.urlWithoutProtocol.hasMatch(value ?? decoded)) {
|
||||
state.urlError = null;
|
||||
checkUrlDetails(updateState: false);
|
||||
} else {
|
||||
try {
|
||||
final decoded = Uri.decodeComponent(url);
|
||||
var value = decoded.contains(":~:text=") ? decoded.split(":~:text=")[1] : null;
|
||||
state.urlController.text = value ?? decoded;
|
||||
if (Regexps.urlWithoutProtocol.hasMatch(value ?? decoded)) {
|
||||
state.urlError = null;
|
||||
checkUrlDetails(updateState: false);
|
||||
} else {
|
||||
state.urlError = t.bookmarks.addBookmark.invalidUrl;
|
||||
}
|
||||
} catch (e) {
|
||||
state.urlController.text = url;
|
||||
state.urlError = t.bookmarks.addBookmark.invalidUrl;
|
||||
ref.notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:linkdy/screens/webview/ui/webview.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/common_functions.dart';
|
||||
import 'package:linkdy/screens/bookmarks/model/bookmarks.model.dart';
|
||||
import 'package:linkdy/screens/webview/ui/invalid_bookmark.dart';
|
||||
|
||||
import 'package:linkdy/config/sizes.dart';
|
||||
import 'package:linkdy/constants/global_keys.dart';
|
||||
@@ -33,7 +34,7 @@ FutureOr<void> bookmarksRequest(
|
||||
sort: "${type == SortingType.title ? "title" : "added"}_${way == SortingWay.ascendant ? "asc" : "desc"}",
|
||||
);
|
||||
|
||||
if (result.successful == true) {
|
||||
if (result.successful == true && result.content?.results != null && result.content?.count != null) {
|
||||
ref.read(bookmarksProvider).bookmarks = result.content!.results!;
|
||||
ref.read(bookmarksProvider).maxNumber = result.content!.count!;
|
||||
ref.read(bookmarksProvider).currentPage = 0;
|
||||
@@ -89,10 +90,20 @@ class Bookmarks extends _$Bookmarks {
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: _webViewRoute,
|
||||
pageBuilder: (context, state) => CustomTransitionPage(
|
||||
child: WebViewScreen(bookmark: state.extra as Bookmark),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) => child,
|
||||
),
|
||||
pageBuilder: (context, state) {
|
||||
final extra = state.extra;
|
||||
if (extra is Bookmark) {
|
||||
return CustomTransitionPage(
|
||||
child: WebViewScreen(bookmark: extra),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) => child,
|
||||
);
|
||||
} else {
|
||||
return CustomTransitionPage(
|
||||
child: const InvalidBookmarkScreen(),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) => child,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:linkdy/screens/webview/ui/webview.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/common_functions.dart';
|
||||
import 'package:linkdy/screens/bookmarks/model/search_bookmarks.model.dart';
|
||||
import 'package:linkdy/screens/webview/ui/invalid_bookmark.dart';
|
||||
|
||||
import 'package:linkdy/config/sizes.dart';
|
||||
import 'package:linkdy/providers/app_status.provider.dart';
|
||||
@@ -30,7 +31,6 @@ FutureOr<void> fetchSearchBookmarks(FetchSearchBookmarksRef ref, int limit) asyn
|
||||
);
|
||||
|
||||
if (result.successful == true) {
|
||||
// ref.read(faviconStoreProvider.notifier).loadFavicons(result.content!.results!);
|
||||
ref.read(searchBookmarksProvider).bookmarks = result.content!.results!;
|
||||
ref.read(searchBookmarksProvider).maxNumber = result.content!.count!;
|
||||
ref.read(searchBookmarksProvider).currentPage = 0;
|
||||
@@ -81,10 +81,20 @@ class SearchBookmarks extends _$SearchBookmarks {
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: _webViewRoute,
|
||||
pageBuilder: (context, state) => CustomTransitionPage(
|
||||
child: WebViewScreen(bookmark: state.extra as Bookmark),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) => child,
|
||||
),
|
||||
pageBuilder: (context, state) {
|
||||
final extra = state.extra;
|
||||
if (extra is Bookmark) {
|
||||
return CustomTransitionPage(
|
||||
child: WebViewScreen(bookmark: extra),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) => child,
|
||||
);
|
||||
} else {
|
||||
return CustomTransitionPage(
|
||||
child: const InvalidBookmarkScreen(),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) => child,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:linkdy/screens/webview/ui/webview.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/common_functions.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
|
||||
import 'package:linkdy/screens/filtered_bookmarks/model/filtered_bookmarks.model.dart';
|
||||
import 'package:linkdy/screens/webview/ui/invalid_bookmark.dart';
|
||||
|
||||
import 'package:linkdy/config/sizes.dart';
|
||||
import 'package:linkdy/constants/global_keys.dart';
|
||||
@@ -35,7 +36,6 @@ FutureOr<void> tagBookmarksRequest(TagBookmarksRequestRef ref, Tag? tag, String?
|
||||
);
|
||||
|
||||
if (bookmarksResult.successful == true) {
|
||||
// ref.read(faviconStoreProvider.notifier).loadFavicons(bookmarksResult.content!.results!);
|
||||
ref.read(filteredBookmarksProvider).bookmarks = bookmarksResult.content!.results!;
|
||||
ref.read(filteredBookmarksProvider).maxNumber = bookmarksResult.content!.count!;
|
||||
if (tag == null) ref.read(filteredBookmarksProvider).tag = tagResult!.content!;
|
||||
@@ -83,7 +83,6 @@ FutureOr<void> filteredBookmarksRequest(FilteredBookmarksRequestRef ref, Filtere
|
||||
);
|
||||
|
||||
if (bookmarksResult.successful == true) {
|
||||
// ref.read(faviconStoreProvider.notifier).loadFavicons(bookmarksResult.content!.results!);
|
||||
ref.read(filteredBookmarksProvider).bookmarks = bookmarksResult.content!.results!;
|
||||
ref.read(filteredBookmarksProvider).maxNumber = bookmarksResult.content!.count!;
|
||||
ref.read(filteredBookmarksProvider).currentPage = 0;
|
||||
@@ -115,7 +114,6 @@ FutureOr<void> filteredBookmarksRequestLoadMore(TagBookmarksRequestLoadMoreRef r
|
||||
);
|
||||
|
||||
if (result.successful == true) {
|
||||
// ref.read(faviconStoreProvider.notifier).loadFavicons(result.content!.results!);
|
||||
provider.bookmarks = [...provider.bookmarks, ...result.content!.results!];
|
||||
provider.maxNumber = result.content!.count!;
|
||||
provider.currentPage = provider.currentPage + 1;
|
||||
@@ -141,10 +139,20 @@ class FilteredBookmarks extends _$FilteredBookmarks {
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: _webViewRoute,
|
||||
pageBuilder: (context, state) => CustomTransitionPage(
|
||||
child: WebViewScreen(bookmark: state.extra as Bookmark),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) => child,
|
||||
),
|
||||
pageBuilder: (context, state) {
|
||||
final extra = state.extra;
|
||||
if (extra is Bookmark) {
|
||||
return CustomTransitionPage(
|
||||
child: WebViewScreen(bookmark: extra),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) => child,
|
||||
);
|
||||
} else {
|
||||
return CustomTransitionPage(
|
||||
child: const InvalidBookmarkScreen(),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) => child,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
18
lib/screens/webview/ui/invalid_bookmark.dart
Normal file
18
lib/screens/webview/ui/invalid_bookmark.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
|
||||
import 'package:linkdy/widgets/error_screen.dart';
|
||||
|
||||
class InvalidBookmarkScreen extends StatelessWidget {
|
||||
const InvalidBookmarkScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Center(
|
||||
child: ErrorScreen(error: t.webview.invalidBookmarkData),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user