Skip to content

Commit 32c10c2

Browse files
committed
refactor: UI Improvements And Archived Bookmarks Fetching
Refactoring UI for Accounts, and Bookmarks Pages: - Bookmarks will display details (`archived`, `shared`, and `unread`). - Accounts will display information (`TLS`, and sharing). Archived bookmarks are now fetched from `/api/bookmarks/archived/` endpoint. Linting fixes.
1 parent 7404e3b commit 32c10c2

File tree

10 files changed

+235
-102
lines changed

10 files changed

+235
-102
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,9 @@ Potential improvements:
6565
- [Performance] Check performance with high amount of bookmarks spread across multiple instances.
6666
- [Application] Refactor codebase to be more organized.
6767
- [Application] Allow user-provided TLS certificate.
68-
- [UI] Indicators for `archived`, `unread`, `shared` bookmarks.
69-
- [UI] Display account information in accounts page.
7068
- [Distribution] Flatpack release.
7169
- [Distribution] compiled binary in GitHub release.
7270
- [UI] Sort bookmarks.
73-
- [UI] Improve `Accounts` page view.
7471

7572
Things to consider:
7673

i18n/en/cosmicding.ftl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ no-bookmarks = No bookmarks
4040
no-bookmarks-found-for-account = No bookmarks found for account {$acc}
4141
notes = Notes
4242
open-accounts-page = Open Accounts Page
43+
open-instance = Open instance
4344
provided-url-is-not-valid = Provided URL is not valid
4445
quit = Quit
4546
refresh = Refresh
@@ -59,10 +60,12 @@ shared = Shared
5960
shared-disabled = Shared (Disabled)
6061
successful = successful
6162
tags = Tags
62-
tags-helper = Enter any number of tags separated by space.
63+
tags-subtext = Enter any number of tags separated by space.
6364
theme = Theme
6465
title = Title
6566
tls = TLS
67+
tls-disabled = TLS disabled
68+
tls-enabled = TLS enabled
6669
token = Token
6770
unexpected-http-return-code = Unexpected HTTP return code {$http_rc}
6871
unread = Unread

res/screenshots/accounts.png

33.7 KB
Loading

res/screenshots/bookmarks.png

-14.6 KB
Loading

