/* Copyright 2017 Vector Creations Ltd Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import React from 'react'; import createReactClass from 'create-react-class'; import PropTypes from 'prop-types'; import { MatrixClient } from 'matrix-js-sdk'; import sdk from '../../index'; import { _t } from '../../languageHandler'; import dis from '../../dispatcher'; import AccessibleButton from '../views/elements/AccessibleButton'; export default createReactClass({ displayName: 'MyGroups', getInitialState: function() { return { groups: null, error: null, }; }, contextTypes: { matrixClient: PropTypes.instanceOf(MatrixClient).isRequired, }, componentWillMount: function() { this._fetch(); }, _onCreateGroupClick: function() { dis.dispatch({action: 'view_create_group'}); }, _fetch: function() { this.context.matrixClient.getJoinedGroups().then((result) => { this.setState({groups: result.groups, error: null}); }, (err) => { if (err.errcode === 'M_GUEST_ACCESS_FORBIDDEN') { // Indicate that the guest isn't in any groups (which should be true) this.setState({groups: [], error: null}); return; } this.setState({groups: null, error: err}); }); }, render: function() { const Loader = sdk.getComponent("elements.Spinner"); const SimpleRoomHeader = sdk.getComponent('rooms.SimpleRoomHeader'); const GroupTile = sdk.getComponent("groups.GroupTile"); const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper"); let content; let contentHeader; if (this.state.groups) { const groupNodes = []; this.state.groups.forEach((g) => { groupNodes.push(); }); contentHeader = groupNodes.length > 0 ?

{ _t('Your Communities') }

:
; content = groupNodes.length > 0 ?

{ _t( "Did you know: you can use communities to filter your Riot.im experience!", ) }

{ _t( "To set up a filter, drag a community avatar over to the filter panel on " + "the far left hand side of the screen. You can click on an avatar in the " + "filter panel at any time to see only the rooms and people associated " + "with that community.", ) }

{ groupNodes }
:
{ _t( "You're not currently a member of any communities.", ) }
; } else if (this.state.error) { content =
{ _t('Error whilst fetching joined communities') }
; } else { content = ; } return
{ _t('Create a new community') }
{ _t( 'Create a community to group together users and rooms! ' + 'Build a custom homepage to mark out your space in the Matrix universe.', ) }
{/*
{ _t('Join an existing community') }
{ _t( 'To join an existing community you\'ll have to '+ 'know its community identifier; this will look '+ 'something like +example:matrix.org.', {}, { 'i': (sub) => { sub } }) }
*/}
{ contentHeader } { content }
; }, });