minor updates in ui

This commit is contained in:
ammarahm-ed
2020-12-09 13:11:21 +05:00
parent 179ea43b5f
commit c8f0c44edd
10 changed files with 228587 additions and 28 deletions

View File

@@ -0,0 +1,215 @@
// Initialize some variables before react-native code would access them
var onmessage=null, self=global;
// Cache Node's original require as __debug__.require
global.__debug__={require: require};
// Prevent leaking process.versions from debugger process to
// worker because pure React Native doesn't do that and some packages as js-md5 rely on this behavior
Object.defineProperty(process, "versions", {
value: undefined
});
// TODO: Replace by url.fileURLToPath method when Node 10 LTS become deprecated
function fileUrlToPath(url) {
if (process.platform === 'win32') {
return url.toString().replace('file:///', '');
} else {
return url.toString().replace('file://', '');
}
}
function getNativeModules() {
var NativeModules;
try {
// This approach is for old RN versions
NativeModules = global.require('NativeModules');
} catch (err) {
// ignore error and try another way for more recent RN versions
try {
var nativeModuleId;
var modules = global.__r.getModules();
var ids = Object.keys(modules);
for (var i = 0; i < ids.length; i++) {
if (modules[ids[i]].verboseName) {
var packagePath = new String(modules[ids[i]].verboseName);
if (packagePath.indexOf('react-native/Libraries/BatchedBridge/NativeModules.js') > 0) {
nativeModuleId = parseInt(ids[i], 10);
break;
}
}
}
if (nativeModuleId) {
NativeModules = global.__r(nativeModuleId);
}
}
catch (err) {
// suppress errors
}
}
return NativeModules;
}
// Originally, this was made for iOS only
var vscodeHandlers = {
'vscode_reloadApp': function () {
var NativeModules = getNativeModules();
if (NativeModules && NativeModules.DevMenu) {
NativeModules.DevMenu.reload();
}
},
'vscode_showDevMenu': function () {
var NativeModules = getNativeModules();
if (NativeModules && NativeModules.DevMenu) {
NativeModules.DevMenu.show();
}
}
};
process.on("message", function (message) {
if (message.data && vscodeHandlers[message.data.method]) {
vscodeHandlers[message.data.method]();
} else if(onmessage) {
onmessage(message);
}
});
var postMessage = function(message){
process.send(message);
};
if (!self.postMessage) {
self.postMessage = postMessage;
}
var importScripts = (function(){
var fs=require('fs'), vm=require('vm');
return function(scriptUrl){
scriptUrl = fileUrlToPath(scriptUrl);
var scriptCode = fs.readFileSync(scriptUrl, 'utf8');
// Add a 'debugger;' statement to stop code execution
// to wait for the sourcemaps to be processed by the debug adapter
vm.runInThisContext('debugger;' + scriptCode, {filename: scriptUrl});
};
})();
// Worker is ran as nodejs process, so console.trace() writes to stderr and it leads to error in native app
// To avoid this console.trace() is overridden to print stacktrace via console.log()
// Please, see Node JS implementation: https://github.com/nodejs/node/blob/master/lib/internal/console/constructor.js
console.trace = (function() {
return function() {
try {
var err = {
name: 'Trace',
message: require('util').format.apply(null, arguments)
};
// Node uses 10, but usually it's not enough for RN app trace
Error.stackTraceLimit = 30;
Error.captureStackTrace(err, console.trace);
console.log(err.stack);
} catch (e) {
console.error(e);
}
};
})();
// As worker is ran in node, it breaks broadcast-channels package approach of identifying if its ran in node:
// https://github.com/pubkey/broadcast-channel/blob/master/src/util.js#L64
// To avoid it if process.toString() is called if will return empty string instead of [object process].
var nativeObjectToString = Object.prototype.toString;
Object.prototype.toString = function() {
if (this === process) {
return '';
} else {
return nativeObjectToString.call(this);
}
};
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
/* global __fbBatchedBridge, self, importScripts, postMessage, onmessage: true */
/* eslint no-unused-vars: 0 */
onmessage = function () {
var visibilityState;
var showVisibilityWarning = function () {
var hasWarned = false;
return function () {
// Wait until `YellowBox` gets initialized before displaying the warning.
if (hasWarned || console.warn.toString().includes('[native code]')) {
return;
}
hasWarned = true;
console.warn('Remote debugger is in a background tab which may cause apps to ' + 'perform slowly. Fix this by foregrounding the tab (or opening it in ' + 'a separate window).');
};
}();
var messageHandlers = {
executeApplicationScript: function (message, sendReply) {
for (var key in message.inject) {
self[key] = JSON.parse(message.inject[key]);
}
var error;
try {
importScripts(message.url);
} catch (err) {
error = err.message;
}
sendReply(null
/* result */
, error);
},
setDebuggerVisibility: function (message) {
visibilityState = message.visibilityState;
}
};
return function (message) {
if (visibilityState === 'hidden') {
showVisibilityWarning();
}
var object = message.data;
var sendReply = function (result, error) {
postMessage({
replyID: object.id,
result: result,
error: error
});
};
var handler = messageHandlers[object.method];
if (handler) {
// Special cased handlers
handler(object, sendReply);
} else {
// Other methods get called on the bridge
var returnValue = [[], [], [], 0];
var error;
try {
if (typeof __fbBatchedBridge === 'object') {
returnValue = __fbBatchedBridge[object.method].apply(null, object.arguments);
} else {
error = 'Failed to call function, __fbBatchedBridge is undefined';
}
} catch (err) {
error = err.message;
} finally {
sendReply(JSON.stringify(returnValue), error);
}
}
};
}();
//# sourceMappingURL=debuggerWorker.js.map
// Notify debugger that we're done with loading
// and started listening for IPC messages
postMessage({workerLoaded:true});