src/app.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl Application for Cosmicding {
276276
let nav_page = self.nav.data::<NavPage>(entity).unwrap_or_default();
277277

278278
widget::column::with_children(vec![
279-
(widget::toaster(&self.toasts, widget::horizontal_space()).into()),
279+
widget::toaster(&self.toasts, widget::horizontal_space()),
280280
nav_page.view(self),
281281
])
282282
.padding([
@@ -368,7 +368,7 @@ impl Application for Cosmicding {
368368
}
369369
Message::OpenAccountsPage => {
370370
let account_page_entity = &self.nav.entity_at(0);
371-
_ = self.nav.activate(account_page_entity.unwrap());
371+
self.nav.activate(account_page_entity.unwrap());
372372
}
373373

374374
Message::ToggleContextPage(context_page) => {
@@ -541,7 +541,7 @@ impl Application for Cosmicding {
541541
db::SqliteDatabase::cache_bookmarks_for_acount(
542542
&mut self.db,
543543
&response.account,
544-
response.bookmarks.unwrap_or_else(|| Vec::new()),
544+
response.bookmarks.unwrap_or_else(Vec::new),
545545
response.timestamp,
546546
response.successful,
547547
)
@@ -583,7 +583,7 @@ impl Application for Cosmicding {
583583
db::SqliteDatabase::cache_bookmarks_for_acount(
584584
&mut self.db,
585585
&account,
586-
response.bookmarks.unwrap_or_else(|| Vec::new()),
586+
response.bookmarks.unwrap_or_else(Vec::new),
587587
response.timestamp,
588588
response.successful,
589589
)
@@ -604,7 +604,7 @@ impl Application for Cosmicding {
604604
commands.push(Task::perform(http::fetch_account_details(account), message));
605605
}
606606
Message::DoneRefreshAccountProfile(mut account, account_details) => {
607-
if !account_details.is_none() {
607+
if account_details.is_some() {
608608
let details = account_details.unwrap();
609609
account.enable_sharing = details.enable_sharing;
610610
account.enable_public_sharing = details.enable_public_sharing;
@@ -857,13 +857,13 @@ impl Application for Cosmicding {
857857
self.config = config;
858858
}
859859
Message::OpenRemoveAccountDialog(account) => {
860-
if !self.dialog_pages.pop_front().is_some() {
860+
if self.dialog_pages.pop_front().is_none() {
861861
self.dialog_pages
862862
.push_back(DialogPage::RemoveAccount(account));
863863
}
864864
}
865865
Message::OpenRemoveBookmarkDialog(account, bookmark) => {
866-
if !self.dialog_pages.pop_front().is_some() {
866+
if self.dialog_pages.pop_front().is_none() {
867867
self.dialog_pages
868868
.push_back(DialogPage::RemoveBookmark(account, bookmark));
869869
}
@@ -903,7 +903,7 @@ impl Application for Cosmicding {
903903
tokio::time::sleep(Duration::from_secs(1)).await;
904904
crate::app::Message::StartRefreshBookmarksForAllAccounts
905905
},
906-
|msg| cosmic::app::Message::App(msg),
906+
cosmic::app::Message::App,
907907
));
908908
self.startup_completed = true;
909909
}

src/db/mod.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl SqliteDatabase {
7474
enable_public_sharing: row.get("enable_public_sharing"),
7575
})
7676
.collect();
77-
return data;
77+
data
7878
}
7979
pub async fn delete_account(&mut self, account: &Account) {
8080
let bookmarks_query: &str = "DELETE FROM UserAccounts WHERE id = $1;";
@@ -87,13 +87,13 @@ impl SqliteDatabase {
8787
pub async fn update_account(&mut self, account: &Account) {
8888
let query: &str = "UPDATE UserAccounts SET display_name=$2, instance=$3, api_token=$4, tls=$5, enable_sharing=$6, enable_public_sharing=$7 WHERE id=$1;";
8989
sqlx::query(query)
90-
.bind(&account.id)
90+
.bind(account.id)
9191
.bind(&account.display_name)
9292
.bind(&account.instance)
9393
.bind(&account.api_token)
94-
.bind(&account.tls)
95-
.bind(&account.enable_sharing)
96-
.bind(&account.enable_public_sharing)
94+
.bind(account.tls)
95+
.bind(account.enable_sharing)
96+
.bind(account.enable_public_sharing)
9797
.execute(&mut self.conn)
9898
.await
9999
.unwrap();
@@ -104,9 +104,9 @@ impl SqliteDatabase {
104104
.bind(&account.display_name)
105105
.bind(&account.instance)
106106
.bind(&account.api_token)
107-
.bind(&account.tls)
108-
.bind(&account.enable_sharing)
109-
.bind(&account.enable_public_sharing)
107+
.bind(account.tls)
108+
.bind(account.enable_sharing)
109+
.bind(account.enable_public_sharing)
110110
.execute(&mut self.conn)
111111
.await
112112
.unwrap();
@@ -185,19 +185,19 @@ impl SqliteDatabase {
185185
website_description)
186186
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17);"#;
187187
sqlx::query(query)
188-
.bind(&bookmark.user_account_id)
189-
.bind(&bookmark.linkding_internal_id)
188+
.bind(bookmark.user_account_id)
189+
.bind(bookmark.linkding_internal_id)
190190
.bind(&bookmark.url)
191191
.bind(&bookmark.title)
192192
.bind(&bookmark.description)
193193
.bind(&bookmark.notes)
194194
.bind(&bookmark.web_archive_snapshot_url)
195195
.bind(&bookmark.favicon_url)
196196
.bind(&bookmark.preview_image_url)
197-
.bind(&bookmark.is_archived)
198-
.bind(&bookmark.unread)
199-
.bind(&bookmark.shared)
200-
.bind(&bookmark.tag_names.join(" "))
197+
.bind(bookmark.is_archived)
198+
.bind(bookmark.unread)
199+
.bind(bookmark.shared)
200+
.bind(bookmark.tag_names.join(" "))
201201
.bind(&bookmark.date_added)
202202
.bind(&bookmark.date_modified)
203203
.bind(&bookmark.website_title)
@@ -243,7 +243,7 @@ impl SqliteDatabase {
243243
}
244244
})
245245
.collect();
246-
return data;
246+
data
247247
}
248248
pub async fn update_bookmark(&mut self, old_bookmark: &Bookmark, new_bookmark: &Bookmark) {
249249
let query: &str = r#"
@@ -272,31 +272,31 @@ impl SqliteDatabase {
272272
.bind(&new_bookmark.web_archive_snapshot_url)
273273
.bind(&new_bookmark.favicon_url)
274274
.bind(&new_bookmark.preview_image_url)
275-
.bind(&new_bookmark.is_archived)
276-
.bind(&new_bookmark.unread)
277-
.bind(&new_bookmark.shared)
278-
.bind(&new_bookmark.tag_names.join(" "))
275+
.bind(new_bookmark.is_archived)
276+
.bind(new_bookmark.unread)
277+
.bind(new_bookmark.shared)
278+
.bind(new_bookmark.tag_names.join(" "))
279279
.bind(&new_bookmark.date_added)
280280
.bind(&new_bookmark.date_modified)
281281
.bind(&new_bookmark.website_title)
282282
.bind(&new_bookmark.website_description)
283-
.bind(&old_bookmark.id)
283+
.bind(old_bookmark.id)
284284
.execute(&mut self.conn)
285285
.await
286286
.unwrap();
287287
}
288288
pub async fn delete_all_bookmarks_of_account(&mut self, account: &Account) {
289289
let query: &str = "DELETE FROM Bookmarks WHERE user_account_id = $1;";
290290
sqlx::query(query)
291-
.bind(&account.id)
291+
.bind(account.id)
292292
.execute(&mut self.conn)
293293
.await
294294
.unwrap();
295295
}
296296
pub async fn delete_bookmark(&mut self, bookmark: &Bookmark) {
297297
let query: &str = "DELETE FROM Bookmarks WHERE id = $1;";
298298
sqlx::query(query)
299-
.bind(&bookmark.id)
299+
.bind(bookmark.id)
300300
.execute(&mut self.conn)
301301
.await
302302
.unwrap();
@@ -353,6 +353,6 @@ impl SqliteDatabase {
353353
}
354354
})
355355
.collect();
356-
return data;
356+
data
357357
}
358358
}

0 commit comments

Comments
 (0)