mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
add update Database functions
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
getColorScheme,
|
getColorScheme,
|
||||||
ACCENT,
|
ACCENT,
|
||||||
} from '../common/common';
|
} from '../common/common';
|
||||||
|
import {db} from '../../App';
|
||||||
|
|
||||||
const useAppContext = () => {
|
const useAppContext = () => {
|
||||||
const [state, dispatch] = useContext(AppContext);
|
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 {
|
return {
|
||||||
...state,
|
...state,
|
||||||
updateAppTheme,
|
updateAppTheme,
|
||||||
@@ -70,6 +102,11 @@ const useAppContext = () => {
|
|||||||
changeAccentColor,
|
changeAccentColor,
|
||||||
changeSelectionMode,
|
changeSelectionMode,
|
||||||
updateSelectionList,
|
updateSelectionList,
|
||||||
|
updateNotes,
|
||||||
|
updateNotebooks,
|
||||||
|
updateFavorites,
|
||||||
|
updatePinned,
|
||||||
|
updateTrash,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user