fix edit topic dialog

This commit is contained in:
ammarahm-ed
2020-12-17 10:31:35 +05:00
parent 0b1f26ffc5
commit 3cd91bdbe0
2 changed files with 29 additions and 15 deletions

View File

@@ -1,19 +1,24 @@
import React, {createRef} from 'react'; import React, {createRef} from 'react';
import {View} from 'react-native';
import {TextInput} from 'react-native-gesture-handler'; import {TextInput} from 'react-native-gesture-handler';
import {Actions} from '../../provider/Actions'; import {Actions} from '../../provider/Actions';
import {DDS} from '../../services/DeviceDetection'; import {
import {eSendEvent, ToastEvent} from '../../services/EventManager'; eSendEvent,
import {getElevation} from '../../utils'; eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent,
} from '../../services/EventManager';
import {db} from '../../utils/DB'; import {db} from '../../utils/DB';
import {eOnNewTopicAdded} from '../../utils/Events'; import {
import {ph, pv, SIZE, WEIGHT} from '../../utils/SizeUtils'; eCloseAddTopicDialog,
eOnNewTopicAdded,
eOpenAddTopicDialog,
} from '../../utils/Events';
import {SIZE, WEIGHT} from '../../utils/SizeUtils';
import BaseDialog from '../Dialog/base-dialog'; import BaseDialog from '../Dialog/base-dialog';
import DialogButtons from '../Dialog/dialog-buttons'; import DialogButtons from '../Dialog/dialog-buttons';
import DialogContainer from '../Dialog/dialog-container'; import DialogContainer from '../Dialog/dialog-container';
import DialogHeader from '../Dialog/dialog-header'; import DialogHeader from '../Dialog/dialog-header';
import {updateEvent} from '../DialogManager/recievers'; import {updateEvent} from '../DialogManager/recievers';
import Seperator from '../Seperator';
import {Toast} from '../Toast'; import {Toast} from '../Toast';
export class AddTopicDialog extends React.Component { export class AddTopicDialog extends React.Component {
@@ -46,13 +51,22 @@ export class AddTopicDialog extends React.Component {
eSendEvent(eOnNewTopicAdded); eSendEvent(eOnNewTopicAdded);
}; };
async open() { componentDidMount() {
console.log(this.props.notebookID); eSubscribeEvent(eOpenAddTopicDialog, this.open);
this.notebook = await db.notebooks.notebook(this.props.notebookID); eSubscribeEvent(eCloseAddTopicDialog, this.close);
}
componentWillUnmount() {
eUnSubscribeEvent(eOpenAddTopicDialog, this.open);
eUnSubscribeEvent(eCloseAddTopicDialog, this.close);
}
open = async (notebookId) => {
let id = notebookId || this.props.notebookID;
this.notebook = await db.notebooks.notebook(id);
this.setState({ this.setState({
visible: true, visible: true,
}); });
} };
close = () => { close = () => {
this.title = null; this.title = null;
this.setState({ this.setState({

View File

@@ -147,8 +147,8 @@ export class DialogManager extends Component {
eSubscribeEvent(eOpenAddNotebookDialog, this.showAddNotebook); eSubscribeEvent(eOpenAddNotebookDialog, this.showAddNotebook);
eSubscribeEvent(eCloseAddNotebookDialog, this.hideAddNotebook); eSubscribeEvent(eCloseAddNotebookDialog, this.hideAddNotebook);
eSubscribeEvent(eOpenAddTopicDialog, this.showAddTopic); //eSubscribeEvent(eOpenAddTopicDialog, this.showAddTopic);
eSubscribeEvent(eCloseAddTopicDialog, this.hideAddTopic); //eSubscribeEvent(eCloseAddTopicDialog, this.hideAddTopic);
eSubscribeEvent(eOpenLoginDialog, this.showLoginDialog); eSubscribeEvent(eOpenLoginDialog, this.showLoginDialog);
eSubscribeEvent(eCloseLoginDialog, this.hideLoginDialog); eSubscribeEvent(eCloseLoginDialog, this.hideLoginDialog);
@@ -172,8 +172,8 @@ export class DialogManager extends Component {
eUnSubscribeEvent(eOpenAddNotebookDialog, this.showAddNotebook); eUnSubscribeEvent(eOpenAddNotebookDialog, this.showAddNotebook);
eUnSubscribeEvent(eCloseAddNotebookDialog, this.hideAddNotebook); eUnSubscribeEvent(eCloseAddNotebookDialog, this.hideAddNotebook);
eUnSubscribeEvent(eOpenAddTopicDialog, this.showAddTopic); //eUnSubscribeEvent(eOpenAddTopicDialog, this.showAddTopic);
eUnSubscribeEvent(eCloseAddTopicDialog, this.hideAddTopic); //eUnSubscribeEvent(eCloseAddTopicDialog, this.hideAddTopic);
eUnSubscribeEvent(eOpenLoginDialog, this.showLoginDialog); eUnSubscribeEvent(eOpenLoginDialog, this.showLoginDialog);
eUnSubscribeEvent(eCloseLoginDialog, this.hideLoginDialog); eUnSubscribeEvent(eCloseLoginDialog, this.hideLoginDialog);