228308
apps/mobile/.vscode/.react/index.bundle vendored Normal file

File diff suppressed because one or more lines are too long

1
apps/mobile/.vscode/.react/index.map vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -201,7 +201,6 @@ const AppStack = React.memo(
function setDeviceMode(current, size) {
eSendEvent(current !== 'mobile' ? eCloseSideMenu : eOpenSideMenu);
setMode(current);
console.log(current, 'DEVICE MODE');
dispatch({type: Actions.DEVICE_MODE, state: current});
dispatch({type: Actions.FULLSCREEN, state: false});
editorRef.current?.setNativeProps({

View File

@@ -16,7 +16,6 @@ export const HeaderLeftMenu = () => {
}
Navigation.goBack();
};
return (
<>
{deviceMode === 'mobile' || currentScreen === 'search' ? (

View File

@@ -1,5 +1,5 @@
import React, {createRef, useEffect, useState} from 'react';
import {Modal, TouchableOpacity, View} from 'react-native';
import {ActivityIndicator, Modal, TouchableOpacity, View} from 'react-native';
import {TextInput} from 'react-native-gesture-handler';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
@@ -31,14 +31,18 @@ import {
import {pv, SIZE, WEIGHT} from '../../utils/SizeUtils';
import {sleep} from '../../utils/TimeUtils';
import {ActionIcon} from '../ActionIcon';
import BaseDialog from '../Dialog/base-dialog';
import DialogContainer from '../Dialog/dialog-container';
import DialogHeader from '../Dialog/dialog-header';
import {ListHeaderComponent} from '../SimpleList/ListHeaderComponent';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
const LoginDialog = () => {
const [state, dispatch] = useTracked();
const colors = state.colors;
const [visible, setVisible] = useState(false);
const [status, setStatus] = useState('Logging you in');
const [status, setStatus] = useState(null);
const [loggingIn, setLoggingIn] = useState(false);
const [email, setEmail] = useState(null);
const [password, setPassword] = useState(null);
@@ -108,19 +112,17 @@ const LoginDialog = () => {
setStatus('Logging in');
try {
let res = await db.user.login(username.toLowerCase(), password);
await db.user.login(username.toLowerCase(), password);
} catch (e) {
setTimeout(() => {
ToastEvent.show(e.message, 'error', 'local');
setLoggingIn(false);
}, 500);
ToastEvent.show(e.message, 'error', 'local');
setLoggingIn(false);
return;
}
try {
let user = await db.user.get();
if (!user) throw new Error('Username or passoword incorrect!');
setStatus('Syncing your notes');
setStatus('Syncing Data');
dispatch({type: Actions.USER, user: user});
await db.sync();
eSendEvent(eStartSyncer);
@@ -174,7 +176,7 @@ const LoginDialog = () => {
if (!validateInfo()) return;
setSigningIn(true);
setStatus('Creating your account');
setStatus('Creating User');
try {
await db.user.signup(username, email, password);
} catch (e) {
@@ -209,6 +211,32 @@ const LoginDialog = () => {
onRequestClose={close}
visible={true}
transparent={true}>
{status && (loggingIn || signingIn) ? (
<BaseDialog visible={true}>
<DialogContainer>
<View
style={{
justifyContent: 'center',
alignItems: 'center',
marginBottom: 10,
}}>
<Heading>{status}</Heading>
<Paragraph style={{textAlign: 'center'}}>
{loggingIn
? 'Please wait while we log in and sync your data.'
: 'Please wait while we are setting up your account.'}
<Paragraph color={colors.errorText}>
{' '}
Do not close the app.
</Paragraph>
</Paragraph>
</View>
<ActivityIndicator color={colors.accent} />
</DialogContainer>
</BaseDialog>
) : null}
<View
style={{
opacity: 1,

View File

@@ -4,7 +4,7 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {useTracked} from '../../provider';
import {Actions} from '../../provider/Actions';
import {eSendEvent, ToastEvent} from '../../services/EventManager';
import {SUBSCRIPTION_STATUS_STRINGS} from '../../utils';
import {getElevation, SUBSCRIPTION_STATUS_STRINGS} from '../../utils';
import {db} from '../../utils/DB';
import {eOpenLoginDialog} from '../../utils/Events';
import {pv, SIZE} from '../../utils/SizeUtils';
@@ -23,6 +23,7 @@ export const UserSection = ({noTextMode}) => {
borderRadius: 5,
alignSelf: 'center',
backgroundColor: colors.shade,
marginTop:10,
}}>
<View
style={{

View File

@@ -8,6 +8,8 @@ const MS_DAY = 86400000;
const MS_WEEK = MS_DAY * 7;
async function run() {
console.log('exporting backup data');
if (Platform.OS === 'android') {
let granted = await storage.requestPermission();
if (!granted) {
@@ -18,7 +20,9 @@ async function run() {
let backup;
let error;
try {
backup = await db.backup.export('mobile');
console.log('exporting backup data');
backup = await db.backup.export('mobile',false);
console.log('backup data gotten');
} catch (e) {
console.log('error', e);
error = true;

View File

@@ -2,9 +2,10 @@ import { db } from "../utils/DB";
import { eOpenPremiumDialog } from "../utils/Events";
import { eSendEvent } from "./EventManager";
let premiumStatus = null;
let premiumStatus = true;
async function setPremiumStatus() {
async function setPremiumStatus(status) {
try {
let user = await db.user.get();
if (!user || !user.id) {
@@ -18,14 +19,20 @@ async function setPremiumStatus(status) {
}
function get() {
//return true;
return premiumStatus && premiumStatus !== 0 && premiumStatus !== 4
}
async function verify(callback,error) {
/* if (!callback) console.warn('You must provide a callback function');
await callback();
return; */
try {
let user = await db.user.get();
if (!user || !user.id) {
if (!user || !user.id || premiumStatus) {
if (error) {
error();
return;

View File

@@ -12,6 +12,10 @@ import {enabled} from 'react-native-privacy-snapshot';
import Menu, {MenuItem} from 'react-native-reanimated-material-menu';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {Button} from '../../components/Button';
import BaseDialog from '../../components/Dialog/base-dialog';
import DialogButtons from '../../components/Dialog/dialog-buttons';
import DialogContainer from '../../components/Dialog/dialog-container';
import DialogHeader from '../../components/Dialog/dialog-header';
import {PressableButton} from '../../components/PressableButton';
import Seperator from '../../components/Seperator';
import {ListHeaderComponent} from '../../components/SimpleList/ListHeaderComponent';
@@ -34,6 +38,7 @@ import SettingsService from '../../services/SettingsService';
import {
AndroidModule,
dWidth,
getElevation,
MenuItemsList,
setSetting,
SUBSCRIPTION_STATUS_STRINGS,
@@ -58,7 +63,7 @@ import {
eUpdateSearchState,
} from '../../utils/Events';
import {MMKV} from '../../utils/mmkv';
import {opacity, pv, SIZE, WEIGHT} from '../../utils/SizeUtils';
import {opacity, ph, pv, SIZE, WEIGHT} from '../../utils/SizeUtils';
import Storage from '../../utils/storage';
import {sleep} from '../../utils/TimeUtils';
@@ -256,16 +261,7 @@ const SettingsUserSection = () => {
<>
{visible && (
<BaseDialog visible={true}>
<View
style={{
...getElevation(5),
width: DDS.isTab ? 350 : '80%',
maxHeight: 350,
borderRadius: 5,
backgroundColor: colors.bg,
paddingHorizontal: ph,
paddingVertical: pv,
}}>
<DialogContainer>
<DialogHeader
title="Logout"
paragraph="Clear all your data and reset the app."
@@ -281,7 +277,7 @@ const SettingsUserSection = () => {
dispatch({type: Actions.SYNCING, syncing: false});
}}
/>
</View>
</DialogContainer>
</BaseDialog>
)}
<View
@@ -822,6 +818,7 @@ const SettingsBackupAndRestore = () => {
paragraph:
"All your backups are stored in 'Phone Storage/Notesnook/backups/' folder",
});
console.log("running backup now")
await Backup.run();
await sleep(1000);
eSendEvent(eCloseProgressDialog);