diff --git a/apps/web/package.json b/apps/web/package.json index 8cc78d474..7a4a7b633 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -11,7 +11,7 @@ "@mdi/react": "^1.4.0", "@notesnook/desktop": "file:desktop", "@rebass/forms": "^4.0.6", - "@streetwritersco/tinymce-plugins": "^1.4.11", + "@streetwritersco/tinymce-plugins": "^1.4.14", "@tinymce/tinymce-react": "^3.13.0", "async-mutex": "^0.3.2", "axios": "^0.21.4", diff --git a/apps/web/src/common/list-profiles.js b/apps/web/src/common/list-profiles.js index ff63ee793..40ef694e0 100644 --- a/apps/web/src/common/list-profiles.js +++ b/apps/web/src/common/list-profiles.js @@ -25,6 +25,7 @@ const NotesProfile = createProfile( item={item} tags={getTags(item)} notebook={getNotebook(item.notebooks, context?.type)} + attachments={getAttachmentsCount(item.id)} context={context} /> ), @@ -107,3 +108,7 @@ function getNotebook(notebooks, contextType) { topic: { id: topicId, title: topic.title }, }; } + +function getAttachmentsCount(noteId) { + return db.attachments.ofNote(noteId, "all").length; +} diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js index 9c8bc261d..8d1b4aa1f 100644 --- a/apps/web/src/components/note/index.js +++ b/apps/web/src/components/note/index.js @@ -1,5 +1,5 @@ import React, { useMemo } from "react"; -import { Button, Flex } from "rebass"; +import { Button, Flex, Text } from "rebass"; import * as Icon from "../icons"; import TimeAgo from "../time-ago"; import ListItem from "../list-item"; @@ -17,7 +17,7 @@ import Vault from "../../common/vault"; import IconTag from "../icon-tag"; function Note(props) { - const { tags, notebook, item, index, context } = props; + const { tags, notebook, item, index, context, attachments } = props; const note = item; const isOpened = useStore((store) => store.selectedNote === note.id); const isCompact = useStore((store) => store.viewMode === "compact"); @@ -110,6 +110,13 @@ function Note(props) { mr={1} /> + {attachments > 0 && ( + + + {attachments} + + )} + {note.pinned && !props.context && ( )} @@ -170,6 +177,7 @@ export default React.memo(Note, function (prevProps, nextProps) { prevItem.locked === nextItem.locked && prevItem.conflicted === nextItem.conflicted && prevItem.color === nextItem.color && + prevProps.attachments === nextProps.attachments && prevProps.notebook?.dateEdited === nextProps.notebook?.dateEdited && JSON.stringify(prevProps.tags) === JSON.stringify(nextProps.tags) ); diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.js index 364808722..17688ce84 100644 --- a/apps/web/src/stores/editor-store.js +++ b/apps/web/src/stores/editor-store.js @@ -186,12 +186,12 @@ class EditorStore extends BaseStore { noteStore.setSelectedNote(id); } + const attachments = db.attachments.ofNote(note.id, "all"); this.set((state) => { state.session.id = note.id; state.session.isSaving = false; state.session.notebooks = note.notebooks; - state.session.attachments = - db.attachments.ofNote(note.id, "all") || []; + state.session.attachments = attachments; }); if (!oldSession) { @@ -200,6 +200,7 @@ class EditorStore extends BaseStore { } if ( + attachments?.length !== oldSession.attachments.length || note.headline !== oldSession.headline || note.title !== oldSession.title )