Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix header button not working on some screens

ammarahm-ed24e094206b92
diff --git a/apps/mobile/src/components/header/rightmenus.js b/apps/mobile/src/components/header/rightmenus.js
index c0fa91325..6515c2091 100644
--- a/apps/mobile/src/components/header/rightmenus.js
+++ b/apps/mobile/src/components/header/rightmenus.js
@@ -17,6 +17,7 @@ export const RightMenus = () => {
const deviceMode = useSettingStore(state => state.deviceMode);
const rightButtons = useNavigationStore(state => state.headerRightButtons);
const currentScreen = useNavigationStore(state => state.currentScreen.name);
+ const buttonAction = useNavigationStore(state => state.buttonAction);
const menuRef = useRef();
return (
@@ -38,7 +39,7 @@ export const RightMenus = () => {
{deviceMode !== 'mobile' ? (
<Button
- onPress={RightMenus.floatingButtonAction}
+ onPress={buttonAction}
testID={notesnook.ids.default.addBtn}
icon={currentScreen === 'Trash' ? 'delete' : 'plus'}
iconSize={SIZE.xl}
@@ -109,8 +110,6 @@ export const RightMenus = () => {
);
};
-RightMenus.floatingButtonAction = () => {};
-
const styles = StyleSheet.create({
rightBtnContainer: {
flexDirection: 'row',
diff --git a/apps/mobile/src/screens/editor/index.tsx b/apps/mobile/src/screens/editor/index.tsx
index f115a2e84..e3a3bfcca 100755
--- a/apps/mobile/src/screens/editor/index.tsx
+++ b/apps/mobile/src/screens/editor/index.tsx
@@ -114,11 +114,10 @@ const Editor = React.memo(
nestedScrollEnabled
onError={onError}
injectedJavaScriptBeforeContentLoaded={`
- globalThis.readonly=${readonly};
- globalThis.noToolbar=${noToolbar};
- globalThis.noHeader=${noHeader};
- `}
- injectedJavaScript={`globalThis.sessionId="${editor.sessionId}";`}
+ globalThis.sessionId="${editor.sessionId}";
+ globalThis.readonly=${readonly};
+ globalThis.noToolbar=${noToolbar};
+ globalThis.noHeader=${noHeader};`}
javaScriptEnabled={true}
focusable={true}
setSupportMultipleWindows={false}
@@ -139,7 +138,7 @@ const Editor = React.memo(
allowUniversalAccessFromFileURLs={true}
originWhitelist={['*']}
source={{
- uri: __DEV__ ? EDITOR_URI : EDITOR_URI
+ uri: __DEV__ ? `http://192.168.201.126:3000/index.html` : EDITOR_URI
}}
style={style}
autoManageStatusBarEnabled={false}
diff --git a/apps/mobile/src/screens/home/index.tsx b/apps/mobile/src/screens/home/index.tsx
index c9eab6de4..f5fa4c939 100755
--- a/apps/mobile/src/screens/home/index.tsx
+++ b/apps/mobile/src/screens/home/index.tsx
@@ -39,7 +39,7 @@ export const Home = ({ navigation, route }: NavigationProps<'Notes'>) => {
name: route.name
});
SearchService.prepareSearch = prepareSearch;
- RightMenus.floatingButtonAction = openEditor;
+ useNavigationStore.getState().setButtonAction(openEditor);
return !prev?.current;
},
onBlur: () => false,
diff --git a/apps/mobile/src/screens/notebook/index.tsx b/apps/mobile/src/screens/notebook/index.tsx
index 8d0f6968a..ee2557776 100644
--- a/apps/mobile/src/screens/notebook/index.tsx
+++ b/apps/mobile/src/screens/notebook/index.tsx
@@ -23,6 +23,7 @@ const Notebook = ({ route, navigation }: NavigationProps<'Notebook'>) => {
onFocus: () => {
Navigation.routeNeedsUpdate(route.name, onRequestUpdate);
syncWithNavigation();
+ useNavigationStore.getState().setButtonAction(onPressFloatingButton);
return false;
},
onBlur: () => false
diff --git a/apps/mobile/src/screens/notebooks/index.tsx b/apps/mobile/src/screens/notebooks/index.tsx
index 0a8106d28..629cc92f1 100644
--- a/apps/mobile/src/screens/notebooks/index.tsx
+++ b/apps/mobile/src/screens/notebooks/index.tsx
@@ -46,7 +46,7 @@ export const Notebooks = ({ navigation, route }: NavigationProps<'Notebooks'>) =
name: route.name
});
SearchService.prepareSearch = prepareSearch;
- RightMenus.floatingButtonAction = onPressFloatingButton;
+ useNavigationStore.getState().setButtonAction(onPressFloatingButton);
if (notebooks.length === 0) {
Walkthrough.present('notebooks');
diff --git a/apps/mobile/src/screens/notes/index.tsx b/apps/mobile/src/screens/notes/index.tsx
index d6d3b79a8..5b1a6e55c 100644
--- a/apps/mobile/src/screens/notes/index.tsx
+++ b/apps/mobile/src/screens/notes/index.tsx
@@ -113,7 +113,7 @@ const NotesPage = ({
rightButtons && rightButtons(params.current)
);
SearchService.prepareSearch = prepareSearch;
- RightMenus.floatingButtonAction = onPressFloatingButton;
+ useNavigationStore.getState().setButtonAction(onPressFloatingButton);
!isMonograph &&
setOnFirstSave({
diff --git a/apps/mobile/src/stores/useNavigationStore.ts b/apps/mobile/src/stores/useNavigationStore.ts
index b6cfa0867..67fd8f703 100644
--- a/apps/mobile/src/stores/useNavigationStore.ts
+++ b/apps/mobile/src/stores/useNavigationStore.ts
@@ -44,6 +44,8 @@ interface NavigationStore extends State {
headerRightButtons?: HeaderRightButton[]
) => void;
headerRightButtons?: HeaderRightButton[];
+ buttonAction: () => void;
+ setButtonAction: (buttonAction: () => void) => void;
}
const useNavigationStore = create<NavigationStore>((set, get) => ({
@@ -74,7 +76,9 @@ const useNavigationStore = create<NavigationStore>((set, get) => ({
headerRightButtons: headerRightButtons
});
},
- headerRightButtons: []
+ headerRightButtons: [],
+ buttonAction: () => null,
+ setButtonAction: buttonAction => set({ buttonAction })
}));
export default useNavigationStore;