mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-02 20:21:19 +02:00
fix: #107
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import createStore from "../common/store";
|
||||
import { store as noteStore, LIST_TYPES } from "./note-store";
|
||||
import { store as appStore } from "./app-store";
|
||||
import { store as tagStore } from "./tag-store";
|
||||
import { db } from "../common";
|
||||
import { showPasswordDialog } from "../components/dialogs/passworddialog";
|
||||
|
||||
@@ -205,11 +206,13 @@ function updateContext(key, array) {
|
||||
// update notes if the selected context (the current view in the navigator) is a tag or color
|
||||
const notesState = noteStore.getState();
|
||||
const context = notesState.selectedContext;
|
||||
console.log(context);
|
||||
if (context.type === type) {
|
||||
const isValue = array.some(value => value === context.value);
|
||||
if (isValue) noteStore.getState().setSelectedContext(context);
|
||||
}
|
||||
if (type === "tag") {
|
||||
tagStore.getState().refreshTags();
|
||||
}
|
||||
}
|
||||
|
||||
const [useStore, store] = createStore(editorStore);
|
||||
|
||||
18
apps/web/src/stores/tag-store.js
Normal file
18
apps/web/src/stores/tag-store.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import createStore from "../common/store";
|
||||
import { db } from "../common";
|
||||
import { showPasswordDialog } from "../components/dialogs/passworddialog";
|
||||
|
||||
function tagStore(set, get) {
|
||||
return {
|
||||
tags: [],
|
||||
refreshTags: function() {
|
||||
set(state => {
|
||||
state.tags = db.tags.all;
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const [useStore, store] = createStore(tagStore);
|
||||
|
||||
export { useStore, store };
|
||||
@@ -3,7 +3,8 @@ import { Flex, Text } from "rebass";
|
||||
import ListContainer from "../components/list-container";
|
||||
import ListItem from "../components/list-item";
|
||||
import { db } from "../common";
|
||||
import { useStore } from "../stores/note-store";
|
||||
import { useStore as useNotesStore } from "../stores/note-store";
|
||||
import { useStore, store } from "../stores/tag-store";
|
||||
import TagsPlaceholder from "../components/placeholders/tags-placeholder";
|
||||
|
||||
const TagNode = ({ title }) => (
|
||||
@@ -16,8 +17,11 @@ const TagNode = ({ title }) => (
|
||||
);
|
||||
|
||||
const Tags = props => {
|
||||
const setSelectedContext = useStore(store => store.setSelectedContext);
|
||||
const tags = db.tags.all;
|
||||
const setSelectedContext = useNotesStore(store => store.setSelectedContext);
|
||||
const tags = useStore(store => store.tags);
|
||||
useEffect(() => {
|
||||
store.getState().refreshTags();
|
||||
}, []);
|
||||
return (
|
||||
<ListContainer
|
||||
type="tags"
|
||||
|
||||
Reference in New Issue
Block a user