fix sync not working in release mode
@@ -1,45 +1,45 @@
|
||||
import NetInfo from '@react-native-community/netinfo';
|
||||
import { EV, EVENTS } from 'notes-core/common';
|
||||
import React, { useEffect } from 'react';
|
||||
import { Appearance, AppState, Linking, Platform } from 'react-native';
|
||||
import {EV, EVENTS} from 'notes-core/common';
|
||||
import React, {useEffect} from 'react';
|
||||
import {Appearance, AppState, Linking, Platform} from 'react-native';
|
||||
import RNExitApp from 'react-native-exit-app';
|
||||
import * as RNIap from 'react-native-iap';
|
||||
import { enabled } from 'react-native-privacy-snapshot';
|
||||
import {enabled} from 'react-native-privacy-snapshot';
|
||||
import SplashScreen from 'react-native-splash-screen';
|
||||
import { updateEvent } from './src/components/DialogManager/recievers';
|
||||
import { useTracked } from './src/provider';
|
||||
import { Actions } from './src/provider/Actions';
|
||||
import {updateEvent} from './src/components/DialogManager/recievers';
|
||||
import {useTracked} from './src/provider';
|
||||
import {Actions} from './src/provider/Actions';
|
||||
import Backup from './src/services/Backup';
|
||||
import BiometricService from './src/services/BiometricService';
|
||||
import {
|
||||
eSendEvent,
|
||||
eSubscribeEvent,
|
||||
eUnSubscribeEvent,
|
||||
ToastEvent
|
||||
ToastEvent,
|
||||
} from './src/services/EventManager';
|
||||
import {
|
||||
clearMessage,
|
||||
setEmailVerifyMessage,
|
||||
setLoginMessage
|
||||
setLoginMessage,
|
||||
} from './src/services/Message';
|
||||
import Navigation from './src/services/Navigation';
|
||||
import PremiumService from './src/services/PremiumService';
|
||||
import SettingsService from './src/services/SettingsService';
|
||||
import Sync from './src/services/Sync';
|
||||
import { APP_VERSION, doInBackground, editing } from './src/utils';
|
||||
import { updateStatusBarColor } from './src/utils/Colors';
|
||||
import { db } from './src/utils/DB';
|
||||
import {APP_VERSION, doInBackground, editing} from './src/utils';
|
||||
import {updateStatusBarColor} from './src/utils/Colors';
|
||||
import {db} from './src/utils/DB';
|
||||
import {
|
||||
eClearEditor,
|
||||
eCloseProgressDialog,
|
||||
eOpenLoginDialog,
|
||||
eOpenProgressDialog,
|
||||
refreshNotesPage
|
||||
refreshNotesPage,
|
||||
} from './src/utils/Events';
|
||||
import { MMKV } from './src/utils/mmkv';
|
||||
import {MMKV} from './src/utils/mmkv';
|
||||
import Storage from './src/utils/storage';
|
||||
import { sleep } from './src/utils/TimeUtils';
|
||||
import { getNote, getWebviewInit } from './src/views/Editor/Functions';
|
||||
import {sleep} from './src/utils/TimeUtils';
|
||||
import {getNote, getWebviewInit} from './src/views/Editor/Functions';
|
||||
|
||||
let prevTransactionId = null;
|
||||
let subsriptionSuccessListener;
|
||||
@@ -84,12 +84,13 @@ async function reconnectSSE(connection) {
|
||||
if (!state) {
|
||||
state = await NetInfo.fetch();
|
||||
}
|
||||
await doInBackground(async () => {
|
||||
let user = await db.user.getUser();
|
||||
if (user && state.isConnected && state.isInternetReachable) {
|
||||
|
||||
let user = await db.user.getUser();
|
||||
if (user && state.isConnected && state.isInternetReachable) {
|
||||
await doInBackground(async () => {
|
||||
await db.connectSSE();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
@@ -248,17 +249,17 @@ export const AppRootEvents = React.memo(
|
||||
};
|
||||
|
||||
const partialSync = async () => {
|
||||
await doInBackground(async () => {
|
||||
try {
|
||||
dispatch({type: Actions.SYNCING, syncing: true});
|
||||
try {
|
||||
dispatch({type: Actions.SYNCING, syncing: true});
|
||||
await doInBackground(async () => {
|
||||
await db.sync(false);
|
||||
dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});
|
||||
} catch (e) {
|
||||
dispatch({type: Actions.SYNCING, syncing: false});
|
||||
} finally {
|
||||
dispatch({type: Actions.SYNCING, syncing: false});
|
||||
}
|
||||
});
|
||||
});
|
||||
dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});
|
||||
} catch (e) {
|
||||
dispatch({type: Actions.SYNCING, syncing: false});
|
||||
} finally {
|
||||
dispatch({type: Actions.SYNCING, syncing: false});
|
||||
}
|
||||
};
|
||||
|
||||
const onLogout = async reason => {
|
||||
@@ -296,8 +297,6 @@ export const AppRootEvents = React.memo(
|
||||
};
|
||||
|
||||
const setCurrentUser = async login => {
|
||||
await doInBackground(async () => {
|
||||
|
||||
try {
|
||||
let user = await db.user.getUser();
|
||||
if (user) {
|
||||
@@ -306,7 +305,9 @@ export const AppRootEvents = React.memo(
|
||||
await PremiumService.setPremiumStatus();
|
||||
attachIAPListeners();
|
||||
await Sync.run();
|
||||
user = await db.user.fetchUser(true);
|
||||
await doInBackground(async () => {
|
||||
user = await db.user.fetchUser(true);
|
||||
});
|
||||
if (!user.isEmailConfirmed) {
|
||||
setEmailVerifyMessage(dispatch);
|
||||
return;
|
||||
@@ -331,9 +332,6 @@ export const AppRootEvents = React.memo(
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
const onSuccessfulSubscription = async subscription => {
|
||||
|
||||
4
apps/mobile/android/app/proguard-rules.pro
vendored
@@ -37,4 +37,6 @@
|
||||
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
|
||||
**[] $VALUES;
|
||||
public *;
|
||||
}
|
||||
}
|
||||
|
||||
-keep class **.R$* { *; }
|
||||
@@ -6,7 +6,7 @@ function reactNativeEventHandler(type, value) {
|
||||
JSON.stringify({
|
||||
type: type,
|
||||
value: value,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -91,22 +91,21 @@ function init_tiny(size) {
|
||||
'Classic=courier new;' +
|
||||
'Mono=monospace;',
|
||||
setup: function (editor) {
|
||||
|
||||
editor.ui.registry.addButton('deleteimage', {
|
||||
icon: 'remove',
|
||||
tooltip: 'Remove image',
|
||||
tooltip: 'Remove image',
|
||||
onAction: function () {
|
||||
tinymce.activeEditor.execCommand('Delete');
|
||||
},
|
||||
onclick: function () {
|
||||
tinymce.activeEditor.execCommand('Delete');
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
editor.ui.registry.addButton('imagepreview', {
|
||||
icon: 'fullscreen',
|
||||
tooltip: 'Preview image',
|
||||
onAction: function () {
|
||||
|
||||
if (tinymce.activeEditor.selection.getNode().tagName === 'IMG') {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'blob';
|
||||
@@ -124,13 +123,12 @@ function init_tiny(size) {
|
||||
};
|
||||
xhr.open(
|
||||
'GET',
|
||||
tinymce.activeEditor.selection.getNode().getAttribute('src')
|
||||
tinymce.activeEditor.selection.getNode().getAttribute('src'),
|
||||
);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
},
|
||||
onclick: function () {},
|
||||
onclick: function () {}
|
||||
});
|
||||
},
|
||||
init_instance_callback: function (edit) {
|
||||
@@ -146,11 +144,11 @@ function init_tiny(size) {
|
||||
});
|
||||
});
|
||||
|
||||
editor.on('focus', function() {
|
||||
editor.on('focus', function () {
|
||||
reactNativeEventHandler('focus', 'editor');
|
||||
});
|
||||
|
||||
editor.on('SetContent', function(event) {
|
||||
editor.on('SetContent', function (event) {
|
||||
if (!event.paste) {
|
||||
reactNativeEventHandler('noteLoaded', true);
|
||||
}
|
||||
@@ -160,24 +158,24 @@ function init_tiny(size) {
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('ScrollIntoView', function(e) {
|
||||
editor.on('ScrollIntoView', function (e) {
|
||||
e.preventDefault();
|
||||
e.elm.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'nearest',
|
||||
block: 'nearest'
|
||||
});
|
||||
});
|
||||
editor.on('input', onChange);
|
||||
editor.on('keyup', onChange);
|
||||
editor.on('NodeChange', onChange);
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
window.prevContent = '';
|
||||
const onChange = function(event) {
|
||||
const onChange = function (event) {
|
||||
clearTimeout(changeTimer);
|
||||
changeTimer = null;
|
||||
changeTimer = setTimeout(function() {
|
||||
changeTimer = setTimeout(function () {
|
||||
if (event.type === 'nodechange' && !event.selectionChange) return;
|
||||
if (isLoading) {
|
||||
isLoading = false;
|
||||
@@ -216,9 +214,9 @@ function selectchange() {
|
||||
|
||||
let formats = Object.keys(editor.formatter.get());
|
||||
let currentFormats = {};
|
||||
editor.formatter
|
||||
.matchAll(formats)
|
||||
.forEach(function(format) {currentFormats[format] = true});
|
||||
editor.formatter.matchAll(formats).forEach(function (format) {
|
||||
currentFormats[format] = true;
|
||||
});
|
||||
|
||||
let node = editor.selection.getNode();
|
||||
currentFormats.hilitecolor = getNodeBg(node);
|
||||
|
||||
|
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 215 B |
|
Before Width: | Height: | Size: 188 B After Width: | Height: | Size: 188 B |
|
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 346 B |
|
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 211 B |
2
apps/mobile/android/app/src/main/res/values/keep.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@drawable/ic_stat_name"/>
|
||||
@@ -659,7 +659,7 @@ export const ActionSheetComponent = ({
|
||||
<TouchableOpacity
|
||||
activeOpacity={0.9}
|
||||
testID={notesnook.ids.dialogs.actionsheet.sync}
|
||||
onPress={async () => await doInBackground(()=>Sync.run('local'))}
|
||||
onPress={async () => await Sync.run()}
|
||||
style={{
|
||||
borderColor: colors.accent,
|
||||
paddingHorizontal: 5,
|
||||
|
||||
@@ -41,7 +41,7 @@ const Input = ({
|
||||
returnKeyType,
|
||||
returnKeyLabel,
|
||||
autoCompleteType,
|
||||
onFocusInput
|
||||
onFocusInput,
|
||||
}) => {
|
||||
const [state] = useTracked();
|
||||
const colors = state.colors;
|
||||
@@ -63,7 +63,7 @@ const Input = ({
|
||||
? customColor || colors.accent
|
||||
: colors.nav;
|
||||
|
||||
const validate = (value) => {
|
||||
const validate = value => {
|
||||
if (!validationType) return;
|
||||
if (!value || value?.length === 0) {
|
||||
setError(false);
|
||||
@@ -97,7 +97,7 @@ const Input = ({
|
||||
if (validationType === 'password') {
|
||||
let hasError = false;
|
||||
|
||||
Object.keys(isError).forEach((e) => {
|
||||
Object.keys(isError).forEach(e => {
|
||||
if (isError[e] === true) {
|
||||
hasError = true;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ const Input = ({
|
||||
}
|
||||
};
|
||||
|
||||
const onChange = (value) => {
|
||||
const onChange = value => {
|
||||
onChangeText(value);
|
||||
validate(value);
|
||||
};
|
||||
@@ -126,9 +126,8 @@ const Input = ({
|
||||
const onFocus = () => {
|
||||
setFocus(true);
|
||||
if (onFocusInput) {
|
||||
onFocusInput()
|
||||
onFocusInput();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const style = {
|
||||
@@ -149,7 +148,7 @@ const Input = ({
|
||||
paddingVertical: 0,
|
||||
paddingBottom: 2.5,
|
||||
flexGrow: 1,
|
||||
height:35,
|
||||
height: 35,
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -283,9 +282,9 @@ const Input = ({
|
||||
style={{
|
||||
paddingTop: 5,
|
||||
}}>
|
||||
{Object.keys(errorList).filter((k) => errorList[k] === true)
|
||||
.length !== 0 ? (
|
||||
Object.keys(ERRORS_LIST).map((error) => (
|
||||
{Object.keys(errorList).filter(k => errorList[k] === true).length !==
|
||||
0 ? (
|
||||
Object.keys(ERRORS_LIST).map(error => (
|
||||
<View
|
||||
style={{
|
||||
flexDirection: 'row',
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import React from 'react';
|
||||
import {Platform} from 'react-native';
|
||||
import {ActivityIndicator, TouchableOpacity, View} from 'react-native';
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
||||
import { ActivityIndicator, Platform, TouchableOpacity, View } from 'react-native';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
import {useTracked} from '../../provider';
|
||||
import {DDS} from '../../services/DeviceDetection';
|
||||
import {eSendEvent, ToastEvent} from '../../services/EventManager';
|
||||
import { useTracked } from '../../provider';
|
||||
import { DDS } from '../../services/DeviceDetection';
|
||||
import { eSendEvent, ToastEvent } from '../../services/EventManager';
|
||||
import Sync from '../../services/Sync';
|
||||
import { doInBackground } from '../../utils';
|
||||
import {eOpenLoginDialog} from '../../utils/Events';
|
||||
import {SIZE} from '../../utils/SizeUtils';
|
||||
import { eOpenLoginDialog } from '../../utils/Events';
|
||||
import { SIZE } from '../../utils/SizeUtils';
|
||||
import Heading from '../Typography/Heading';
|
||||
import Paragraph from '../Typography/Paragraph';
|
||||
import {TimeSince} from './TimeSince';
|
||||
import { TimeSince } from './TimeSince';
|
||||
|
||||
export const UserSection = () => {
|
||||
const [state] = useTracked();
|
||||
@@ -82,7 +80,7 @@ export const UserSection = () => {
|
||||
{user && (
|
||||
<TouchableOpacity
|
||||
activeOpacity={0.8}
|
||||
onPress={async () => await doInBackground(async ()=>await Sync.run('local'))}
|
||||
onPress={async ()=>await Sync.run('local')}
|
||||
style={{
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
|
||||
@@ -221,7 +221,7 @@ export const PremiumComponent = ({close, promo}) => {
|
||||
? promo.text
|
||||
: user
|
||||
? `Subscribe for ${product?.localizedPrice || '$4.49'} / mo`
|
||||
: 'Start Your Free 14 Day Trial'
|
||||
: 'Start Your 14 Day Free Trial'
|
||||
}
|
||||
type="accent"
|
||||
height={60}
|
||||
|
||||
@@ -79,7 +79,7 @@ const SimpleList = ({
|
||||
}, [listData, deviceMode, loading]);
|
||||
|
||||
const _onRefresh = async () => {
|
||||
await doInBackground(async () => await Sync.run('local'));
|
||||
await Sync.run('local');
|
||||
if (refreshCallback) {
|
||||
refreshCallback();
|
||||
}
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
import {updateEvent} from '../components/DialogManager/recievers';
|
||||
import {Actions} from '../provider/Actions';
|
||||
import {doInBackground} from '../utils';
|
||||
import {db} from '../utils/DB';
|
||||
import {eOpenLoginDialog} from '../utils/Events';
|
||||
import {eSendEvent, ToastEvent} from './EventManager';
|
||||
import {
|
||||
beginBackgroundTask,
|
||||
endBackgroundTask,
|
||||
} from 'react-native-begin-background-task';
|
||||
import {Platform} from 'react-native';
|
||||
|
||||
const run = async (context = 'global') => {
|
||||
|
||||
updateEvent({
|
||||
type: Actions.SYNCING,
|
||||
syncing: true,
|
||||
});
|
||||
|
||||
try {
|
||||
await db.sync();
|
||||
await doInBackground(async () => {
|
||||
await db.sync();
|
||||
});
|
||||
ToastEvent.show({
|
||||
heading: 'Sync complete',
|
||||
type: 'success',
|
||||
@@ -56,7 +53,6 @@ const run = async (context = 'global') => {
|
||||
type: Actions.SYNCING,
|
||||
syncing: false,
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -195,10 +195,13 @@ export async function doInBackground(cb) {
|
||||
await cb();
|
||||
await endBackgroundTask(bgTaskId);
|
||||
} else {
|
||||
await BackgroundService.start(async () => {
|
||||
await cb();
|
||||
await BackgroundService.stop();
|
||||
},bgTaskOptions);
|
||||
return new Promise(async (res, rej) => {
|
||||
await BackgroundService.start(async () => {
|
||||
await cb();
|
||||
await BackgroundService.stop();
|
||||
res('done');
|
||||
}, bgTaskOptions);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||