Skip to content

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

feat: added color toast

alihamuhce6fec10bff5
diff --git a/apps/web/src/common/toasts.js b/apps/web/src/common/toasts.js
index 53a2731d5..700aa8db2 100644
--- a/apps/web/src/common/toasts.js
+++ b/apps/web/src/common/toasts.js
@@ -26,4 +26,22 @@ function showNotesMovedToast(note, noteIds, notebook) {
showToast("success", messageText, actions);
}
-export { showNotesMovedToast };
+function showNoteDeleted(note) {
+ const undoAction = async () => {
+ await db.trash.restore(note);
+ };
+
+ let actions = [{ text: "Undo", onClick: undoAction }];
+
+ showToast("success", "Note Deleted", actions);
+}
+
+function showNoteColored(colors, label) {
+ if (colors.includes(label)) {
+ showToast("success", "Untagged as " + label);
+ } else {
+ showToast("success", "Tagged as " + label);
+ }
+}
+
+export { showNotesMovedToast, showNoteDeleted, showNoteColored };
diff --git a/apps/web/src/components/menu/colors.js b/apps/web/src/components/menu/colors.js
index bf3729848..22013ff9b 100644
--- a/apps/web/src/components/menu/colors.js
+++ b/apps/web/src/components/menu/colors.js
@@ -4,6 +4,7 @@ import * as Icon from "../icons/index";
import { objectMap } from "../../utils/object";
import { useStore } from "../../stores/note-store";
import { Flex } from "rebass";
+import { showNoteColored } from "../../common/toasts";
function Colors(props) {
const { id, colors } = props.data;
@@ -14,7 +15,10 @@ function Colors(props) {
{objectMap(COLORS, (label, code) => (
<Flex
sx={{ position: "relative" }}
- onClick={() => setColor(id, label)}
+ onClick={() => {
+ setColor(id, label);
+ showNoteColored(colors, label);
+ }}
key={label}
>
<Icon.Circle
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index 1aaa18ce1..d25fb5734 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -13,6 +13,7 @@ import { useTheme } from "emotion-theming";
import Colors from "../menu/colors";
import { showExportDialog } from "../dialogs/exportdialog";
import { setHashParam } from "../../utils/useHashParam";
+import { showNoteDeleted } from "../../common/toasts";
function menuItems(note, context) {
return [
@@ -91,7 +92,7 @@ function menuItems(note, context) {
"Are you sure you want to delete this note?"
).then(async (res) => {
if (res) {
- await store.delete(note.id);
+ await store.delete(note.id).then(showNoteDeleted(note.id));
}
});
},
diff --git a/apps/web/src/stores/trash-store.js b/apps/web/src/stores/trash-store.js
index 97740c30e..325ecb4ec 100644
--- a/apps/web/src/stores/trash-store.js
+++ b/apps/web/src/stores/trash-store.js
@@ -6,12 +6,12 @@ class TrashStore extends BaseStore {
trash = [];
refresh = () => {
- this.set(state => (state.trash = db.trash.all));
+ this.set((state) => (state.trash = db.trash.all));
};
delete = (id, index) => {
return db.trash.delete(id).then(() => {
- this.set(state => {
+ this.set((state) => {
state.trash.splice(index, 1);
});
});
@@ -19,13 +19,13 @@ class TrashStore extends BaseStore {
restore = (id, index) => {
return db.trash.restore(id).then(() => {
- this.set(state => state.trash.splice(index, 1));
+ this.set((state) => state.trash.splice(index, 1));
});
};
clear = () => {
return db.trash.clear().then(() => {
- this.set(state => (state.trash = []));
+ this.set((state) => (state.trash = []));
});
};
}