Handle existing urls

This commit is contained in:
Juan Gilsanz Polo
2024-07-18 19:34:48 +02:00
parent 8dacc0f4d4
commit 0a1eb60903
7 changed files with 41 additions and 7 deletions

View File

@@ -16,6 +16,7 @@ class BookmarkFormModel {
final TextEditingController notesController;
int? editBookmarkId;
bool share;
bool bookmarkExists = false;
BookmarkFormModel({
required this.urlController,

View File

@@ -92,8 +92,18 @@ class BookmarkForm extends _$BookmarkForm {
}
final result = await ref.read(checkBookmarkProvider(state.urlController.text).future);
if (result.successful == true) {
state.titleController.text = result.content?.metadata?.title ?? "";
state.descriptionController.text = result.content?.metadata?.description ?? "";
if (result.content?.bookmark != null) {
state.titleController.text = result.content?.bookmark?.title ?? "";
state.descriptionController.text = result.content?.metadata?.description ?? "";
state.tags = result.content?.bookmark?.tagNames ?? [];
state.notesController.text = result.content?.bookmark?.notes ?? "";
state.markAsUnread = result.content?.bookmark?.unread ?? false;
state.share = result.content?.bookmark?.shared ?? false;
state.bookmarkExists = true;
} else {
state.titleController.text = result.content?.metadata?.title ?? "";
state.descriptionController.text = result.content?.metadata?.description ?? "";
}
state.bookmarkValid = true;
state.checkBookmarkLoadStatus = LoadStatus.loaded;
} else {

View File

@@ -248,6 +248,20 @@ class _ModalContent extends ConsumerWidget {
),
),
),
if (provider.bookmarkExists == true)
Card(
margin: const EdgeInsets.all(16),
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
const Icon(Icons.info_rounded),
const SizedBox(width: 16),
Flexible(child: Text(t.bookmarks.addBookmark.urlAlreadyBookmarked)),
],
),
),
),
SectionLabel(
label: t.bookmarks.addBookmark.bookmarkDetails,
padding: const EdgeInsets.symmetric(