Handle existing urls
This commit is contained in:
@@ -16,6 +16,7 @@ class BookmarkFormModel {
|
||||
final TextEditingController notesController;
|
||||
int? editBookmarkId;
|
||||
bool share;
|
||||
bool bookmarkExists = false;
|
||||
|
||||
BookmarkFormModel({
|
||||
required this.urlController,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user