mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
apply a possible fix for user logout
This commit is contained in:
@@ -1,45 +1,45 @@
|
|||||||
import NetInfo from '@react-native-community/netinfo';
|
import NetInfo from '@react-native-community/netinfo';
|
||||||
import {EV, EVENTS} from 'notes-core/common';
|
import { EV, EVENTS } from 'notes-core/common';
|
||||||
import React, {useEffect} from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import {Appearance, AppState, Linking, Platform} from 'react-native';
|
import { Appearance, AppState, Linking, Platform } from 'react-native';
|
||||||
import RNExitApp from 'react-native-exit-app';
|
import RNExitApp from 'react-native-exit-app';
|
||||||
import * as RNIap from 'react-native-iap';
|
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 SplashScreen from 'react-native-splash-screen';
|
||||||
import {updateEvent} from './src/components/DialogManager/recievers';
|
import { updateEvent } from './src/components/DialogManager/recievers';
|
||||||
import {useTracked} from './src/provider';
|
import { useTracked } from './src/provider';
|
||||||
import {Actions} from './src/provider/Actions';
|
import { Actions } from './src/provider/Actions';
|
||||||
import Backup from './src/services/Backup';
|
import Backup from './src/services/Backup';
|
||||||
import BiometricService from './src/services/BiometricService';
|
import BiometricService from './src/services/BiometricService';
|
||||||
import {
|
import {
|
||||||
eSendEvent,
|
eSendEvent,
|
||||||
eSubscribeEvent,
|
eSubscribeEvent,
|
||||||
eUnSubscribeEvent,
|
eUnSubscribeEvent,
|
||||||
ToastEvent,
|
ToastEvent
|
||||||
} from './src/services/EventManager';
|
} from './src/services/EventManager';
|
||||||
import {
|
import {
|
||||||
clearMessage,
|
clearMessage,
|
||||||
setEmailVerifyMessage,
|
setEmailVerifyMessage,
|
||||||
setLoginMessage,
|
setLoginMessage
|
||||||
} from './src/services/Message';
|
} from './src/services/Message';
|
||||||
import Navigation from './src/services/Navigation';
|
import Navigation from './src/services/Navigation';
|
||||||
import PremiumService from './src/services/PremiumService';
|
import PremiumService from './src/services/PremiumService';
|
||||||
import SettingsService from './src/services/SettingsService';
|
import SettingsService from './src/services/SettingsService';
|
||||||
import Sync from './src/services/Sync';
|
import Sync from './src/services/Sync';
|
||||||
import {APP_VERSION, editing} from './src/utils';
|
import { APP_VERSION, doInBackground, editing } from './src/utils';
|
||||||
import {updateStatusBarColor} from './src/utils/Colors';
|
import { updateStatusBarColor } from './src/utils/Colors';
|
||||||
import {db} from './src/utils/DB';
|
import { db } from './src/utils/DB';
|
||||||
import {
|
import {
|
||||||
eClearEditor,
|
eClearEditor,
|
||||||
eCloseProgressDialog,
|
eCloseProgressDialog,
|
||||||
eOpenLoginDialog,
|
eOpenLoginDialog,
|
||||||
eOpenProgressDialog,
|
eOpenProgressDialog,
|
||||||
refreshNotesPage,
|
refreshNotesPage
|
||||||
} from './src/utils/Events';
|
} from './src/utils/Events';
|
||||||
import {MMKV} from './src/utils/mmkv';
|
import { MMKV } from './src/utils/mmkv';
|
||||||
import Storage from './src/utils/storage';
|
import Storage from './src/utils/storage';
|
||||||
import {sleep} from './src/utils/TimeUtils';
|
import { sleep } from './src/utils/TimeUtils';
|
||||||
import {getNote, getWebviewInit} from './src/views/Editor/Functions';
|
import { getNote, getWebviewInit } from './src/views/Editor/Functions';
|
||||||
|
|
||||||
let prevTransactionId = null;
|
let prevTransactionId = null;
|
||||||
let subsriptionSuccessListener;
|
let subsriptionSuccessListener;
|
||||||
@@ -84,11 +84,12 @@ async function reconnectSSE(connection) {
|
|||||||
if (!state) {
|
if (!state) {
|
||||||
state = await NetInfo.fetch();
|
state = await NetInfo.fetch();
|
||||||
}
|
}
|
||||||
let user = await db.user.getUser();
|
await doInBackground(async () => {
|
||||||
|
let user = await db.user.getUser();
|
||||||
if (user && state.isConnected && state.isInternetReachable) {
|
if (user && state.isConnected && state.isInternetReachable) {
|
||||||
await db.connectSSE();
|
await db.connectSSE();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +231,7 @@ export const AppRootEvents = React.memo(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onAccountStatusChange = async userStatus => {
|
const onAccountStatusChange = async userStatus => {
|
||||||
console.log('account status',userStatus,PremiumService.get());
|
console.log('account status', userStatus, PremiumService.get());
|
||||||
if (!PremiumService.get() && userStatus.type === 5) {
|
if (!PremiumService.get() && userStatus.type === 5) {
|
||||||
eSendEvent(eOpenProgressDialog, {
|
eSendEvent(eOpenProgressDialog, {
|
||||||
title: 'Notesnook Pro',
|
title: 'Notesnook Pro',
|
||||||
@@ -247,15 +248,17 @@ export const AppRootEvents = React.memo(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const partialSync = async () => {
|
const partialSync = async () => {
|
||||||
try {
|
await doInBackground(async () => {
|
||||||
dispatch({type: Actions.SYNCING, syncing: true});
|
try {
|
||||||
await db.sync(false);
|
dispatch({type: Actions.SYNCING, syncing: true});
|
||||||
dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});
|
await db.sync(false);
|
||||||
} catch (e) {
|
dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});
|
||||||
dispatch({type: Actions.SYNCING, syncing: false});
|
} catch (e) {
|
||||||
} finally {
|
dispatch({type: Actions.SYNCING, syncing: false});
|
||||||
dispatch({type: Actions.SYNCING, syncing: false});
|
} finally {
|
||||||
}
|
dispatch({type: Actions.SYNCING, syncing: false});
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onLogout = async reason => {
|
const onLogout = async reason => {
|
||||||
@@ -293,6 +296,8 @@ export const AppRootEvents = React.memo(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const setCurrentUser = async login => {
|
const setCurrentUser = async login => {
|
||||||
|
await doInBackground(async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let user = await db.user.getUser();
|
let user = await db.user.getUser();
|
||||||
if (user) {
|
if (user) {
|
||||||
@@ -326,6 +331,9 @@ export const AppRootEvents = React.memo(
|
|||||||
eSendEvent(eCloseProgressDialog);
|
eSendEvent(eCloseProgressDialog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSuccessfulSubscription = async subscription => {
|
const onSuccessfulSubscription = async subscription => {
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="#FFFFFF">
|
||||||
|
<group android:scaleX="0.12527233"
|
||||||
|
android:scaleY="0.12527233"
|
||||||
|
android:translateX="5.3605666"
|
||||||
|
android:translateY="-1.5294118">
|
||||||
|
<group android:translateY="151.2">
|
||||||
|
<path android:pathData="M95.904,0L75.744,0L30.096,-68.976L30.096,0L9.936,0L9.936,-100.656L30.096,-100.656L75.744,-31.536L75.744,-100.656L95.904,-100.656Z"
|
||||||
|
android:fillColor="#000000"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</vector>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 215 B |
Binary file not shown.
|
After Width: | Height: | Size: 188 B |
Binary file not shown.
|
After Width: | Height: | Size: 270 B |
Binary file not shown.
|
After Width: | Height: | Size: 346 B |
Binary file not shown.
|
After Width: | Height: | Size: 211 B |
@@ -8,7 +8,9 @@
|
|||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".MainApplication"
|
android:name=".MainApplication"
|
||||||
@@ -74,6 +76,7 @@
|
|||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:stopWithTask="false" />
|
android:stopWithTask="false" />
|
||||||
|
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" />
|
||||||
<provider
|
<provider
|
||||||
android:name="com.vinzscam.reactnativefileviewer.FileProvider"
|
android:name="com.vinzscam.reactnativefileviewer.FileProvider"
|
||||||
android:authorities="${applicationId}.provider"
|
android:authorities="${applicationId}.provider"
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -74,7 +74,7 @@ function init_tiny(size) {
|
|||||||
table_toolbar:
|
table_toolbar:
|
||||||
'tablecellprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol',
|
'tablecellprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol',
|
||||||
imagetools_toolbar:
|
imagetools_toolbar:
|
||||||
'rotateleft rotateright | flipv fliph | imageoptions | deleteimage | imagepreview',
|
'rotateleft rotateright flipv fliph | imageoptions | deleteimage | imagepreview',
|
||||||
placeholder: 'Start writing your note here',
|
placeholder: 'Start writing your note here',
|
||||||
object_resizing: true,
|
object_resizing: true,
|
||||||
resize: true,
|
resize: true,
|
||||||
@@ -91,10 +91,10 @@ function init_tiny(size) {
|
|||||||
'Classic=courier new;' +
|
'Classic=courier new;' +
|
||||||
'Mono=monospace;',
|
'Mono=monospace;',
|
||||||
setup: function (editor) {
|
setup: function (editor) {
|
||||||
|
|
||||||
editor.ui.registry.addButton('deleteimage', {
|
editor.ui.registry.addButton('deleteimage', {
|
||||||
icon: 'remove',
|
icon: 'remove',
|
||||||
//image: 'http://p.yusukekamiyamane.com/icons/search/fugue/icons/calendar-blue.png',
|
tooltip: 'Remove image',
|
||||||
tooltip: 'Remove image',
|
|
||||||
onAction: function () {
|
onAction: function () {
|
||||||
tinymce.activeEditor.execCommand('Delete');
|
tinymce.activeEditor.execCommand('Delete');
|
||||||
},
|
},
|
||||||
@@ -104,7 +104,6 @@ function init_tiny(size) {
|
|||||||
});
|
});
|
||||||
editor.ui.registry.addButton('imagepreview', {
|
editor.ui.registry.addButton('imagepreview', {
|
||||||
icon: 'fullscreen',
|
icon: 'fullscreen',
|
||||||
//image: 'http://p.yusukekamiyamane.com/icons/search/fugue/icons/calendar-blue.png',
|
|
||||||
tooltip: 'Preview image',
|
tooltip: 'Preview image',
|
||||||
onAction: function () {
|
onAction: function () {
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,8 @@
|
|||||||
}
|
}
|
||||||
.htmldiff_div {
|
.htmldiff_div {
|
||||||
padding:12px !important;
|
padding:12px !important;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -28,6 +28,6 @@ public class OnClearFromRecentService extends Service {
|
|||||||
MMKV mmkv = MMKV.mmkvWithID("default",MMKV.SINGLE_PROCESS_MODE);
|
MMKV mmkv = MMKV.mmkvWithID("default",MMKV.SINGLE_PROCESS_MODE);
|
||||||
mmkv.removeValueForKey("appState");
|
mmkv.removeValueForKey("appState");
|
||||||
stopSelf();
|
stopSelf();
|
||||||
System.exit(0);
|
//System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1600,7 +1600,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
/usr/lib/swift,
|
/usr/lib/swift,
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
@@ -1658,7 +1658,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
/usr/lib/swift,
|
/usr/lib/swift,
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
|
|||||||
@@ -60,6 +60,30 @@
|
|||||||
ReferencedContainer = "container:Notesnook.xcodeproj">
|
ReferencedContainer = "container:Notesnook.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildableProductRunnable>
|
</BuildableProductRunnable>
|
||||||
|
<EnvironmentVariables>
|
||||||
|
<EnvironmentVariable
|
||||||
|
key = "NSZombieEnabled"
|
||||||
|
value = "YES"
|
||||||
|
isEnabled = "YES">
|
||||||
|
</EnvironmentVariable>
|
||||||
|
<EnvironmentVariable
|
||||||
|
key = "NSDebugEnabled"
|
||||||
|
value = "YES"
|
||||||
|
isEnabled = "YES">
|
||||||
|
</EnvironmentVariable>
|
||||||
|
<EnvironmentVariable
|
||||||
|
key = "NSAutoreleaseFreedObjectCheckEnabled"
|
||||||
|
value = "YES"
|
||||||
|
isEnabled = "YES">
|
||||||
|
</EnvironmentVariable>
|
||||||
|
</EnvironmentVariables>
|
||||||
|
<AdditionalOptions>
|
||||||
|
<AdditionalOption
|
||||||
|
key = "NSZombieEnabled"
|
||||||
|
value = "YES"
|
||||||
|
isEnabled = "YES">
|
||||||
|
</AdditionalOption>
|
||||||
|
</AdditionalOptions>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
buildConfiguration = "Release"
|
buildConfiguration = "Release"
|
||||||
|
|||||||
@@ -90,6 +90,10 @@
|
|||||||
<key>UIApplicationSupportsMultipleScenes</key>
|
<key>UIApplicationSupportsMultipleScenes</key>
|
||||||
<false/>
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>UIBackgroundModes</key>
|
||||||
|
<array>
|
||||||
|
<string>processing</string>
|
||||||
|
</array>
|
||||||
<key>UIFileSharingEnabled</key>
|
<key>UIFileSharingEnabled</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>UILaunchStoryboardName</key>
|
<key>UILaunchStoryboardName</key>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require_relative '../node_modules/react-native/scripts/react_native_pods'
|
require_relative '../node_modules/react-native/scripts/react_native_pods'
|
||||||
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
|
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
|
||||||
|
|
||||||
platform :ios, '10.0'
|
platform :ios, '11.0'
|
||||||
|
|
||||||
permissions_path = '../node_modules/react-native-permissions/ios'
|
permissions_path = '../node_modules/react-native-permissions/ios'
|
||||||
|
|
||||||
|
|||||||
@@ -236,6 +236,8 @@ PODS:
|
|||||||
- React-jsi (= 0.64.0)
|
- React-jsi (= 0.64.0)
|
||||||
- React-perflogger (= 0.64.0)
|
- React-perflogger (= 0.64.0)
|
||||||
- React-jsinspector (0.64.0)
|
- React-jsinspector (0.64.0)
|
||||||
|
- react-native-begin-background-task (0.1.0):
|
||||||
|
- React
|
||||||
- react-native-document-picker (4.1.1):
|
- react-native-document-picker (4.1.1):
|
||||||
- React-Core
|
- React-Core
|
||||||
- react-native-fingerprint-scanner (5.0.0):
|
- react-native-fingerprint-scanner (5.0.0):
|
||||||
@@ -411,6 +413,7 @@ DEPENDENCIES:
|
|||||||
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
|
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
|
||||||
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
|
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
|
||||||
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
|
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
|
||||||
|
- react-native-begin-background-task (from `../node_modules/react-native-begin-background-task`)
|
||||||
- react-native-document-picker (from `../node_modules/react-native-document-picker`)
|
- react-native-document-picker (from `../node_modules/react-native-document-picker`)
|
||||||
- react-native-fingerprint-scanner (from `../node_modules/react-native-fingerprint-scanner`)
|
- react-native-fingerprint-scanner (from `../node_modules/react-native-fingerprint-scanner`)
|
||||||
- react-native-get-random-values (from `../node_modules/react-native-get-random-values`)
|
- react-native-get-random-values (from `../node_modules/react-native-get-random-values`)
|
||||||
@@ -508,6 +511,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
|
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
|
||||||
React-jsinspector:
|
React-jsinspector:
|
||||||
:path: "../node_modules/react-native/ReactCommon/jsinspector"
|
:path: "../node_modules/react-native/ReactCommon/jsinspector"
|
||||||
|
react-native-begin-background-task:
|
||||||
|
:path: "../node_modules/react-native-begin-background-task"
|
||||||
react-native-document-picker:
|
react-native-document-picker:
|
||||||
:path: "../node_modules/react-native-document-picker"
|
:path: "../node_modules/react-native-document-picker"
|
||||||
react-native-fingerprint-scanner:
|
react-native-fingerprint-scanner:
|
||||||
@@ -639,6 +644,7 @@ SPEC CHECKSUMS:
|
|||||||
React-jsi: 74341196d9547cbcbcfa4b3bbbf03af56431d5a1
|
React-jsi: 74341196d9547cbcbcfa4b3bbbf03af56431d5a1
|
||||||
React-jsiexecutor: 06a9c77b56902ae7ffcdd7a4905f664adc5d237b
|
React-jsiexecutor: 06a9c77b56902ae7ffcdd7a4905f664adc5d237b
|
||||||
React-jsinspector: 0ae35a37b20d5e031eb020a69cc5afdbd6406301
|
React-jsinspector: 0ae35a37b20d5e031eb020a69cc5afdbd6406301
|
||||||
|
react-native-begin-background-task: 3b889e07458afc5822a7277cf9cbc7cd077e39ee
|
||||||
react-native-document-picker: c9cbeb5445188a805ab19fa4061115d38fe1ea63
|
react-native-document-picker: c9cbeb5445188a805ab19fa4061115d38fe1ea63
|
||||||
react-native-fingerprint-scanner: be63e626b31fb951780a5fac5328b065a61a3d6e
|
react-native-fingerprint-scanner: be63e626b31fb951780a5fac5328b065a61a3d6e
|
||||||
react-native-get-random-values: 1404bd5cc0ab0e287f75ee1c489555688fc65f89
|
react-native-get-random-values: 1404bd5cc0ab0e287f75ee1c489555688fc65f89
|
||||||
@@ -692,6 +698,6 @@ SPEC CHECKSUMS:
|
|||||||
toolbar-android: 85f3ef4d691469f2d304e7dee4bca013aa1ba1ff
|
toolbar-android: 85f3ef4d691469f2d304e7dee4bca013aa1ba1ff
|
||||||
Yoga: 8c8436d4171c87504c648ae23b1d81242bdf3bbf
|
Yoga: 8c8436d4171c87504c648ae23b1d81242bdf3bbf
|
||||||
|
|
||||||
PODFILE CHECKSUM: b0855a87f6220ed2901b0f35ebbd45aa7795a696
|
PODFILE CHECKSUM: 09d36b8defe185bc54169d76956faad114955e6e
|
||||||
|
|
||||||
COCOAPODS: 1.10.1
|
COCOAPODS: 1.10.1
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
} from '../../services/EventManager';
|
} from '../../services/EventManager';
|
||||||
import Navigation from '../../services/Navigation';
|
import Navigation from '../../services/Navigation';
|
||||||
import Sync from '../../services/Sync';
|
import Sync from '../../services/Sync';
|
||||||
import { editing, toTXT } from '../../utils';
|
import { doInBackground, editing, toTXT } from '../../utils';
|
||||||
import {
|
import {
|
||||||
ACCENT,
|
ACCENT,
|
||||||
COLOR_SCHEME,
|
COLOR_SCHEME,
|
||||||
@@ -659,7 +659,7 @@ export const ActionSheetComponent = ({
|
|||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
activeOpacity={0.9}
|
activeOpacity={0.9}
|
||||||
testID={notesnook.ids.dialogs.actionsheet.sync}
|
testID={notesnook.ids.dialogs.actionsheet.sync}
|
||||||
onPress={async () => await Sync.run('local')}
|
onPress={async () => await doInBackground(()=>Sync.run('local'))}
|
||||||
style={{
|
style={{
|
||||||
borderColor: colors.accent,
|
borderColor: colors.accent,
|
||||||
paddingHorizontal: 5,
|
paddingHorizontal: 5,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {useTracked} from '../../provider';
|
|||||||
import {DDS} from '../../services/DeviceDetection';
|
import {DDS} from '../../services/DeviceDetection';
|
||||||
import {eSendEvent, ToastEvent} from '../../services/EventManager';
|
import {eSendEvent, ToastEvent} from '../../services/EventManager';
|
||||||
import Sync from '../../services/Sync';
|
import Sync from '../../services/Sync';
|
||||||
|
import { doInBackground } from '../../utils';
|
||||||
import {eOpenLoginDialog} from '../../utils/Events';
|
import {eOpenLoginDialog} from '../../utils/Events';
|
||||||
import {SIZE} from '../../utils/SizeUtils';
|
import {SIZE} from '../../utils/SizeUtils';
|
||||||
import Heading from '../Typography/Heading';
|
import Heading from '../Typography/Heading';
|
||||||
@@ -81,7 +82,7 @@ export const UserSection = () => {
|
|||||||
{user && (
|
{user && (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
activeOpacity={0.8}
|
activeOpacity={0.8}
|
||||||
onPress={() => Sync.run()}
|
onPress={async () => await doInBackground(async ()=>await Sync.run('local'))}
|
||||||
style={{
|
style={{
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {useTracked} from '../../provider';
|
|||||||
import {DDS} from '../../services/DeviceDetection';
|
import {DDS} from '../../services/DeviceDetection';
|
||||||
import {eSendEvent} from '../../services/EventManager';
|
import {eSendEvent} from '../../services/EventManager';
|
||||||
import Sync from '../../services/Sync';
|
import Sync from '../../services/Sync';
|
||||||
import {dHeight, dWidth} from '../../utils';
|
import {dHeight, doInBackground, dWidth} from '../../utils';
|
||||||
import {COLORS_NOTE} from '../../utils/Colors';
|
import {COLORS_NOTE} from '../../utils/Colors';
|
||||||
import {eScrollEvent} from '../../utils/Events';
|
import {eScrollEvent} from '../../utils/Events';
|
||||||
import JumpToDialog from '../JumpToDialog';
|
import JumpToDialog from '../JumpToDialog';
|
||||||
@@ -40,7 +40,7 @@ const SimpleList = ({
|
|||||||
headerProps = {
|
headerProps = {
|
||||||
heading: 'Home',
|
heading: 'Home',
|
||||||
},
|
},
|
||||||
screen
|
screen,
|
||||||
}) => {
|
}) => {
|
||||||
const [state] = useTracked();
|
const [state] = useTracked();
|
||||||
const {colors, deviceMode, messageBoardState} = state;
|
const {colors, deviceMode, messageBoardState} = state;
|
||||||
@@ -50,11 +50,11 @@ const SimpleList = ({
|
|||||||
return r1 !== r2;
|
return r1 !== r2;
|
||||||
}).cloneWithRows([header, empty]),
|
}).cloneWithRows([header, empty]),
|
||||||
);
|
);
|
||||||
const [width,setWidth] = useState(dWidth)
|
const [width, setWidth] = useState(dWidth);
|
||||||
const scrollRef = useRef();
|
const scrollRef = useRef();
|
||||||
|
|
||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
|
|
||||||
const {fontScale} = useWindowDimensions();
|
const {fontScale} = useWindowDimensions();
|
||||||
const refreshing = false;
|
const refreshing = false;
|
||||||
const dataType = type;
|
const dataType = type;
|
||||||
@@ -79,7 +79,7 @@ const SimpleList = ({
|
|||||||
}, [listData, deviceMode, loading]);
|
}, [listData, deviceMode, loading]);
|
||||||
|
|
||||||
const _onRefresh = async () => {
|
const _onRefresh = async () => {
|
||||||
await Sync.run();
|
await doInBackground(async () => await Sync.run('local'));
|
||||||
if (refreshCallback) {
|
if (refreshCallback) {
|
||||||
refreshCallback();
|
refreshCallback();
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ const SimpleList = ({
|
|||||||
let y = event.nativeEvent.contentOffset.y;
|
let y = event.nativeEvent.contentOffset.y;
|
||||||
eSendEvent(eScrollEvent, {
|
eSendEvent(eScrollEvent, {
|
||||||
y,
|
y,
|
||||||
screen
|
screen,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -213,7 +213,6 @@ const SimpleList = ({
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
tintColor={colors.accent}
|
tintColor={colors.accent}
|
||||||
colors={[colors.accent]}
|
colors={[colors.accent]}
|
||||||
progressViewOffset={150}
|
progressViewOffset={150}
|
||||||
@@ -236,8 +235,8 @@ const SimpleList = ({
|
|||||||
height: '100%',
|
height: '100%',
|
||||||
backgroundColor: colors.bg,
|
backgroundColor: colors.bg,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
minHeight: 1,
|
minHeight: 1,
|
||||||
minWidth: 1
|
minWidth: 1,
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -254,7 +253,6 @@ const SimpleList = ({
|
|||||||
dataProvider={dataProvider}
|
dataProvider={dataProvider}
|
||||||
rowRenderer={_renderRow}
|
rowRenderer={_renderRow}
|
||||||
onScroll={_onScroll}
|
onScroll={_onScroll}
|
||||||
|
|
||||||
canChangeSize={true}
|
canChangeSize={true}
|
||||||
renderFooter={listData.length === 0 ? null : Footer}
|
renderFooter={listData.length === 0 ? null : Footer}
|
||||||
scrollViewProps={scrollProps}
|
scrollViewProps={scrollProps}
|
||||||
|
|||||||
@@ -2,9 +2,15 @@ import {updateEvent} from '../components/DialogManager/recievers';
|
|||||||
import {Actions} from '../provider/Actions';
|
import {Actions} from '../provider/Actions';
|
||||||
import {db} from '../utils/DB';
|
import {db} from '../utils/DB';
|
||||||
import {eOpenLoginDialog} from '../utils/Events';
|
import {eOpenLoginDialog} from '../utils/Events';
|
||||||
import {eSendEvent, ToastEvent, } from './EventManager';
|
import {eSendEvent, ToastEvent} from './EventManager';
|
||||||
|
import {
|
||||||
|
beginBackgroundTask,
|
||||||
|
endBackgroundTask,
|
||||||
|
} from 'react-native-begin-background-task';
|
||||||
|
import {Platform} from 'react-native';
|
||||||
|
|
||||||
const run = async (context = 'global') => {
|
const run = async (context = 'global') => {
|
||||||
|
|
||||||
updateEvent({
|
updateEvent({
|
||||||
type: Actions.SYNCING,
|
type: Actions.SYNCING,
|
||||||
syncing: true,
|
syncing: true,
|
||||||
@@ -13,16 +19,16 @@ const run = async (context = 'global') => {
|
|||||||
try {
|
try {
|
||||||
await db.sync();
|
await db.sync();
|
||||||
ToastEvent.show({
|
ToastEvent.show({
|
||||||
heading:"Sync complete",
|
heading: 'Sync complete',
|
||||||
type:"success",
|
type: 'success',
|
||||||
message: "All your notes are encrypted and synced successfully!",
|
message: 'All your notes are encrypted and synced successfully!',
|
||||||
context: context,
|
context: context,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.message === 'You need to login to sync.') {
|
if (e.message === 'You need to login to sync.') {
|
||||||
ToastEvent.show({
|
ToastEvent.show({
|
||||||
heading:"Enable sync",
|
heading: 'Enable sync',
|
||||||
message: "Login to encrypt and sync notes.",
|
message: 'Login to encrypt and sync notes.',
|
||||||
context: context,
|
context: context,
|
||||||
func: () => {
|
func: () => {
|
||||||
eSendEvent(eOpenLoginDialog);
|
eSendEvent(eOpenLoginDialog);
|
||||||
@@ -35,7 +41,7 @@ const run = async (context = 'global') => {
|
|||||||
syncing: false,
|
syncing: false,
|
||||||
});
|
});
|
||||||
ToastEvent.show({
|
ToastEvent.show({
|
||||||
heading:"Sync failed",
|
heading: 'Sync failed',
|
||||||
message: e.message,
|
message: e.message,
|
||||||
context: context,
|
context: context,
|
||||||
});
|
});
|
||||||
@@ -50,6 +56,7 @@ const run = async (context = 'global') => {
|
|||||||
type: Actions.SYNCING,
|
type: Actions.SYNCING,
|
||||||
syncing: false,
|
syncing: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ import {MMKV} from './mmkv';
|
|||||||
import {tabBarRef} from './Refs';
|
import {tabBarRef} from './Refs';
|
||||||
import {SIZE} from './SizeUtils';
|
import {SIZE} from './SizeUtils';
|
||||||
import FastImage from 'react-native-fast-image';
|
import FastImage from 'react-native-fast-image';
|
||||||
|
import BackgroundService from 'react-native-background-actions';
|
||||||
|
import {
|
||||||
|
beginBackgroundTask,
|
||||||
|
endBackgroundTask,
|
||||||
|
} from 'react-native-begin-background-task';
|
||||||
|
|
||||||
const imgNames = [
|
const imgNames = [
|
||||||
'favorites',
|
'favorites',
|
||||||
'notes',
|
'notes',
|
||||||
@@ -128,7 +134,7 @@ export const editing = {
|
|||||||
focusType: null,
|
focusType: null,
|
||||||
movedAway: true,
|
movedAway: true,
|
||||||
tooltip: false,
|
tooltip: false,
|
||||||
isRestoringState:false
|
isRestoringState: false,
|
||||||
};
|
};
|
||||||
export const selection = {
|
export const selection = {
|
||||||
data: [],
|
data: [],
|
||||||
@@ -171,6 +177,31 @@ export async function showContext(event, title) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const bgTaskOptions = {
|
||||||
|
taskName: 'notesnookSync',
|
||||||
|
taskTitle: 'Notesnook Sync',
|
||||||
|
taskDesc: 'Syncing your notes.',
|
||||||
|
taskIcon: {
|
||||||
|
name: 'ic_stat_name',
|
||||||
|
type: 'drawable',
|
||||||
|
},
|
||||||
|
color: '#ffffff',
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function doInBackground(cb) {
|
||||||
|
if (Platform.OS === 'ios') {
|
||||||
|
let bgTaskId;
|
||||||
|
bgTaskId = await beginBackgroundTask();
|
||||||
|
await cb();
|
||||||
|
await endBackgroundTask(bgTaskId);
|
||||||
|
} else {
|
||||||
|
await BackgroundService.start(async () => {
|
||||||
|
await cb();
|
||||||
|
await BackgroundService.stop();
|
||||||
|
},bgTaskOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export let dWidth = Dimensions.get('window').width;
|
export let dWidth = Dimensions.get('window').width;
|
||||||
export let dHeight = Dimensions.get('window').height;
|
export let dHeight = Dimensions.get('window').height;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
import React, {useCallback, useEffect, useState} from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import {ContainerBottomButton} from '../../components/Container/ContainerBottomButton';
|
import { ContainerBottomButton } from '../../components/Container/ContainerBottomButton';
|
||||||
import {ContainerTopSection} from '../../components/Container/ContainerTopSection';
|
import { ContainerTopSection } from '../../components/Container/ContainerTopSection';
|
||||||
|
import { Header } from '../../components/Header/index';
|
||||||
|
import SelectionHeader from '../../components/SelectionHeader';
|
||||||
import SimpleList from '../../components/SimpleList';
|
import SimpleList from '../../components/SimpleList';
|
||||||
import {useTracked} from '../../provider';
|
import { useTracked } from '../../provider';
|
||||||
import {Actions} from '../../provider/Actions';
|
import { Actions } from '../../provider/Actions';
|
||||||
import {DDS} from '../../services/DeviceDetection';
|
import { DDS } from '../../services/DeviceDetection';
|
||||||
import {eSendEvent} from '../../services/EventManager';
|
import { eSendEvent } from '../../services/EventManager';
|
||||||
import Navigation from '../../services/Navigation';
|
import Navigation from '../../services/Navigation';
|
||||||
import SearchService from '../../services/SearchService';
|
import SearchService from '../../services/SearchService';
|
||||||
import {InteractionManager, scrollRef} from '../../utils';
|
import { InteractionManager, scrollRef } from '../../utils';
|
||||||
import {db} from '../../utils/DB';
|
import { db } from '../../utils/DB';
|
||||||
import {eOnLoadNote, eScrollEvent} from '../../utils/Events';
|
import { eOnLoadNote, eScrollEvent } from '../../utils/Events';
|
||||||
import {tabBarRef} from '../../utils/Refs';
|
import { tabBarRef } from '../../utils/Refs';
|
||||||
import {Header} from '../../components/Header/index';
|
|
||||||
import SelectionHeader from '../../components/SelectionHeader';
|
|
||||||
export const Home = ({route, navigation}) => {
|
export const Home = ({route, navigation}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {loading} = state;
|
const {loading} = state;
|
||||||
@@ -105,6 +105,7 @@ export const Home = ({route, navigation}) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const _onPressBottomButton = async () => {
|
const _onPressBottomButton = async () => {
|
||||||
|
|
||||||
if (!DDS.isLargeTablet()) {
|
if (!DDS.isLargeTablet()) {
|
||||||
eSendEvent(eOnLoadNote, {type: 'new'});
|
eSendEvent(eOnLoadNote, {type: 'new'});
|
||||||
tabBarRef.current?.goToPage(1);
|
tabBarRef.current?.goToPage(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user