From fcf55d259f1fa5dac66bb7fa5d6048f371579e1d Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 6 Mar 2018 14:40:44 -0300 Subject: [PATCH] Workaround for RN 0.54 on iOS (#246) --- app/animations/fade.js | 5 +---- app/containers/EmojiPicker/EmojiCategory.js | 6 +----- app/containers/EmojiPicker/index.js | 11 ++++------- app/containers/Sidebar.js | 15 ++++++++++----- app/views/ListServerView.js | 14 ++++++-------- app/views/LoginView.js | 8 ++++---- app/views/RoomMembersView/index.js | 2 +- 7 files changed, 27 insertions(+), 34 deletions(-) diff --git a/app/animations/fade.js b/app/animations/fade.js index b9657e49..97693d03 100644 --- a/app/animations/fade.js +++ b/app/animations/fade.js @@ -17,6 +17,7 @@ export default class Fade extends React.Component { this.state = { visible: props.visible }; + this._visibility = new Animated.Value(this.props.visible ? 1 : 0); } componentWillReceiveProps(nextProps) { @@ -32,10 +33,6 @@ export default class Fade extends React.Component { }); } - UNSAFE_componentWillMount() { - this._visibility = new Animated.Value(this.props.visible ? 1 : 0); - } - render() { const { style, children, ...rest } = this.props; diff --git a/app/containers/EmojiPicker/EmojiCategory.js b/app/containers/EmojiPicker/EmojiCategory.js index 5643e057..3e3823ba 100644 --- a/app/containers/EmojiPicker/EmojiCategory.js +++ b/app/containers/EmojiPicker/EmojiCategory.js @@ -36,17 +36,13 @@ export default class EmojiCategory extends React.Component { const { width, height } = this.props.window; this.size = Math.min(this.props.width || width, height) / (this.props.emojisPerRow || emojisPerRow); - this.emojis = []; + this.emojis = props.emojis; } shouldComponentUpdate() { return false; } - UNSAFE_componentWillMount() { - this.emojis = this.props.emojis; - } - renderItem(emoji, size) { return ( this.setState({ show: true })); + this.frequentlyUsed.addListener(this.updateFrequentlyUsed); + this.customEmojis.addListener(this.updateCustomEmojis); + this.updateFrequentlyUsed(); + this.updateCustomEmojis(); } componentWillUnmount() { this.frequentlyUsed.removeAllListeners(); @@ -64,13 +68,6 @@ export default class EmojiPicker extends Component { } } - UNSAFE_componentWillMount() { - this.frequentlyUsed.addListener(this.updateFrequentlyUsed); - this.customEmojis.addListener(this.updateCustomEmojis); - this.updateFrequentlyUsed(); - this.updateCustomEmojis(); - } - _addFrequentlyUsed = (emoji) => { database.write(() => { database.create('frequentlyUsedEmoji', emoji, true); diff --git a/app/containers/Sidebar.js b/app/containers/Sidebar.js index 186a0af3..66538af5 100644 --- a/app/containers/Sidebar.js +++ b/app/containers/Sidebar.js @@ -52,6 +52,16 @@ export default class Sidebar extends Component { gotoAddServer: PropTypes.func.isRequired } + constructor(props) { + super(props); + this.state = { servers: [] }; + } + + componentDidMount() { + database.databases.serversDB.addListener('change', this.updateState); + this.setState(this.getState()); + } + componentWillUnmount() { database.databases.serversDB.removeListener('change', this.updateState); } @@ -72,11 +82,6 @@ export default class Sidebar extends Component { servers: database.databases.serversDB.objects('servers') }) - UNSAFE_componentWillMount() { - database.databases.serversDB.addListener('change', this.updateState); - this.setState(this.getState()); - } - updateState = () => { this.setState(this.getState()); } diff --git a/app/views/ListServerView.js b/app/views/ListServerView.js index 423e967c..7b4c2905 100644 --- a/app/views/ListServerView.js +++ b/app/views/ListServerView.js @@ -88,6 +88,12 @@ export default class ListServerView extends React.Component { this.data.addListener(this.updateState); } + componentDidMount() { + zeroconf.on('update', this.updateState); + zeroconf.scan('http', 'tcp', 'local.'); + this.setState(this.getState()); + } + componentDidUpdate() { if (this.props.connected && this.props.server && @@ -140,14 +146,6 @@ export default class ListServerView extends React.Component { }; }; - UNSAFE_componentWillMount() { - zeroconf.on('update', this.updateState); - - zeroconf.scan('http', 'tcp', 'local.'); - - this.setState(this.getState()); - } - updateState = () => { this.setState(this.getState()); } diff --git a/app/views/LoginView.js b/app/views/LoginView.js index 52337879..d1647cff 100644 --- a/app/views/LoginView.js +++ b/app/views/LoginView.js @@ -70,6 +70,10 @@ export default class LoginView extends React.Component { this.redirectRegex = new RegExp(`(?=.*(${ this.props.server }))(?=.*(credentialToken))(?=.*(credentialSecret))`, 'g'); } + componentDidMount() { + this.props.open(); + } + componentWillReceiveProps(nextProps) { if (this.props.services !== nextProps.services) { LayoutAnimation.easeInEaseOut(); @@ -150,10 +154,6 @@ export default class LoginView extends React.Component { return Base64.encodeURI(JSON.stringify({ loginStyle: 'popup', credentialToken, isCordova: true })); } - UNSAFE_componentWillMount() { - this.props.open(); - } - openOAuth = (oAuthUrl) => { this.setState({ oAuthUrl, modalVisible: true }); } diff --git a/app/views/RoomMembersView/index.js b/app/views/RoomMembersView/index.js index a3d8d6f0..321864f6 100644 --- a/app/views/RoomMembersView/index.js +++ b/app/views/RoomMembersView/index.js @@ -57,7 +57,7 @@ export default class MentionedMessagesView extends React.PureComponent { }; } - componentWillMount() { + componentDidMount() { this.props.navigation.setParams({ onPressToogleStatus: this.onPressToogleStatus, allUsers: this.state.allUsers