A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: add opened note indicator
thecodrrd6a7d2f20494
diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.jsindex 81b4d0cd6..9dc1e0264 100644--- a/apps/web/src/components/list-container/index.js+++ b/apps/web/src/components/list-container/index.js@@ -9,16 +9,24 @@ const ListContainer = props => {return (<Flex flexDirection="column" flex="1 1 auto"><Search placeholder="Search" />- <List- style={{- width: "100%",- flex: "1 1 auto",- height: "auto",- overflowX: "hidden"+ <Flex+ flexDirection="column"+ flex="1 1 auto"+ sx={{+ marginTop: 2}}- totalCount={props.itemsLength}- item={props.item}- />+ >+ <List+ style={{+ width: "100%",+ flex: "1 1 auto",+ height: "auto",+ overflowX: "hidden"+ }}+ totalCount={props.itemsLength}+ item={props.item}+ />+ </Flex>{props.button && (<ButtonIcon={props.button.icon || Icon.Plus}diff --git a/apps/web/src/components/list-item/index.js b/apps/web/src/components/list-item/index.jsindex 71b5b4247..89c112a71 100644--- a/apps/web/src/components/list-item/index.js+++ b/apps/web/src/components/list-item/index.js@@ -3,121 +3,126 @@ import { Flex, Box, Text } from "rebass";import * as Icon from "react-feather";import Dropdown, { DropdownTrigger, DropdownContent } from "../dropdown";import Menu from "../menu";+import { useStore } from "../../stores/note-store";-const ListItem = props => (- <Flex- alignItems="center"- justifyContent="space-between"- py={1}- bg={props.pinned ? "shade" : "background"}- px={2}- sx={{- position: "relative",- marginTop: props.pinned ? 4 : 0,- borderBottom: "1px solid",- borderBottomColor: "navbg",- cursor: "default",- ":hover": {- borderBottomColor: "primary",- cursor: "pointer"- }- //TODO add onpressed reaction- }}- >- {props.pinned && (- <Flex- bg="primary"- sx={{- borderRadius: 35,- width: 30,- height: 30,- position: "absolute",- top: -15,- left: 0,- marginTop: 5,- boxShadow: "2px 1px 3px #00000066"- }}- mx={2}- alignItems="center"- justifyContent="center"- >- <Box- bg="static"- sx={{- borderRadius: 5,- width: 5,- height: 5- }}- />- </Flex>- )}- <Box- onClick={() => {- //e.stopPropagation();- if (props.onClick) {- props.onClick();- }- }}+const ListItem = props => {+ const selectedNote = useStore(store => store.selectedNote);+ const isSelected = selectedNote === props.id;+ return (+ <Flex+ alignItems="center"+ justifyContent="space-between"+ py={1}+ bg={props.pinned || isSelected ? "shade" : "background"}+ px={2}sx={{- flex: "1 1 auto",- paddingTop: props.pinned ? 4 : 0,+ position: "relative",+ marginTop: props.pinned ? 4 : 0,+ borderBottom: "1px solid",+ borderBottomColor: "navbg",+ cursor: "default",":hover": {+ borderBottomColor: "primary",cursor: "pointer"}+ //TODO add onpressed reaction}}>- <Flex flexDirection="row" justifyContent="space-between">- <Text fontFamily={"heading"} fontSize="title" fontWeight={"bold"}>- {props.title}- </Text>- </Flex>- <Text- display={props.body ? "flex" : "none"}- variant="body"+ {props.pinned && (+ <Flex+ bg="primary"+ sx={{+ borderRadius: 35,+ width: 30,+ height: 30,+ position: "absolute",+ top: -15,+ left: 0,+ marginTop: 5,+ boxShadow: "2px 1px 3px #00000066"+ }}+ mx={2}+ alignItems="center"+ justifyContent="center"+ >+ <Box+ bg="static"+ sx={{+ borderRadius: 5,+ width: 5,+ height: 5+ }}+ />+ </Flex>+ )}+ <Box+ onClick={() => {+ //e.stopPropagation();+ if (props.onClick) {+ props.onClick();+ }+ }}sx={{- marginBottom: 1,+ flex: "1 1 auto",+ paddingTop: props.pinned ? 4 : 0,":hover": {cursor: "pointer"- },- flexWrap: "wrap"+ }}}>- {props.body}- </Text>- {props.subBody && props.subBody}- <Text- display={props.info ? "flex" : "none"}- variant="body"- fontSize={10}- color="fontTertiary"- >- {props.info}- </Text>- </Box>- {props.menuItems && props.dropdownRefs && (- <Dropdown- style={{ zIndex: 1, marginRight: -4 }}- ref={ref => (props.dropdownRefs[props.index] = ref)}- >- <DropdownTrigger>- <Text sx={{ ":active, :hover": { color: "primary" } }}>- <Icon.MoreVertical- size={24}- strokeWidth={1.5}- style={{ marginRight: -5 }}- />+ <Flex flexDirection="row" justifyContent="space-between">+ <Text fontFamily={"heading"} fontSize="title" fontWeight={"bold"}>+ {props.title}</Text>- </DropdownTrigger>- <DropdownContent style={{ zIndex: 2, marginLeft: -110 }}>- <Menu- dropdownRef={props.dropdownRefs[props.index]}- menuItems={props.menuItems}- data={props.menuData}- />- </DropdownContent>- </Dropdown>- )}- </Flex>-);+ </Flex>+ <Text+ display={props.body ? "flex" : "none"}+ variant="body"+ sx={{+ marginBottom: 1,+ ":hover": {+ cursor: "pointer"+ },+ flexWrap: "wrap"+ }}+ >+ {props.body}+ </Text>+ {props.subBody && props.subBody}+ <Text+ display={props.info ? "flex" : "none"}+ variant="body"+ fontSize={10}+ color="fontTertiary"+ >+ {props.info}+ </Text>+ </Box>+ {props.menuItems && props.dropdownRefs && (+ <Dropdown+ style={{ zIndex: 1, marginRight: -4 }}+ ref={ref => (props.dropdownRefs[props.index] = ref)}+ >+ <DropdownTrigger>+ <Text sx={{ ":active, :hover": { color: "primary" } }}>+ <Icon.MoreVertical+ size={24}+ strokeWidth={1.5}+ style={{ marginRight: -5 }}+ />+ </Text>+ </DropdownTrigger>+ <DropdownContent style={{ zIndex: 2, marginLeft: -110 }}>+ <Menu+ dropdownRef={props.dropdownRefs[props.index]}+ menuItems={props.menuItems}+ data={props.menuData}+ />+ </DropdownContent>+ </Dropdown>+ )}+ </Flex>+ );+};export default ListItem;diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.jsindex b048c31ec..a93bb8ecc 100644--- a/apps/web/src/components/note/index.js+++ b/apps/web/src/components/note/index.js@@ -66,6 +66,7 @@ export default class Note extends React.Component {<ListItemtitle={note.title}body={note.headline}+ id={note.id}index={index}onClick={async () => {await editorStore.getState().openSession(note);diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.jsindex 7b4e2c66c..9a7c0abc8 100644--- a/apps/web/src/stores/editor-store.js+++ b/apps/web/src/stores/editor-store.js@@ -1,5 +1,5 @@import createStore from "../common/store";-import { store as notestore, LIST_TYPES } from "./note-store";+import { store as noteStore, LIST_TYPES } from "./note-store";import { store as appStore } from "./app-store";import { db } from "../common";@@ -33,6 +33,7 @@ function editorStore(set, get) {text: note.content.text,delta: await db.notes.note(note).delta()};+ noteStore.getState().setSelectedNote(note.id);set(state => {clearTimeout(state.session.timeout);state.session = {@@ -66,15 +67,16 @@ function editorStore(set, get) {updateContext("colors", colors);appStore.getState().refreshColors();}-set(state => {+ if (state.session.id === "") {+ noteStore.getState().setSelectedNote(id);+ }state.session.id = id;- state.session.state = SESSION_STATES.stale;- notestore.getState().refresh();+ noteStore.getState().refresh();// we update favorites only if favorite has changedif (!oldSession || oldSession.favorite !== session.favorite) {- notestore.getState().refreshList(LIST_TYPES.fav);+ noteStore.getState().refreshList(LIST_TYPES.fav);}});});@@ -82,6 +84,7 @@ function editorStore(set, get) {setSession: function(session) {const oldSession = get().session;set(state => {+ state.session.state = SESSION_STATES.stale;session(state);clearTimeout(state.session.timeout);state.session.timeout = setTimeout(() => {@@ -132,12 +135,12 @@ function setTagOrColor(session, array, value, func, set) {function updateContext(key, array) {let type = key === "colors" ? "color" : "tag";// update notes if the selected context (the current view in the navigator) is a tag or color- const notesState = notestore.getState();+ const notesState = noteStore.getState();const context = notesState.selectedContext;if (context.type === type) {array.forEach(value => {if (context.value === value) {- notestore.getState().setSelectedContext(context);+ noteStore.getState().setSelectedContext(context);}});}diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.jsindex 2909d9a8e..9935e9b96 100644--- a/apps/web/src/stores/note-store.js+++ b/apps/web/src/stores/note-store.js@@ -17,6 +17,12 @@ function noteStore(set, get) {favorites: [],selectedNotes: [],selectedContext: {},+ selectedNote: 0,+ setSelectedNote: function(id) {+ set(state => {+ state.selectedNote = id;+ });+ },refresh: function() {set(state => {//TODO save group type