Skip to content

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

fix when selection is called

ammarahm-ed929dc034a5dd
diff --git a/apps/mobile/src/components/Properties/index.js b/apps/mobile/src/components/Properties/index.js
index cd1498103..b6c8d76be 100644
--- a/apps/mobile/src/components/Properties/index.js
+++ b/apps/mobile/src/components/Properties/index.js
@@ -218,7 +218,7 @@ export const Properties = ({
icon: 'book-outline',
func: () => {
close();
- clearSelection();
+ clearSelection(true);
setSelectedItem(note);
setTimeout(() => {
eSendEvent(eOpenMoveNoteDialog, note);
diff --git a/apps/mobile/src/components/SelectionHeader/index.js b/apps/mobile/src/components/SelectionHeader/index.js
index 750b54b77..355ebf093 100644
--- a/apps/mobile/src/components/SelectionHeader/index.js
+++ b/apps/mobile/src/components/SelectionHeader/index.js
@@ -37,7 +37,6 @@ export const SelectionHeader = React.memo(({screen, type, extras}) => {
Navigation.routeNames.NotesPage,
Navigation.routeNames.Favorites
]);
- setSelectionMode(false);
clearSelection();
}
};
@@ -57,7 +56,6 @@ export const SelectionHeader = React.memo(({screen, type, extras}) => {
Navigation.routeNames.Favorites,
Navigation.routeNames.Trash
]);
- setSelectionMode(false);
clearSelection();
ToastEvent.show({
heading: 'Restore successful',
@@ -68,7 +66,6 @@ export const SelectionHeader = React.memo(({screen, type, extras}) => {
const onBackPress = () => {
layoutmanager.withSpringAnimation(500);
- setSelectionMode(false);
clearSelection();
return true;
};
@@ -113,7 +110,6 @@ export const SelectionHeader = React.memo(({screen, type, extras}) => {
type="grayBg"
onPress={() => {
setSelectionMode(!selectionMode);
- clearSelection();
}}
size={SIZE.xl}
color={colors.icon}
@@ -130,11 +126,9 @@ export const SelectionHeader = React.memo(({screen, type, extras}) => {
flexDirection: 'row',
alignItems: 'center'
}}>
- {Platform.OS === 'android' ? (
- <Heading size={SIZE.md} color={colors.accent}>
- {selectedItemsList.length + ' Selected'}
- </Heading>
- ) : null}
+ <Heading size={SIZE.md} color={colors.accent}>
+ {selectedItemsList.length + ' Selected'}
+ </Heading>
</View>
</View>
<View
@@ -194,7 +188,6 @@ export const SelectionHeader = React.memo(({screen, type, extras}) => {
Navigation.routeNames.Notebook,
Navigation.routeNames.Notebooks
]);
- setSelectionMode(false);
clearSelection();
}
}}
diff --git a/apps/mobile/src/components/SelectionWrapper/index.js b/apps/mobile/src/components/SelectionWrapper/index.js
index dc58ac238..eb4eec7b6 100644
--- a/apps/mobile/src/components/SelectionWrapper/index.js
+++ b/apps/mobile/src/components/SelectionWrapper/index.js
@@ -73,6 +73,7 @@ const SelectionWrapper = ({
{item.type === 'note' ? <Filler background={background} item={item} /> : null}
<SelectionIcon
+ compactMode={compactMode}
setActionStrip={setActionStrip}
item={item}
onLongPress={onLongPress}
diff --git a/apps/mobile/src/components/SelectionWrapper/selection.js b/apps/mobile/src/components/SelectionWrapper/selection.js
index 5ad337bd3..0b5226292 100644
--- a/apps/mobile/src/components/SelectionWrapper/selection.js
+++ b/apps/mobile/src/components/SelectionWrapper/selection.js
@@ -6,7 +6,7 @@ import {Actions} from '../../provider/Actions';
import {useSelectionStore} from '../../provider/stores';
import {SIZE} from '../../utils/SizeUtils';
-export const SelectionIcon = ({setActionStrip, item}) => {
+export const SelectionIcon = ({setActionStrip, item,compactMode}) => {
const [state, dispatch] = useTracked();
const {colors} = state;
@@ -44,7 +44,7 @@ export const SelectionIcon = ({setActionStrip, item}) => {
display: 'flex',
opacity: 1,
width: '10%',
- height: 70,
+ height:compactMode ? 40 : 70,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: colors.bg,
diff --git a/apps/mobile/src/navigation/NavigatorStack.js b/apps/mobile/src/navigation/NavigatorStack.js
index 7e47067ba..e5ceecd45 100644
--- a/apps/mobile/src/navigation/NavigatorStack.js
+++ b/apps/mobile/src/navigation/NavigatorStack.js
@@ -29,7 +29,7 @@ export const NavigatorStack = React.memo(
const settings = useSettingStore(state => state.settings);
const onStateChange = React.useCallback(() => {
if (history.selectionMode) {
- clearSelection();
+ clearSelection(true);
}
eSendEvent('navigate');
});
diff --git a/apps/mobile/src/provider/interfaces.ts b/apps/mobile/src/provider/interfaces.ts
index d8cabf737..b2e9cedba 100644
--- a/apps/mobile/src/provider/interfaces.ts
+++ b/apps/mobile/src/provider/interfaces.ts
@@ -140,7 +140,7 @@ export interface SelectionStore extends State {
setAll: (all: Array<Object>,) => void,
setSelectionMode: (mode: boolean) => void,
setSelectedItem: (item: Item) => void,
- clearSelection: () => void,
+ clearSelection: (noanimation:boolean) => void,
}
export type Message = {
diff --git a/apps/mobile/src/provider/stores.ts b/apps/mobile/src/provider/stores.ts
index e52454018..36ba17168 100644
--- a/apps/mobile/src/provider/stores.ts
+++ b/apps/mobile/src/provider/stores.ts
@@ -1,4 +1,4 @@
-import {LayoutAnimation, Platform} from 'react-native';
+import {LayoutAnimation, Platform, UIManager} from 'react-native';
import {Dimensions} from 'react-native';
import create from 'zustand';
import PremiumService from '../services/PremiumService';
@@ -340,6 +340,8 @@ export const useSelectionStore = create<SelectionStore>((set, get) => ({
if (!mode) {
history.selectedItemsList = [];
history.selectionMode = false;
+ } else {
+ history.selectionMode = true;
}
console.log('call set selection mode');
if (mode !== get().selectionMode) {
@@ -365,22 +367,15 @@ export const useSelectionStore = create<SelectionStore>((set, get) => ({
history.selectionMode =
selectedItems.length > 0 ? get().selectionMode : false;
console.log('called selected items');
- if (get().selectionMode !== history.selectionMode) {
- layoutmanager.withSpringAnimation(500);
- }
-
set({
selectedItemsList: selectedItems,
selectionMode: history.selectionMode
});
},
- clearSelection: () => {
+ clearSelection: (noanimation) => {
history.selectedItemsList = [];
history.selectionMode = false;
console.log('called clear selection');
- if (get().selectionMode !== history.selectionMode) {
- layoutmanager.withSpringAnimation(500);
- }
set({selectionMode: false, selectedItemsList: []});
}
}));
diff --git a/apps/mobile/src/utils/functions.js b/apps/mobile/src/utils/functions.js
index 732eb392c..b8c0ae8e5 100644
--- a/apps/mobile/src/utils/functions.js
+++ b/apps/mobile/src/utils/functions.js
@@ -118,7 +118,7 @@ export const deleteItems = async item => {
}
history.selectedItemsList = [];
Navigation.setRoutesToUpdate([Navigation.routeNames.Trash]);
- useSelectionStore.getState().clearSelection();
+ useSelectionStore.getState().clearSelection(true);
useMenuStore.getState().setMenuPins();
useMenuStore.getState().setColorNotes();
};
diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.js
index 7ffde3adc..2a2173f87 100644
--- a/apps/mobile/src/views/Trash/index.js
+++ b/apps/mobile/src/views/Trash/index.js
@@ -92,7 +92,7 @@ export const Trash = ({route, navigation}) => {
positivePress: async () => {
await db.trash.clear();
useTrashStore.getState().setTrash();
- useSelectionStore.getState().clearSelection();
+ useSelectionStore.getState().clearSelection(true);
ToastEvent.show({
heading: 'Trash cleared',
message: