Skip to content

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

possibly fix loading indicator on ios

ammarahm-ed1c0e3714af8b
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index c2d900d10..e950c13fd 100644
--- a/apps/mobile/src/components/SimpleList/index.js
+++ b/apps/mobile/src/components/SimpleList/index.js
@@ -34,7 +34,7 @@ const SimpleList = ({
isHome = false,
}) => {
const [state, dispatch] = useTracked();
- const {colors, selectionMode} = state;
+ const {colors, selectionMode, syncing} = state;
const searchResults = {...state.searchResults};
const insets = useSafeArea();
const _onScroll = event => {
@@ -84,8 +84,8 @@ const SimpleList = ({
marginTop:
Platform.OS == 'ios'
? data[0] && !selectionMode
- ? 135
- : 135 - 60
+ ? 115
+ : 115 - 60
: data[0] && !selectionMode
? 155 - insets.top
: 155 - insets.top - 60,
@@ -120,8 +120,8 @@ const SimpleList = ({
marginTop:
Platform.OS == 'ios'
? data[0] && !selectionMode
- ? 135
- : 135 - 60
+ ? 115
+ : 115 - 60
: data[0] && !selectionMode
? 155 - insets.top
: 155 - 60 - insets.top,
@@ -257,14 +257,15 @@ const SimpleList = ({
<RefreshControl
tintColor={colors.accent}
colors={[colors.accent]}
- progressViewOffset={165}
+ progressViewOffset={150}
onRefresh={onRefresh}
- refreshing={refreshing}
+ refreshing={syncing}
/>
}
keyExtractor={_listKeyExtractor}
renderSectionHeader={_renderSectionHeader}
onScroll={_onScroll}
+ stickySectionHeadersEnabled={false}
ListEmptyComponent={_ListEmptyComponent}
ListHeaderComponent={_ListHeaderComponent_S}
contentContainerStyle={{
@@ -292,7 +293,7 @@ const SimpleList = ({
<RefreshControl
tintColor={colors.accent}
colors={[colors.accent]}
- progressViewOffset={165}
+ progressViewOffset={-200}
onRefresh={onRefresh}
refreshing={refreshing}
/>
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index eb1701d8a..3b54a49cb 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -44,7 +44,7 @@ const InfoBarRef = createRef();
const EditorWebView = createRef();
let note = {};
let id = null;
-var content = null;
+var content = {};
var title = null;
let timer = null;
let saveCounter = 0;
@@ -386,50 +386,50 @@ const Editor = ({noMenu}) => {
};
const updateEditor = async () => {
- title = note.title;
- id = note.id;
- saveCounter = 0;
- InfoBarRef.current?.setDateCreated(note.dateCreated);
- content.text = await db.notes.note(id).text();
-
- InfoBarRef.current?.setDateEdited(
- note.dateEdited,
- content.text.split(' ').length,
- );
-
- if (title !== null || title === '') {
- post({
- type: 'title',
- value: note.title,
- });
- } else {
- post({
- type: 'clearTitle',
- });
- post({
- type: 'clearEditor',
- });
- post({
- type: 'focusTitle',
- });
- }
- if (content.text === '' && note.content.delta === null) {
- post({
- type: 'clearEditor',
- });
- } else if (note.content.delta) {
- if (typeof note.content.delta !== 'string') {
- content.delta = note.content.delta;
+ try {
+ title = note.title;
+ id = note.id;
+ saveCounter = 0;
+ InfoBarRef.current?.setDateCreated(note.dateCreated);
+ content.text = await db.notes.note(id).text();
+ InfoBarRef.current?.setDateEdited(
+ note.dateEdited,
+ content.text.split(' ').length,
+ );
+ if (title !== null || title === '') {
+ post({
+ type: 'title',
+ value: note.title,
+ });
} else {
- content.delta = await db.notes.note(id).delta();
+ post({
+ type: 'clearTitle',
+ });
+ post({
+ type: 'clearEditor',
+ });
+ post({
+ type: 'focusTitle',
+ });
}
- post({
- type: 'delta',
- value: content.delta,
- });
- } else {
- post({type: 'text', value: content.text});
- }
+ if (content.text === '' && note.content.delta === null) {
+ post({
+ type: 'clearEditor',
+ });
+ } else if (note.content.delta) {
+ if (typeof note.content.delta !== 'string') {
+ content.delta = note.content.delta;
+ } else {
+ content.delta = await db.notes.note(id).delta();
+ }
+ post({
+ type: 'delta',
+ value: content.delta,
+ });
+ } else {
+ post({type: 'text', value: content.text});
+ }
+ } catch (e) {}
};
const params = 'platform=' + Platform.OS;
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index 1b2aab187..803932a12 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -41,14 +41,24 @@ export const Home = ({navigation}) => {
}, [isFocused]);
const _onRefresh = async () => {
- setRefreshing(true);
+ dispatch({
+ type: ACTIONS.SYNCING,
+ syncing: true,
+ });
+
try {
await db.sync();
- setRefreshing(false);
+ dispatch({
+ type: ACTIONS.SYNCING,
+ syncing: false,
+ });
+
ToastEvent.show('Sync Complete', 'success');
} catch (e) {
- setRefreshing(false);
- console.log(e);
+ dispatch({
+ type: ACTIONS.SYNCING,
+ syncing: false,
+ });
ToastEvent.show(e.message, 'error');
}
dispatch({type: ACTIONS.NOTES});