mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
fix vault dialog not opening on ios
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { createRef, useEffect, useState } from 'react';
|
||||
import React, {createRef, useEffect, useState} from 'react';
|
||||
import {
|
||||
Dimensions,
|
||||
StatusBar,
|
||||
@@ -22,19 +22,19 @@ import {
|
||||
SIZE,
|
||||
WEIGHT,
|
||||
} from '../../common/common';
|
||||
import { useTracked } from '../../provider';
|
||||
import { ACTIONS } from '../../provider/actions';
|
||||
import {useTracked} from '../../provider';
|
||||
import {ACTIONS} from '../../provider/actions';
|
||||
import NavigationService from '../../services/NavigationService';
|
||||
import { timeConverter, ToastEvent, DDS, db } from '../../utils/utils';
|
||||
import { openVault, eSendEvent } from '../../services/eventManager';
|
||||
import { refreshNotesPage } from '../../services/events';
|
||||
import {timeConverter, ToastEvent, DDS, db} from '../../utils/utils';
|
||||
import {openVault, eSendEvent} from '../../services/eventManager';
|
||||
import {refreshNotesPage} from '../../services/events';
|
||||
|
||||
const w = Dimensions.get('window').width;
|
||||
const h = Dimensions.get('window').height;
|
||||
|
||||
const tagsInputRef = createRef();
|
||||
export const ActionSheetComponent = ({
|
||||
close = () => { },
|
||||
close = () => {},
|
||||
item,
|
||||
hasColors = false,
|
||||
hasTags = false,
|
||||
@@ -42,7 +42,7 @@ export const ActionSheetComponent = ({
|
||||
columnItems = [],
|
||||
}) => {
|
||||
const [state, dispatch] = useTracked();
|
||||
const { colors, tags, currentEditingNote } = state;
|
||||
const {colors, tags, currentEditingNote} = state;
|
||||
const [focused, setFocused] = useState(false);
|
||||
const [note, setNote] = useState(
|
||||
item
|
||||
@@ -65,12 +65,12 @@ export const ActionSheetComponent = ({
|
||||
let newColors = setColorScheme(colors, accent);
|
||||
StatusBar.setBarStyle(colors.night ? 'light-content' : 'dark-content');
|
||||
|
||||
dispatch({ type: ACTIONS.THEME, colors: newColors });
|
||||
dispatch({type: ACTIONS.THEME, colors: newColors});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (item.dateCreated !== null) {
|
||||
setNote({ ...item });
|
||||
setNote({...item});
|
||||
}
|
||||
}, [item]);
|
||||
|
||||
@@ -96,8 +96,8 @@ export const ActionSheetComponent = ({
|
||||
|
||||
await db.notes.note(note.id).tag(tag);
|
||||
|
||||
setNote({ ...db.notes.note(note.id).data });
|
||||
dispatch({ type: ACTIONS.TAGS });
|
||||
setNote({...db.notes.note(note.id).data});
|
||||
dispatch({type: ACTIONS.TAGS});
|
||||
tagToAdd = '';
|
||||
};
|
||||
|
||||
@@ -112,14 +112,14 @@ export const ActionSheetComponent = ({
|
||||
backPressCount = 0;
|
||||
|
||||
let tagInputValue = note.tags[note.tags.length - 1];
|
||||
let oldProps = { ...note };
|
||||
let oldProps = {...note};
|
||||
if (oldProps.tags.length === 0) return;
|
||||
|
||||
await db.notes
|
||||
.note(note.id)
|
||||
.untag(oldProps.tags[oldProps.tags.length - 1]);
|
||||
|
||||
setNote({ ...db.notes.note(note.id).data });
|
||||
setNote({...db.notes.note(note.id).data});
|
||||
|
||||
tagsInputRef.current?.setNativeProps({
|
||||
text: tagInputValue,
|
||||
@@ -183,11 +183,11 @@ export const ActionSheetComponent = ({
|
||||
if (!toAdd || !toAdd.id) return;
|
||||
|
||||
if (!nodispatch) {
|
||||
dispatch({ type: type });
|
||||
dispatch({ type: ACTIONS.PINNED });
|
||||
dispatch({ type: ACTIONS.FAVORITES });
|
||||
dispatch({type: type});
|
||||
dispatch({type: ACTIONS.PINNED});
|
||||
dispatch({type: ACTIONS.FAVORITES});
|
||||
}
|
||||
setNote({ ...toAdd });
|
||||
setNote({...toAdd});
|
||||
};
|
||||
|
||||
const rowItemsData = [
|
||||
@@ -195,8 +195,8 @@ export const ActionSheetComponent = ({
|
||||
name: 'Add to',
|
||||
icon: 'book-outline',
|
||||
func: () => {
|
||||
dispatch({ type: ACTIONS.MODAL_NAVIGATOR, enabled: true });
|
||||
dispatch({ type: ACTIONS.SELECTED_ITEMS, item: note });
|
||||
dispatch({type: ACTIONS.MODAL_NAVIGATOR, enabled: true});
|
||||
dispatch({type: ACTIONS.SELECTED_ITEMS, item: note});
|
||||
|
||||
close('movenote');
|
||||
},
|
||||
@@ -260,7 +260,7 @@ export const ActionSheetComponent = ({
|
||||
icon: 'delete-restore',
|
||||
func: async () => {
|
||||
await db.trash.restore(note.id);
|
||||
dispatch({ type: ACTIONS.TRASH });
|
||||
dispatch({type: ACTIONS.TRASH});
|
||||
localRefresh(note.type);
|
||||
ToastEvent.show(
|
||||
item.type === 'note' ? 'Note restored' : 'Notebook restored',
|
||||
@@ -284,10 +284,10 @@ export const ActionSheetComponent = ({
|
||||
icon: 'theme-light-dark',
|
||||
func: () => {
|
||||
if (!colors.night) {
|
||||
MMKV.setStringAsync('theme', JSON.stringify({ night: true }));
|
||||
MMKV.setStringAsync('theme', JSON.stringify({night: true}));
|
||||
changeColorScheme(COLOR_SCHEME_DARK);
|
||||
} else {
|
||||
MMKV.setStringAsync('theme', JSON.stringify({ night: false }));
|
||||
MMKV.setStringAsync('theme', JSON.stringify({night: false}));
|
||||
changeColorScheme(COLOR_SCHEME_LIGHT);
|
||||
}
|
||||
},
|
||||
@@ -305,7 +305,7 @@ export const ActionSheetComponent = ({
|
||||
} else {
|
||||
await db.notebooks.notebook(note.id).pin();
|
||||
}
|
||||
dispatch({ type: ACTIONS.PINNED });
|
||||
dispatch({type: ACTIONS.PINNED});
|
||||
localRefresh(item.type);
|
||||
},
|
||||
close: false,
|
||||
@@ -322,7 +322,7 @@ export const ActionSheetComponent = ({
|
||||
} else {
|
||||
await db.notebooks.notebook(note.id).favorite();
|
||||
}
|
||||
dispatch({ type: ACTIONS.FAVORITES });
|
||||
dispatch({type: ACTIONS.FAVORITES});
|
||||
localRefresh(item.type);
|
||||
},
|
||||
close: false,
|
||||
@@ -336,28 +336,25 @@ export const ActionSheetComponent = ({
|
||||
if (!note.id) return;
|
||||
|
||||
if (note.locked) {
|
||||
close();
|
||||
openVault(note, true, true, true, false, false);
|
||||
close('unlock');
|
||||
|
||||
return;
|
||||
} else {
|
||||
db.vault
|
||||
.add(note.id)
|
||||
.then(() => {
|
||||
dispatch({ type: ACTIONS.NOTES })
|
||||
dispatch({type: ACTIONS.NOTES});
|
||||
eSendEvent(refreshNotesPage);
|
||||
dispatch({ type: ACTIONS.PINNED });
|
||||
dispatch({type: ACTIONS.PINNED});
|
||||
close();
|
||||
})
|
||||
.catch(async e => {
|
||||
switch (e.message) {
|
||||
case db.vault.ERRORS.noVault:
|
||||
openVault(note, false);
|
||||
close();
|
||||
close('novault');
|
||||
break;
|
||||
case db.vault.ERRORS.vaultLocked:
|
||||
openVault(note, true, true);
|
||||
close();
|
||||
close('valutlocked');
|
||||
break;
|
||||
case db.vault.ERRORS.wrongPassword:
|
||||
close();
|
||||
@@ -376,13 +373,13 @@ export const ActionSheetComponent = ({
|
||||
<TouchableOpacity
|
||||
key={tag}
|
||||
onPress={async () => {
|
||||
let oldProps = { ...note };
|
||||
let oldProps = {...note};
|
||||
try {
|
||||
await db.notes
|
||||
.note(note.id)
|
||||
.untag(oldProps.tags[oldProps.tags.indexOf(tag)]);
|
||||
localRefresh(oldProps.type);
|
||||
dispatch({ type: ACTIONS.TAGS });
|
||||
dispatch({type: ACTIONS.TAGS});
|
||||
} catch (e) {
|
||||
localRefresh(oldProps.type);
|
||||
}
|
||||
@@ -423,7 +420,7 @@ export const ActionSheetComponent = ({
|
||||
} else {
|
||||
await db.notes.note(note.id).color(color);
|
||||
}
|
||||
dispatch({ type: ACTIONS.COLORS });
|
||||
dispatch({type: ACTIONS.COLORS});
|
||||
localRefresh(note.type);
|
||||
}}
|
||||
style={{
|
||||
@@ -809,7 +806,8 @@ export const ActionSheetComponent = ({
|
||||
position: 'absolute',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
}}></TouchableOpacity>
|
||||
}}
|
||||
/>
|
||||
{note && note.tags ? note.tags.map(_renderTag) : null}
|
||||
<TextInput
|
||||
style={{
|
||||
|
||||
@@ -210,31 +210,15 @@ export class DialogManager extends Component {
|
||||
this._showSimpleDialog(TEMPLATE_PERMANANT_DELETE);
|
||||
break;
|
||||
}
|
||||
case 'lock': {
|
||||
this._showVaultDialog();
|
||||
|
||||
break;
|
||||
}
|
||||
case 'novault': {
|
||||
this.setState({
|
||||
vaultExists: false,
|
||||
});
|
||||
this._showVaultDialog();
|
||||
openVault(this.state.item, false);
|
||||
}
|
||||
case 'vaultlocked': {
|
||||
openVault(this.state.item, true, true);
|
||||
break;
|
||||
}
|
||||
case 'unlock': {
|
||||
this.setState({
|
||||
isPerm: true,
|
||||
});
|
||||
this._showVaultDialog();
|
||||
break;
|
||||
}
|
||||
case 'unlock_share': {
|
||||
this.setState({
|
||||
isPerm: false,
|
||||
shareAfterUnlock: true,
|
||||
});
|
||||
this._showVaultDialog();
|
||||
break;
|
||||
openVault(this.state.item, true, true, true, false, false);
|
||||
}
|
||||
case 'notebook': {
|
||||
this.showAddNotebook({item: this.state.item});
|
||||
|
||||
Reference in New Issue
Block a user