...
 
Commits (2)
......@@ -27,7 +27,7 @@
"entities": "^2.0.0",
"ethjs-signer": "^0.1.1",
"i18n-js": "^3.2.2",
"lodash": "^4.17.11",
"lodash": "^4.17.15",
"mobx": "^5.14.0",
"mobx-react": "^5.4.4",
"mobx-utils": "^5.4.1",
......
......@@ -43,17 +43,19 @@ export default
@inject('channel', 'subscriptionRequest')
@observer
class ChannelScreen extends Component {
/**
* State
*/
state = {
guid: null
guid: null,
};
/**
* Disable navigation bar
*/
static navigationOptions = {
header: null
}
header: null,
};
/**
* Load data on mount
......@@ -78,6 +80,9 @@ class ChannelScreen extends Component {
}
}
/**
* Initial load
*/
async initialLoad() {
const params = this.props.navigation.state.params;
......@@ -92,6 +97,9 @@ class ChannelScreen extends Component {
}
}
/**
* Component will unmount
*/
componentWillUnmount() {
if (this.disposeEnter) {
this.disposeEnter.remove();
......@@ -100,8 +108,11 @@ class ChannelScreen extends Component {
this.props.channel.store(this.guid).markInactive();
}
/**
* Load channel
* @param {string|UserModel} channelOrGuid
*/
async loadChannel(channelOrGuid) {
const isModel = channelOrGuid instanceof UserModel;
const guid = isModel ? channelOrGuid.guid : channelOrGuid;
const store = this.props.channel.store(guid);
......@@ -160,14 +171,14 @@ class ChannelScreen extends Component {
// load feed now
store.feedStore.loadFeed();
} catch(err) {
} catch (err) {
Alert.alert(
i18n.t('attention'),
i18n.t('channel.notFound'),
[{ text: i18n.t('ok'), onPress: () => this.props.navigation.goBack() }],
{ cancelable: false }
);
};
}
}
get guid() {
......
import {
observable,
action
} from 'mobx';
import {observable, action} from 'mobx';
import {cloneDeep} from 'lodash';
import channelService from './ChannelService';
import wireService from '../wire/WireService';
......@@ -62,6 +60,9 @@ export default class ChannelStore {
@action
async load(defaultChannel) {
if (defaultChannel) {
defaultChannel = cloneDeep(defaultChannel);
}
const channel = await channelsService.get(this.guid, defaultChannel);
if (channel) {
......