feat: added dialogs for favorite view

This commit is contained in:
alihamuh
2020-01-07 16:42:27 +05:00
parent 2bd102c016
commit 2f0894eb95

View File

@@ -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`);
});
}
});
}
}