Skip to content

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

make components lightweight

ammarahm-ed69d769b74600
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index fe4f64b77..562b3761a 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -55,6 +55,7 @@ const NoteItem = ({item, isTrash}) => {
) : null}
<Text
+ numberOfLines={1}
style={{
color: COLORS_NOTE[item.color] || colors.heading,
fontSize: SIZE.md,
diff --git a/apps/mobile/src/components/NoteItem/wrapper.js b/apps/mobile/src/components/NoteItem/wrapper.js
index fd7376cde..e4ffeced3 100644
--- a/apps/mobile/src/components/NoteItem/wrapper.js
+++ b/apps/mobile/src/components/NoteItem/wrapper.js
@@ -1,17 +1,16 @@
import React from 'react';
-import {useWindowDimensions} from 'react-native';
import NoteItem from '.';
-import {notesnook} from '../../../e2e/test.ids';
-import {useTracked} from '../../provider';
-import {Actions} from '../../provider/Actions';
-import {DDS} from '../../services/DeviceDetection';
-import {eSendEvent, openVault} from '../../services/EventManager';
-import {history} from '../../utils';
-import {db} from '../../utils/DB';
-import {eOnLoadNote, eShowMergeDialog} from '../../utils/Events';
-import {tabBarRef} from '../../utils/Refs';
-import {simpleDialogEvent} from '../DialogManager/recievers';
-import {TEMPLATE_TRASH} from '../DialogManager/Templates';
+import { notesnook } from '../../../e2e/test.ids';
+import { useTracked } from '../../provider';
+import { Actions } from '../../provider/Actions';
+import { DDS } from '../../services/DeviceDetection';
+import { eSendEvent, openVault } from '../../services/EventManager';
+import { history } from '../../utils';
+import { db } from '../../utils/DB';
+import { eOnLoadNote, eShowMergeDialog } from '../../utils/Events';
+import { tabBarRef } from '../../utils/Refs';
+import { simpleDialogEvent } from '../DialogManager/recievers';
+import { TEMPLATE_TRASH } from '../DialogManager/Templates';
import SelectionWrapper from '../SelectionWrapper';
export const NoteWrapper = React.memo(({item, index}) => {
@@ -20,7 +19,7 @@ export const NoteWrapper = React.memo(({item, index}) => {
const onPress = async () => {
let _note = db.notes.note(item.id).data;
- if (history.selectedItemsList.length > 0) {
+ if (history.selectedItemsList.length > 0 ) {
dispatch({type: Actions.SELECTED_ITEMS, item: _note});
return;
}
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index 55bdf3d03..06cfdffd2 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, {useEffect, useState} from 'react';
import {TouchableOpacity, View} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {notesnook} from '../../../e2e/test.ids';
@@ -14,6 +14,7 @@ import Paragraph from '../Typography/Paragraph';
export const NotebookItem = ({item, isTopic = false, notebookID, isTrash}) => {
const [state] = useTracked();
const {colors} = state;
+ const topics = item.topics?.slice(0, 3) || [];
const totalNotes = getTotalNotes(item);
const showActionSheet = () => {
let rowItems = isTrash
@@ -31,10 +32,10 @@ export const NotebookItem = ({item, isTopic = false, notebookID, isTrash}) => {
});
};
- const navigateToTopic = (topic) => {
+ const navigateToTopic = topic => {
if (history.selectedItemsList.length > 0) return;
let routeName = 'NotesPage';
- let params = {...topic, menu: false};
+ let params = {...topic, menu: false, get: 'topics'};
let headerState = {
heading: topic.title,
id: topic.id,
@@ -81,47 +82,32 @@ export const NotebookItem = ({item, isTopic = false, notebookID, isTrash}) => {
flexWrap: 'wrap',
paddingVertical: 0,
}}>
- {item && item.topics ? (
- item.topics
- .sort((a, b) => b.dateEdited - a.dateEdited)
- .slice(0, 2)
- .map(topic => (
- <TouchableOpacity
- activeOpacity={0.8}
- onPress={() => navigateToTopic(topic)}
- key={topic.id}
- style={{
- borderRadius: 2.5,
- backgroundColor: colors.accent,
- paddingHorizontal: 5,
- paddingVertical: 2,
- marginRight: 5,
- marginVertical: 2.5,
- }}>
- <Paragraph
- size={SIZE.xs}
- numberOfLines={1}
- style={{
- color: 'white',
- maxWidth: '100%',
- }}>
- {topic.title.length > 16
- ? topic.title.slice(0, 16) + '...'
- : topic.title}
- </Paragraph>
- </TouchableOpacity>
- ))
- ) : (
- <Paragraph
- color={colors.icon}
- size={SIZE.xs}
+ {topics.map(topic => (
+ <TouchableOpacity
+ activeOpacity={0.8}
+ onPress={() => navigateToTopic(topic)}
+ key={topic.id}
style={{
- paddingVertical: pv / 3,
- maxWidth: '100%',
+ borderRadius: 2.5,
+ backgroundColor: colors.accent,
+ paddingHorizontal: 5,
+ paddingVertical: 2,
+ marginRight: 5,
+ marginVertical: 2.5,
+ maxWidth: 70,
}}>
- This notebook has no topics.
- </Paragraph>
- )}
+ <Paragraph
+ size={SIZE.xs}
+ numberOfLines={1}
+ lineBreakMode="tail"
+ color="white"
+ style={{
+ maxWidth: '100%',
+ }}>
+ {topic.title}
+ </Paragraph>
+ </TouchableOpacity>
+ ))}
</View>
)}
diff --git a/apps/mobile/src/components/SelectionWrapper/index.js b/apps/mobile/src/components/SelectionWrapper/index.js
index b065412b5..db120a659 100644
--- a/apps/mobile/src/components/SelectionWrapper/index.js
+++ b/apps/mobile/src/components/SelectionWrapper/index.js
@@ -28,12 +28,10 @@ const SelectionWrapper = ({
};
const _onPress = async () => {
-
if (actionStrip) {
setActionStrip(false);
return;
}
- console.log('clicking',onPress);
await onPress();
};