mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +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 * as Icon from "react-feather";
|
||||||
import ListItem from "../components/listview";
|
import ListItem from "../components/listview";
|
||||||
import { showSnack } from "../components/snackbar";
|
import { showSnack } from "../components/snackbar";
|
||||||
|
import { ask } from "../components/dialogs";
|
||||||
const dropdownRefs = [];
|
const dropdownRefs = [];
|
||||||
const menuItems = item => [
|
const menuItems = item => [
|
||||||
{
|
{
|
||||||
title: "Unfavorite",
|
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(() => {
|
db.favoriteItem(item.type, item.dateCreated).then(() => {
|
||||||
let itemType = item.type[0] + item.type.substring(1);
|
let itemType = item.type[0] + item.type.substring(1);
|
||||||
showSnack(itemType + " Unfavorited!", Icon.Check);
|
showSnack(itemType + " Unfavorited!", Icon.Check);
|
||||||
ev.emit(`refreshFavorites`);
|
ev.emit(`refreshFavorites`);
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Delete",
|
title: "Delete",
|
||||||
color: "red",
|
color: "red",
|
||||||
onClick: async () => {
|
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"
|
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(() => {
|
: db.deleteNotebooks([item]).then(() => {
|
||||||
let itemType = item.type[0] + item.type.substring(1);
|
let itemType = item.type[0] + item.type.substring(1);
|
||||||
showSnack(itemType + " Deleted!", Icon.Trash);
|
showSnack(itemType + " Deleted!", Icon.Trash);
|
||||||
|
ev.emit(`refreshFavorites`);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user