do not load dialogs on init in memory

This commit is contained in:
ammarahm-ed
2020-11-23 12:32:33 +05:00
parent 661794fd7e
commit 2ae6e48627
17 changed files with 216 additions and 200 deletions

View File

@@ -215,21 +215,6 @@ export class AddNotebookDialog extends React.Component {
topics: prevTopics, topics: prevTopics,
}); });
this.currentInputValue = null; this.currentInputValue = null;
/* if (prevTopics[this.prevIndex + 1] && forward) {
this.prevIndex = this.prevIndex + 1;
this.prevItem = prevTopics[this.prevIndex];
this.currentInputValue = this.prevItem;
this.topicInputRef.setNativeProps({
text: null,
});
this.topicInputRef.setNativeProps({
text: prevTopics[this.prevIndex],
});
this.setState({
editTopic:true
})
} else {} */
if (this.state.editTopic) { if (this.state.editTopic) {
this.topicInputRef.blur(); this.topicInputRef.blur();
Keyboard.dismiss(); Keyboard.dismiss();
@@ -261,9 +246,10 @@ export class AddNotebookDialog extends React.Component {
visible, visible,
topicInputFocused, topicInputFocused,
} = this.state; } = this.state;
if (!visible) return null;
return ( return (
<Modal <Modal
visible={visible} visible={true}
transparent={true} transparent={true}
animated animated
animationType={DDS.isTab ? 'fade' : 'slide'} animationType={DDS.isTab ? 'fade' : 'slide'}

View File

@@ -59,13 +59,13 @@ export class AddTopicDialog extends React.Component {
render() { render() {
const {visible, titleFocused} = this.state; const {visible, titleFocused} = this.state;
const {colors, toEdit} = this.props; const {colors, toEdit} = this.props;
if (!visible) return null;
return ( return (
<BaseDialog <BaseDialog
onShow={() => { onShow={() => {
this.titleRef.current?.focus(); this.titleRef.current?.focus();
}} }}
visible={visible} visible={true}
onRequestClose={this.close}> onRequestClose={this.close}>
<View <View
style={{ style={{

View File

@@ -2,17 +2,9 @@ import React, {Component} from 'react';
import {View} from 'react-native'; import {View} from 'react-native';
import {Actions} from '../../provider/Actions'; import {Actions} from '../../provider/Actions';
import {DDS} from '../../services/DeviceDetection'; import {DDS} from '../../services/DeviceDetection';
import {eSendEvent, ToastEvent} from '../../services/EventManager'; import {ToastEvent} from '../../services/EventManager';
import NavigationService from '../../services/Navigation';
import {getElevation, history} from '../../utils'; import {getElevation, history} from '../../utils';
import {db} from '../../utils/DB'; import {db} from '../../utils/DB';
import {
eApplyChanges,
eClearEditor,
eCloseFullscreenEditor,
eOnLoadNote,
eOnNewTopicAdded,
} from '../../utils/Events';
import {ph, pv} from '../../utils/SizeUtils'; import {ph, pv} from '../../utils/SizeUtils';
import {dialogActions} from '../DialogManager/DialogActions'; import {dialogActions} from '../DialogManager/DialogActions';
import {updateEvent} from '../DialogManager/recievers'; import {updateEvent} from '../DialogManager/recievers';
@@ -87,8 +79,10 @@ export class Dialog extends Component {
const {template, colors} = this.props; const {template, colors} = this.props;
const {title, paragraph, positiveText, negativeText, icon} = template; const {title, paragraph, positiveText, negativeText, icon} = template;
const {visible} = this.state; const {visible} = this.state;
if (!visible) return null;
return ( return (
<BaseDialog visible={visible} onRequestClose={this.hide}> <BaseDialog visible={true} onRequestClose={this.hide}>
<View <View
style={{ style={{
...getElevation(5), ...getElevation(5),

View File

@@ -46,7 +46,8 @@ import {DDS} from '../../services/DeviceDetection';
import ResultDialog from '../ResultDialog'; import ResultDialog from '../ResultDialog';
import SortDialog from '../SortDialog'; import SortDialog from '../SortDialog';
import JumpToDialog from '../JumpToDialog'; import JumpToDialog from '../JumpToDialog';
import {GetPremium,translatePrem} from '../ActionSheetComponent/GetPremium'; import {GetPremium, translatePrem} from '../ActionSheetComponent/GetPremium';
import {sleep} from '../../utils/TimeUtils';
export class DialogManager extends Component { export class DialogManager extends Component {
constructor(props) { constructor(props) {
@@ -55,6 +56,7 @@ export class DialogManager extends Component {
this.opened = false; this.opened = false;
this.state = { this.state = {
item: {}, item: {},
actionSheetVisible: false,
actionSheetData: { actionSheetData: {
colors: false, colors: false,
tags: false, tags: false,
@@ -84,6 +86,7 @@ export class DialogManager extends Component {
{ {
actionSheetData: data, actionSheetData: data,
item: data.item ? data.item : {}, item: data.item ? data.item : {},
actionSheetVisible: true,
}, },
() => { () => {
this.actionSheet._setModalVisible(); this.actionSheet._setModalVisible();
@@ -93,6 +96,11 @@ export class DialogManager extends Component {
_hideActionSheet = () => { _hideActionSheet = () => {
this.actionSheet._setModalVisible(); this.actionSheet._setModalVisible();
sleep(200).then(() => {
this.setState({
actionSheetVisible: false,
});
});
}; };
_showMoveNote = () => { _showMoveNote = () => {
@@ -230,11 +238,11 @@ export class DialogManager extends Component {
case 'delete': { case 'delete': {
if (this.state.item.locked) { if (this.state.item.locked) {
openVault({ openVault({
item:this.state.item, item: this.state.item,
novault:true, novault: true,
locked:true, locked: true,
deleteNote:true, deleteNote: true,
}) });
} else { } else {
this._showSimpleDialog(TEMPLATE_DELETE(this.state.item.type)); this._showSimpleDialog(TEMPLATE_DELETE(this.state.item.type));
} }
@@ -246,28 +254,28 @@ export class DialogManager extends Component {
} }
case 'novault': { case 'novault': {
openVault({ openVault({
item:this.state.item, item: this.state.item,
novault:false, novault: false,
locked:true, locked: true,
deleteNote:true, deleteNote: true,
}) });
break; break;
} }
case 'locked': { case 'locked': {
openVault({ openVault({
item:this.state.item, item: this.state.item,
novault:true, novault: true,
locked:true, locked: true,
}) });
break; break;
} }
case 'unlock': { case 'unlock': {
openVault({ openVault({
item:this.state.item, item: this.state.item,
novault:true, novault: true,
locked:true, locked: true,
permanant:true permanant: true,
}) });
break; break;
} }
case 'notebook': { case 'notebook': {
@@ -300,6 +308,7 @@ export class DialogManager extends Component {
let {actionSheetData, item, simpleDialog} = this.state; let {actionSheetData, item, simpleDialog} = this.state;
return ( return (
<> <>
{!this.state.actionSheetVisible ? null : (
<ActionSheet <ActionSheet
ref={(ref) => (this.actionSheet = ref)} ref={(ref) => (this.actionSheet = ref)}
containerStyle={{ containerStyle={{
@@ -339,7 +348,7 @@ export class DialogManager extends Component {
bounceOnOpen={false} bounceOnOpen={false}
gestureEnabled={true} gestureEnabled={true}
onClose={() => { onClose={() => {
translatePrem.setValue(-800) translatePrem.setValue(-800);
this.onActionSheetHide(); this.onActionSheetHide();
}}> }}>
<ActionSheetComponent <ActionSheetComponent
@@ -362,6 +371,8 @@ export class DialogManager extends Component {
}} }}
/> />
</ActionSheet> </ActionSheet>
)}
<Dialog <Dialog
ref={(ref) => (this.simpleDialog = ref)} ref={(ref) => (this.simpleDialog = ref)}
item={item} item={item}

View File

@@ -154,11 +154,11 @@ const ExportDialog = () => {
}, },
]; ];
return ( return !visible ? null : (
<BaseDialog <BaseDialog
premium={<GetPremium context="export" offset={50} close={close} />} premium={<GetPremium context="export" offset={50} close={close} />}
onRequestClose={close} onRequestClose={close}
visible={visible}> visible={true}>
<View <View
style={[ style={[
{ {

View File

@@ -1,14 +1,14 @@
import React, { useEffect, useState } from 'react'; import React, {useEffect, useState} from 'react';
import { ScrollView, View } from 'react-native'; import {ScrollView, View} from 'react-native';
import BaseDialog from '../../components/Dialog/base-dialog'; import BaseDialog from '../../components/Dialog/base-dialog';
import { PressableButton } from '../../components/PressableButton'; import {PressableButton} from '../../components/PressableButton';
import Seperator from '../../components/Seperator'; import Seperator from '../../components/Seperator';
import { useTracked } from '../../provider'; import {useTracked} from '../../provider';
import { DDS } from '../../services/DeviceDetection'; import {DDS} from '../../services/DeviceDetection';
import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager'; import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
import { getElevation, scrollRef } from '../../utils'; import {getElevation, scrollRef} from '../../utils';
import { eCloseJumpToDialog, eOpenJumpToDialog } from '../../utils/Events'; import {eCloseJumpToDialog, eOpenJumpToDialog} from '../../utils/Events';
import { SIZE } from '../../utils/SizeUtils'; import {SIZE} from '../../utils/SizeUtils';
import Heading from '../Typography/Heading'; import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph'; import Paragraph from '../Typography/Paragraph';
@@ -83,13 +83,13 @@ const JumpToDialog = () => {
}); });
}; };
return ( return !visible ? null : (
<BaseDialog <BaseDialog
onShow={() => { onShow={() => {
loadOffsets(); loadOffsets();
}} }}
onRequestClose={close} onRequestClose={close}
visible={visible}> visible={true}>
<View <View
style={{ style={{
...getElevation(5), ...getElevation(5),

View File

@@ -1,5 +1,5 @@
import React, {createRef, useEffect, useState} from 'react'; import React, {createRef, useEffect, useState} from 'react';
import {Modal, Text, TouchableOpacity, View} from 'react-native'; import {Modal, TouchableOpacity, View} from 'react-native';
import {TextInput} from 'react-native-gesture-handler'; import {TextInput} from 'react-native-gesture-handler';
import {useSafeAreaInsets} from 'react-native-safe-area-context'; import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
@@ -109,7 +109,6 @@ const LoginDialog = () => {
try { try {
let res = await db.user.login(username.toLowerCase(), password); let res = await db.user.login(username.toLowerCase(), password);
} catch (e) { } catch (e) {
setTimeout(() => { setTimeout(() => {
ToastEvent.show(e.message, 'error', 'local'); ToastEvent.show(e.message, 'error', 'local');
@@ -202,13 +201,13 @@ const LoginDialog = () => {
} }
}; };
return ( return !visible ? null : (
<Modal <Modal
animated={true} animated={true}
animationType={DDS.isTab ? 'fade' : 'slide'} animationType={DDS.isTab ? 'fade' : 'slide'}
statusBarTranslucent={true} statusBarTranslucent={true}
onRequestClose={close} onRequestClose={close}
visible={visible} visible={true}
transparent={true}> transparent={true}>
<View <View
style={{ style={{

View File

@@ -281,8 +281,8 @@ const MergeEditor = () => {
link.click(); link.click();
}`; }`;
return ( return !visible ? null : (
<Modal transparent={false} animated animationType="fade" visible={visible}> <Modal transparent={false} animated animationType="fade" visible={true}>
<SafeAreaView <SafeAreaView
style={{ style={{
backgroundColor: colors.nav, backgroundColor: colors.nav,

View File

@@ -1,28 +1,21 @@
import React, {createRef, useEffect, useState} from 'react'; import React, {createRef, useEffect, useState} from 'react';
import { import {FlatList, Modal, TextInput, TouchableOpacity, View} from 'react-native';
FlatList,
Modal,
Text,
TextInput,
TouchableOpacity,
View,
} from 'react-native';
import {useSafeAreaInsets} from 'react-native-safe-area-context'; import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import {Actions} from '../../provider/Actions'; import {Actions} from '../../provider/Actions';
import {DDS} from '../../services/DeviceDetection';
import { import {
eSubscribeEvent, eSubscribeEvent,
eUnSubscribeEvent, eUnSubscribeEvent,
ToastEvent, ToastEvent,
} from '../../services/EventManager'; } from '../../services/EventManager';
import {eOpenMoveNoteDialog} from '../../utils/Events';
import {getElevation} from '../../utils'; import {getElevation} from '../../utils';
import {db} from '../../utils/DB';
import {eOpenMoveNoteDialog} from '../../utils/Events';
import {pv, SIZE, WEIGHT} from '../../utils/SizeUtils';
import {PressableButton} from '../PressableButton'; import {PressableButton} from '../PressableButton';
import {Toast} from '../Toast'; import {Toast} from '../Toast';
import {pv, SIZE, WEIGHT} from '../../utils/SizeUtils';
import {db} from '../../utils/DB';
import {DDS} from '../../services/DeviceDetection';
import Heading from '../Typography/Heading'; import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph'; import Paragraph from '../Typography/Paragraph';
@@ -80,9 +73,7 @@ const MoveNoteDialog = () => {
if (!newTopicTitle || newTopicTitle.trim().length === 0) { if (!newTopicTitle || newTopicTitle.trim().length === 0) {
return ToastEvent.show('Title is required', 'error', 'local'); return ToastEvent.show('Title is required', 'error', 'local');
} }
let res = await db.notebooks.notebook(expanded).topics.add(newTopicTitle); let res = await db.notebooks.notebook(expanded).topics.add(newTopicTitle);
dispatch({type: Actions.NOTEBOOKS}); dispatch({type: Actions.NOTEBOOKS});
dispatch({type: Actions.PINNED}); dispatch({type: Actions.PINNED});
topicInput.current?.clear(); topicInput.current?.clear();
@@ -90,12 +81,12 @@ const MoveNoteDialog = () => {
newTopicTitle = null; newTopicTitle = null;
}; };
return ( return !visible ? null : (
<Modal <Modal
animated={true} animated={true}
animationType="slide" animationType="slide"
onRequestClose={close} onRequestClose={close}
visible={visible} visible={true}
statusBarTranslucent={true} statusBarTranslucent={true}
transparent={true}> transparent={true}>
<View <View

View File

@@ -36,8 +36,8 @@ const ProgressDialog = () => {
setVisible(false); setVisible(false);
}; };
return ( return !visible ? null : (
<BaseDialog visible={visible} onRequestClose={close}> <BaseDialog visible={true} onRequestClose={close}>
<View <View
style={{ style={{
...getElevation(5), ...getElevation(5),

View File

@@ -1,24 +1,25 @@
import React, {createRef} from 'react'; import React, { createRef } from 'react';
import {Clipboard, Text, View} from 'react-native'; import { Clipboard, View } from 'react-native';
import QRCode from 'react-native-qrcode-svg'; import QRCode from 'react-native-qrcode-svg';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import RNFetchBlob from 'rn-fetch-blob'; import RNFetchBlob from 'rn-fetch-blob';
import {LOGO_BASE64} from '../../assets/images/assets'; import { LOGO_BASE64 } from '../../assets/images/assets';
import { import {
eSendEvent, eSendEvent,
eSubscribeEvent, eSubscribeEvent,
eUnSubscribeEvent, eUnSubscribeEvent,
ToastEvent, ToastEvent
} from '../../services/EventManager'; } from '../../services/EventManager';
import {eOpenRecoveryKeyDialog, eOpenResultDialog} from '../../utils/Events'; import { dWidth } from '../../utils';
import {dWidth} from '../../utils'; import { db } from '../../utils/DB';
import ActionSheet from '../ActionSheet'; import { eOpenRecoveryKeyDialog, eOpenResultDialog } from '../../utils/Events';
import {Button} from '../Button'; import { SIZE } from '../../utils/SizeUtils';
import Seperator from '../Seperator';
import {Toast} from '../Toast';
import {SIZE, WEIGHT} from '../../utils/SizeUtils';
import {db} from '../../utils/DB';
import Storage from '../../utils/storage'; import Storage from '../../utils/storage';
import { sleep } from '../../utils/TimeUtils';
import ActionSheet from '../ActionSheet';
import { Button } from '../Button';
import Seperator from '../Seperator';
import { Toast } from '../Toast';
import Heading from '../Typography/Heading'; import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph'; import Paragraph from '../Typography/Paragraph';
class RecoveryKeyDialog extends React.Component { class RecoveryKeyDialog extends React.Component {
@@ -26,6 +27,7 @@ class RecoveryKeyDialog extends React.Component {
super(props); super(props);
this.state = { this.state = {
key: null, key: null,
visible: false,
}; };
this.actionSheetRef = createRef(); this.actionSheetRef = createRef();
this.svg = createRef(); this.svg = createRef();
@@ -37,11 +39,23 @@ class RecoveryKeyDialog extends React.Component {
if (signup) { if (signup) {
this.signup = true; this.signup = true;
} }
this.setState(
{
visible: true,
},
() => {
this.actionSheetRef.current?._setModalVisible(true); this.actionSheetRef.current?._setModalVisible(true);
},
);
}; };
close = () => { close = () => {
this.actionSheetRef.current?._setModalVisible(false); this.actionSheetRef.current?._setModalVisible(false);
sleep(200).then(() => {
this.setState({
visible: false,
});
});
if (this.signup) { if (this.signup) {
setTimeout(() => { setTimeout(() => {
eSendEvent(eOpenResultDialog, { eSendEvent(eOpenResultDialog, {
@@ -122,6 +136,7 @@ class RecoveryKeyDialog extends React.Component {
render() { render() {
const {colors} = this.props; const {colors} = this.props;
if (!this.state.visible) return null;
return ( return (
<ActionSheet <ActionSheet
containerStyle={{ containerStyle={{

View File

@@ -80,10 +80,10 @@ const RestoreDialog = () => {
setFiles(files); setFiles(files);
}; };
return ( return !visible? null : (
<BaseDialog <BaseDialog
animation="slide" animation="slide"
visible={visible} visible={true}
onShow={checkBackups} onShow={checkBackups}
onRequestClose={close}> onRequestClose={close}>
<View <View

View File

@@ -1,13 +1,13 @@
import React, {useEffect, useState} from 'react'; import React, { useEffect, useState } from 'react';
import {Text, View} from 'react-native'; import { View } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {useTracked} from '../../provider'; import { useTracked } from '../../provider';
import {DDS} from '../../services/DeviceDetection'; import { DDS } from '../../services/DeviceDetection';
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager'; import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
import {getElevation} from '../../utils'; import { getElevation } from '../../utils';
import {eCloseResultDialog, eOpenResultDialog} from '../../utils/Events'; import { eCloseResultDialog, eOpenResultDialog } from '../../utils/Events';
import {ph, SIZE, WEIGHT} from '../../utils/SizeUtils'; import { ph, SIZE } from '../../utils/SizeUtils';
import {Button} from '../Button'; import { Button } from '../Button';
import BaseDialog from '../Dialog/base-dialog'; import BaseDialog from '../Dialog/base-dialog';
import Seperator from '../Seperator'; import Seperator from '../Seperator';
import Heading from '../Typography/Heading'; import Heading from '../Typography/Heading';
@@ -41,8 +41,8 @@ const ResultDialog = () => {
setVisible(false); setVisible(false);
}; };
return ( return !visible ? null : (
<BaseDialog visible={visible} onRequestClose={close}> <BaseDialog visible={true} onRequestClose={close}>
<View <View
style={{ style={{
...getElevation(5), ...getElevation(5),

View File

@@ -1,21 +1,22 @@
import React, {createRef} from 'react'; import React, {createRef} from 'react';
import {Text, TouchableOpacity, View} from 'react-native'; import {TouchableOpacity, View} from 'react-native';
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
import {dWidth, SORT, sortSettings} from '../../utils';
import ActionSheet from '../ActionSheet';
import {DDS} from '../../services/DeviceDetection';
import {eCloseSortDialog, eOpenSortDialog} from '../../utils/Events';
import {PressableButton} from '../PressableButton';
import {SIZE, WEIGHT} from '../../utils/SizeUtils';
import {defaultState} from '../../provider/DefaultState';
import {MMKV} from '../../utils/mmkv';
import {updateEvent} from '../DialogManager/recievers';
import {Actions} from '../../provider/Actions';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import Seperator from '../Seperator'; import {Actions} from '../../provider/Actions';
import {defaultState} from '../../provider/DefaultState';
import {DDS} from '../../services/DeviceDetection';
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
import SettingsService from '../../services/SettingsService'; import SettingsService from '../../services/SettingsService';
import Paragraph from '../Typography/Paragraph'; import {dWidth, SORT, sortSettings} from '../../utils';
import {eCloseSortDialog, eOpenSortDialog} from '../../utils/Events';
import {MMKV} from '../../utils/mmkv';
import {SIZE} from '../../utils/SizeUtils';
import {sleep} from '../../utils/TimeUtils';
import ActionSheet from '../ActionSheet';
import {updateEvent} from '../DialogManager/recievers';
import {PressableButton} from '../PressableButton';
import Seperator from '../Seperator';
import Heading from '../Typography/Heading'; import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
const actionSheet = createRef(); const actionSheet = createRef();
@@ -24,12 +25,20 @@ class SortDialog extends React.Component {
super(props); super(props);
this.state = { this.state = {
settings: defaultState.settings, settings: defaultState.settings,
visible: false,
}; };
} }
async open() { async open() {
this.setState(
{
visible: true,
},
async () => {
actionSheet.current?._setModalVisible(true); actionSheet.current?._setModalVisible(true);
await this.getSettings(); await this.getSettings();
},
);
} }
async getSettings() { async getSettings() {
@@ -41,6 +50,11 @@ class SortDialog extends React.Component {
close() { close() {
actionSheet.current?._setModalVisible(false); actionSheet.current?._setModalVisible(false);
sleep(200).then(() => {
this.setState({
visible: false,
});
});
} }
async componentDidMount() { async componentDidMount() {
@@ -55,6 +69,9 @@ class SortDialog extends React.Component {
render() { render() {
const {colors} = this.props; const {colors} = this.props;
if (!this.state.visible) return null;
return ( return (
<ActionSheet <ActionSheet
containerStyle={{ containerStyle={{

View File

@@ -322,13 +322,14 @@ export class VaultDialog extends Component {
biometricUnlock, biometricUnlock,
} = this.state; } = this.state;
if (!visible) return null;
return ( return (
<BaseDialog <BaseDialog
onShow={() => { onShow={() => {
passInputRef.current?.focus(); passInputRef.current?.focus();
}} }}
onRequestClose={this.close} onRequestClose={this.close}
visible={visible}> visible={true}>
<View <View
style={{ style={{
...getElevation(5), ...getElevation(5),
@@ -495,7 +496,8 @@ export class VaultDialog extends Component {
</View> </View>
) : null} ) : null}
{this.state.isBiometryAvailable && !this.state.fingerprintAccess && {this.state.isBiometryAvailable &&
!this.state.fingerprintAccess &&
(!this.state.biometricUnlock || !novault) ? ( (!this.state.biometricUnlock || !novault) ? (
<TouchableOpacity <TouchableOpacity
onPress={() => { onPress={() => {

View File

@@ -38,7 +38,8 @@ async function init() {
sortSettings.sortOrder = settings.sortOrder; sortSettings.sortOrder = settings.sortOrder;
updateSize(); updateSize();
updateEvent({type: Actions.SETTINGS, settings: {...settings}}); updateEvent({type: Actions.SETTINGS, settings: {...settings}});
await setTheme(); setTheme();
return;
} }
const setTheme = async () => { const setTheme = async () => {

View File

@@ -1,11 +1,5 @@
import React from 'react'; import React, { useEffect } from 'react';
import { import {Platform, TextInput, View} from 'react-native';
KeyboardAvoidingView,
Platform,
SafeAreaView,
TextInput,
View,
} from 'react-native';
import WebView from 'react-native-webview'; import WebView from 'react-native-webview';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import EditorHeader from './EditorHeader'; import EditorHeader from './EditorHeader';
@@ -22,6 +16,10 @@ import {
const Editor = () => { const Editor = () => {
const [state] = useTracked(); const [state] = useTracked();
const {colors, premiumUser} = state; const {colors, premiumUser} = state;
useEffect(() => {
console.log('rendering editor');
})
return ( return (
<> <>
<TextInput <TextInput
@@ -34,7 +32,9 @@ const Editor = () => {
testID="editor" testID="editor"
ref={EditorWebView} ref={EditorWebView}
onError={(error) => console.log(error)} onError={(error) => console.log(error)}
onLoad={async () => await onWebViewLoad(premiumUser, colors)} onLoad={async (event) =>
await onWebViewLoad(premiumUser, colors, event)
}
javaScriptEnabled={true} javaScriptEnabled={true}
focusable={true} focusable={true}
keyboardDisplayRequiresUserAction={false} keyboardDisplayRequiresUserAction={false}