Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: added dialogs for favorite view

alihamuh2f0894eb9581
diff --git a/apps/web/src/views/Favorites.js b/apps/web/src/views/Favorites.js
index 63719fe3e..e87971435 100644
--- a/apps/web/src/views/Favorites.js
+++ b/apps/web/src/views/Favorites.js
@@ -3,27 +3,50 @@ import { db, ev } from "../common";
import * as Icon from "react-feather";
import ListItem from "../components/listview";
import { showSnack } from "../components/snackbar";
+import { ask } from "../components/dialogs";
const dropdownRefs = [];
const menuItems = item => [
{
title: "Unfavorite",
- onClick: async () =>
- db.favoriteItem(item.type, item.dateCreated).then(() => {
- let itemType = item.type[0] + item.type.substring(1);
- showSnack(itemType + " Unfavorited!", Icon.Check);
- ev.emit(`refreshFavorites`);
- })
+ onClick: async () => {
+ ask(
+ Icon.Star,
+ "Unfavorite",
+ "Are you sure you want to remove this item from favorites?"
+ ).then(res => {
+ if (res) {
+ db.favoriteItem(item.type, item.dateCreated).then(() => {
+ let itemType = item.type[0] + item.type.substring(1);
+ showSnack(itemType + " Unfavorited!", Icon.Check);
+ ev.emit(`refreshFavorites`);
+ });
+ }
+ });
+ }
},
{
title: "Delete",
color: "red",
onClick: async () => {
- item.type == "note"
- ? db.deleteNotes([item])
- : db.deleteNotebooks([item]).then(() => {
- let itemType = item.type[0] + item.type.substring(1);
- showSnack(itemType + " Deleted!", Icon.Trash);
- });
+ ask(
+ Icon.Trash2,
+ "Delete",
+ "Are you sure you want to delete this note? It will be moved to trash and permanently deleted after 7 days."
+ ).then(res => {
+ if (res) {
+ item.type == "note"
+ ? db.deleteNotes([item]).then(() => {
+ let itemType = item.type[0] + item.type.substring(1);
+ showSnack(itemType + " Deleted!", Icon.Trash);
+ ev.emit(`refreshFavorites`);
+ })
+ : db.deleteNotebooks([item]).then(() => {
+ let itemType = item.type[0] + item.type.substring(1);
+ showSnack(itemType + " Deleted!", Icon.Trash);
+ ev.emit(`refreshFavorites`);
+ });
+ }
+ });
}
}
];