From faec1aa9c89c615c332eda83bf819a2d022795d0 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Mon, 13 Jan 2020 15:08:43 +0500 Subject: [PATCH] add update Database functions --- apps/mobile/src/provider/useAppContext.js | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/apps/mobile/src/provider/useAppContext.js b/apps/mobile/src/provider/useAppContext.js index bed0a057d..e5104cd6d 100644 --- a/apps/mobile/src/provider/useAppContext.js +++ b/apps/mobile/src/provider/useAppContext.js @@ -7,6 +7,7 @@ import { getColorScheme, ACCENT, } from '../common/common'; +import {db} from '../../App'; const useAppContext = () => { const [state, dispatch] = useContext(AppContext); @@ -63,6 +64,37 @@ const useAppContext = () => { }); } + // Database Control + + function updateNotes() { + dispatch(draft => { + draft.notes = db.groupNotes(); + }); + } + function updateNotebooks() { + dispatch(draft => { + draft.notes = db.getNotebooks(); + }); + } + + function updateTrash() { + dispatch(draft => { + draft.notes = db.getTrash(); + }); + } + + function updateFavorites() { + dispatch(draft => { + draft.notes = db.getFavorites(); + }); + } + + function updatePinned() { + dispatch(draft => { + draft.notes = db.getPinned(); + }); + } + return { ...state, updateAppTheme, @@ -70,6 +102,11 @@ const useAppContext = () => { changeAccentColor, changeSelectionMode, updateSelectionList, + updateNotes, + updateNotebooks, + updateFavorites, + updatePinned, + updateTrash, }; };