mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
feat: added dialogs for favorite view
This commit is contained in:
@@ -3,26 +3,49 @@ 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 () =>
|
||||
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 () => {
|
||||
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])
|
||||
? 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`);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user