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
improve performance when changing settings
ammarahm-edd22de304d016
diff --git a/apps/mobile/src/components/intro/index.js b/apps/mobile/src/components/intro/index.jsindex fae271b38..40ca4471a 100644--- a/apps/mobile/src/components/intro/index.js+++ b/apps/mobile/src/components/intro/index.js@@ -25,9 +25,8 @@ const SVG_Z = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 245.487 113.const Intro = () => {const colors = useThemeStore(state => state.colors);- const settings = useSettingStore(state => state.settings);- const introCompleted = settings.introCompleted;- const isTelemetryEnabled = settings.telemetry;+ const introCompleted = useSettingStore(state => state.settings.introCompleted);+ const isTelemetryEnabled = useSettingStore(state => state.settings.isTelemetryEnabled);const { height } = useWindowDimensions();const opacity = useValue(0);diff --git a/apps/mobile/src/components/list/empty.js b/apps/mobile/src/components/list/empty.jsindex 4793df74a..558f276ce 100644--- a/apps/mobile/src/components/list/empty.js+++ b/apps/mobile/src/components/list/empty.js@@ -17,8 +17,7 @@ export const Empty = React.memo(const colors = useThemeStore(state => state.colors);const insets = useSafeAreaInsets();const { height } = useWindowDimensions();- const settings = useSettingStore(state => state.settings);- const introCompleted = settings.introCompleted;+ const introCompleted = useSettingStore(state => state.settings.introCompleted);const tip = useTip(screen === 'Notes' && introCompleted ? 'first-note' : placeholderData.type || type,diff --git a/apps/mobile/src/components/listitems/headers/sectionheader.js b/apps/mobile/src/components/listitems/headers/sectionheader.jsindex abc7c3af3..932f1839e 100644--- a/apps/mobile/src/components/listitems/headers/sectionheader.js+++ b/apps/mobile/src/components/listitems/headers/sectionheader.js@@ -28,8 +28,13 @@ export const SectionHeader = ({ item, index, type, color, screen }) => {const sortRef = useRef();const compactModeRef = useRef();- const settings = useSettingStore(state => state.settings);- const listMode = type === 'notebooks' ? settings.notebooksListMode : settings.notesListMode;+ const notebooksListMode = useSettingStore(state => state.settings.notebooksListMode);+ const notesListMode = useSettingStore(state => state.settings.notesListMode);+ const listMode = type === 'notebooks' ? notebooksListMode : notesListMode;++ useEffect(() => {+ console.log('rerender section header');+ });groupBy = !groupBy? 'Default'diff --git a/apps/mobile/src/components/listitems/note/index.js b/apps/mobile/src/components/listitems/note/index.jsindex 051889ff0..6e820d37f 100644--- a/apps/mobile/src/components/listitems/note/index.js+++ b/apps/mobile/src/components/listitems/note/index.js@@ -53,8 +53,8 @@ const showActionSheet = item => {const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false }) => {const colors = useThemeStore(state => state.colors);- const settings = useSettingStore(state => state.settings);- const compactMode = settings.notesListMode === 'compact';+ const notesListMode = useSettingStore(state => state.settings.notesListMode);+ const compactMode = notesListMode === 'compact';const attachmentCount = db.attachments?.ofNote(item.id, 'all')?.length || 0;function getNotebook() {diff --git a/apps/mobile/src/components/listitems/notebook/index.js b/apps/mobile/src/components/listitems/notebook/index.jsindex 4d6399249..31ebf8004 100644--- a/apps/mobile/src/components/listitems/notebook/index.js+++ b/apps/mobile/src/components/listitems/notebook/index.js@@ -17,8 +17,8 @@ import Paragraph from '../../ui/typography/paragraph';export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateBy }) => {const colors = useThemeStore(state => state.colors);- const settings = useSettingStore(state => state.settings);- const compactMode = settings.notebooksListMode === 'compact';+ const notebooksListMode = useSettingStore(state => state.settings.notebooksListMode);+ const compactMode = notebooksListMode === 'compact';const topics = item.topics?.slice(0, 3) || [];const totalNotes = getTotalNotes(item);const showActionSheet = () => {diff --git a/apps/mobile/src/components/listitems/selectionwrapper/index.js b/apps/mobile/src/components/listitems/selectionwrapper/index.jsindex 10cd90070..01af2b410 100644--- a/apps/mobile/src/components/listitems/selectionwrapper/index.js+++ b/apps/mobile/src/components/listitems/selectionwrapper/index.js@@ -11,8 +11,9 @@ import { SelectionIcon } from './selection';const SelectionWrapper = ({ children, item, background, onLongPress, onPress, testID }) => {const colors = useThemeStore(state => state.colors);const [actionStrip, setActionStrip] = useState(false);- const settings = useSettingStore(state => state.settings);- const listMode = item.type === 'notebook' ? settings.notebooksListMode : settings.notesListMode;+ const notebooksListMode = useSettingStore(state => state.settings.notebooksListMode);+ const notesListMode = useSettingStore(state => state.settings.notesListMode);+ const listMode = item.type === 'notebook' ? notebooksListMode : notesListMode;const compactMode = (item.type === 'notebook' || item.type === 'note') && listMode === 'compact';const _onLongPress = () => {diff --git a/apps/mobile/src/components/properties/devmode.js b/apps/mobile/src/components/properties/devmode.jsindex 950537af4..81647e282 100644--- a/apps/mobile/src/components/properties/devmode.js+++ b/apps/mobile/src/components/properties/devmode.js@@ -8,9 +8,9 @@ import { SIZE } from '../../utils/size';import { Button } from '../ui/button';export const DevMode = ({ item }) => {- const settings = useSettingStore(state => state.settings);+ const devMode = useSettingStore(state => state.settings.devMode);- return settings.devMode ? (+ return devMode ? (<Viewstyle={{width: '100%',diff --git a/apps/mobile/src/screens/settings/applock.js b/apps/mobile/src/screens/settings/applock.jsindex be9051c0a..9b585ad47 100644--- a/apps/mobile/src/screens/settings/applock.js+++ b/apps/mobile/src/screens/settings/applock.js@@ -19,7 +19,8 @@ import umami from '../../utils/analytics';const AppLock = ({ welcome, s = 0 }) => {const colors = useThemeStore(state => state.colors);- const settings = useSettingStore(state => state.settings);+ const appLockMode = useSettingStore(state => state.settings.appLockMode);+const [step, setStep] = useState(s);const modes = [@@ -92,7 +93,7 @@ const AppLock = ({ welcome, s = 0 }) => {{modes.map(item => (<PressableButtonkey={item.title}- type={settings.appLockMode === item.value ? 'grayBg' : 'transparent'}+ type={appLockMode === item.value ? 'grayBg' : 'transparent'}onPress={() => {SettingsService.set({ appLockMode: item.value });}}@@ -104,21 +105,21 @@ const AppLock = ({ welcome, s = 0 }) => {marginTop: 0,marginBottom: 12,borderWidth: 1,- borderColor: settings.appLockMode === item.value ? item.activeColor : colors.nav+ borderColor: appLockMode === item.value ? item.activeColor : colors.nav}}style={{marginBottom: 10}}><Heading- color={settings.appLockMode === item.value ? item.activeColor : colors.pri}+ color={appLockMode === item.value ? item.activeColor : colors.pri}style={{ maxWidth: '95%' }}size={SIZE.md}>{item.title}</Heading><Paragraph- color={settings.appLockMode === item.value ? item.activeColor : colors.icon}+ color={appLockMode === item.value ? item.activeColor : colors.icon}style={{ maxWidth: '95%' }}size={SIZE.sm}>diff --git a/apps/mobile/src/services/settings.ts b/apps/mobile/src/services/settings.tsindex 192112af9..f19d29c79 100644--- a/apps/mobile/src/services/settings.ts+++ b/apps/mobile/src/services/settings.ts@@ -143,7 +143,6 @@ async function setPrivacyScreen(settings: SettingStore['settings']) {async function set(next: Partial<SettingStore['settings']>) {let settings = get();-settings = {...settings,...nextdiff --git a/apps/mobile/src/utils/colorscheme/utils.js b/apps/mobile/src/utils/colorscheme/utils.jsindex 7885ad70e..817be10e6 100644--- a/apps/mobile/src/utils/colorscheme/utils.js+++ b/apps/mobile/src/utils/colorscheme/utils.js@@ -90,7 +90,5 @@ export const toggleDarkMode = async () => {dark: !settings.theme?.dark}});- setTimeout(() => {- getColorScheme();- }, 1);+ getColorScheme();};