cut components for messaging

Signed-off-by: Baptiste Lemoine <contact@cipherbliss.com>
This commit is contained in:
Baptiste Lemoine 2020-01-07 12:21:34 +01:00
parent ef47cee872
commit fe7ce9f2e0
13 changed files with 481 additions and 270 deletions

View File

@ -3,6 +3,7 @@ Authors
Mastodon is available on [GitHub](https://github.com/tootsuite/mastodon) Mastodon is available on [GitHub](https://github.com/tootsuite/mastodon)
and provided thanks to the work of the following contributors: and provided thanks to the work of the following contributors:
* [Tykayn](https://framagit.org/tykayn) for the Bliss version
* [Gargron](https://github.com/Gargron) * [Gargron](https://github.com/Gargron)
* [ThibG](https://github.com/ThibG) * [ThibG](https://github.com/ThibG)

View File

@ -2,7 +2,7 @@ import { connect } from 'react-redux';
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { defineMessages, FormattedMessage, injectIntl } from 'react-intl'; import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
import { Link } from 'react-router-dom'; import { Link, NavLink } from 'react-router-dom';
import { invitesEnabled, repository, source_url, version } from 'mastodon/initial_state'; import { invitesEnabled, repository, source_url, version } from 'mastodon/initial_state';
import { logOut } from 'mastodon/utils/log_out'; import { logOut } from 'mastodon/utils/log_out';
import { openModal } from 'mastodon/actions/modal'; import { openModal } from 'mastodon/actions/modal';
@ -104,17 +104,32 @@ class LinkFooter extends React.PureComponent {
} }
render() { render() {
const HashTagNavlinks = ['Mastoart', 'OpenStreetMaps', 'Ironèmes', 'vélo'];
const { withHotkeys } = this.props; const { withHotkeys } = this.props;
var snowClasses = this.props.enableChristmasSnow ? 'snow-button active' : 'snow-button '; var snowClasses = this.props.enableChristmasSnow ? 'snow-button active' : 'snow-button ';
const navToTags = HashTagNavlinks.map(element => {
return (
<li className='tag-element btn-small btn'>
<NavLink
exact
activeClassName='active'
to={'/timelines/tag/' + element}
title='Mastoart'
>
#{element}
</NavLink >
</li >
);
});
return ( return (
<div className='getting-started__footer hide-on-smaller-screens'> <div className='links-started__footer desktop-only'>
<div className='extras'> <div className='extras'>
// TODO <button className='mod-theme btn btn-block btn-small btn-primary pull-left'>
<button className='mod-theme btn btn-block'>
{this.themeIsDark ? ( {this.themeIsDark ? (
<span <span
onClick={this.setState('theme', 'light')} onClick={this.setState('theme', 'light')}
@ -150,13 +165,26 @@ class LinkFooter extends React.PureComponent {
</div > </div >
)} )}
{isStaff && ( {isStaff && (
<span >
<a href='/admin/tags?pending_review=1'> <a
<i className='fa fa-fire' /> className='btn-warning'
Trending hashtags</a > href='/admin/tags?pending_review=1'
>
<i className='fa fa-fire' />
Trending hashtags
</a >
<a
className='btn-warning'
href='/admin/accounts'
>
<i className='fa fa-users' />
Comptes
</a >
</span >
)} )}
<br /> <br />
<div className='external-utilities'> <div className='external-utilities'>
<a href='https://mastodon.cipherbliss.com/@tykayn'> <a href='https://mastodon.cipherbliss.com/@tykayn'>
<i className='fa fa-paper-plane' /> <i className='fa fa-paper-plane' />
@ -170,10 +198,11 @@ class LinkFooter extends React.PureComponent {
<a href='https://framapad.org/'> <i className='fa fa-file-text' /> Pad</a > <a href='https://framapad.org/'> <i className='fa fa-file-text' /> Pad</a >
<a href='https://framagit.org/tykayn/mastodon'> <i className='fa fa-gitlab' /> Source</a > <a href='https://framagit.org/tykayn/mastodon'> <i className='fa fa-gitlab' /> Source</a >
<hr /> <hr />
<a href='/web/timelines/tag/vélo'> <i className='fa fa-bicycle' /> #vélo</a > <div className='suggested-tags'>
<a href='/web/timelines/tag/openstreetmap'> <i className='fa fa-map-o' /> #OpenStreetMap</a > <ul >
<a href='/web/timelines/tag/mastoart'> <i className='fa fa-paint-brush' /> #Mastoart</a > {navToTags}
<a href='/web/timelines/tag/ironèmes'> <i className='fa fa-file-text-o' /> #ironèmes</a > </ul >
</div >
</div > </div >
</div > </div >
<ul > <ul >

View File

@ -1,6 +1,7 @@
import ImmutablePureComponent from 'react-immutable-pure-component'; import ImmutablePureComponent from 'react-immutable-pure-component';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import Permalink from '../../../../components/permalink';
export default class Contact extends ImmutablePureComponent { export default class Contact extends ImmutablePureComponent {
@ -21,6 +22,7 @@ export default class Contact extends ImmutablePureComponent {
}; };
render() { render() {
const account = this.props.account;
return ( return (
<div <div
className='contact media' className='contact media'
@ -28,14 +30,22 @@ export default class Contact extends ImmutablePureComponent {
> >
<div className='name media-left'> <div className='name media-left'>
<div className='avatar image is-32x32'> <Permalink
<img key={account.id}
className='is-rounded' className='account__display-name'
src={this.props.account.avatar} title={account.acct}
alt='avatar' href={account.url}
/> to={`/accounts/${account.id}`}
</div > >
<div className='avatar image is-32x32'>
<img
className='is-rounded'
src={this.props.account.avatar}
alt='avatar'
/>
</div >
</Permalink >
</div > </div >
<div className='media-content'> <div className='media-content'>
<div className='username'> <div className='username'>

View File

@ -81,36 +81,34 @@ export default class ContactsList extends ImmutablePureComponent {
}); });
} }
const classList = 'btn btn-primary toggle-list ' + (this.state.showList ? 'active' : 'inactive'); const showListClass = (this.state.showList ? 'active' : 'inactive');
const classListContainer = 'messaging-box ' + showListClass;
const classList = 'btn btn-primary toggle-list ' + showListClass;
return ( return (
<div className='messaging-container'> <div className='messaging-container'>
<div className='messaging-box'> <div className={classListContainer}>
<div className='title column-header'> <div className='title column-header'>
<i <i
role='img' role='img'
className='fa fa-envelope column-header__icon fa-fw' className='fa fa-envelope column-header__icon fa-fw'
/> />
Messaging box {this.state.following_count} contacts
<button
className={classList}
onClick={this.toggleList}
>
{this.state.showList && (
<i className='fa fa-caret-up' />
)}
{!this.state.showList && (
<i className='fa fa-caret-left' />
)}
</button >
</div > </div >
<div className='user-list'> <div className='user-list'>
<h2 className='title'>
la liste de {this.state.following_count} contacts
<button
className={classList}
onClick={this.toggleList}
>
{this.state.showList && (
<i className='fa fa-caret-up' />
)}
{!this.state.showList && (
<i className='fa fa-caret-left' />
)}
</button >
</h2 >
{this.state.showList && ( {this.state.showList && (
<div className='contact-list-container'> <div className='contact-list-container'>
<h3 >show list</h3 >
<ul className='contact-list'> <ul className='contact-list'>
{renderedList} {renderedList}
</ul > </ul >

View File

@ -1,10 +1,11 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { mockContactList } from './mockContactList';
const following = ['bidule', 'chose', 'truc']; const following = mockContactList;
export default class Conversation extends React.Component { export default class ConversationStack extends React.Component {
static propTypes = { static propTypes = {
following: PropTypes.array, following: PropTypes.array,
@ -15,8 +16,8 @@ export default class Conversation extends React.Component {
following: following, following: following,
}; };
openConversationWith(name) { openConversationWith(account) {
console.log('openConversationWith name', name); console.log('openConversationWith name', account.username);
} }
render() { render() {
@ -28,7 +29,7 @@ export default class Conversation extends React.Component {
className='username' className='username'
onClick={this.openConversationWith(elem)} onClick={this.openConversationWith(elem)}
> >
Machin {elem} Machin {elem.username}
</div > </div >
<div className='last-active'>3 min</div > <div className='last-active'>3 min</div >
</li >), </li >),

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import ContactsList from './contacts-list'; import ContactsList from './contacts-list';
import ConversationStack from './conversationStack';
export default class InstantMessaging extends React.PureComponent { export default class InstantMessaging extends React.PureComponent {
@ -25,39 +26,12 @@ export default class InstantMessaging extends React.PureComponent {
// //
// }; // };
// constructor() {
// super();
//
// this.props.conversations = [
// {
// withAccount: '@machin',
// messages : [],
// opened : true,
// },
// {
// withAccount: '@chuck',
// messages : [],
// opened : false,
// },
// ];
// this.props.following = [
// { username: 'wulfila', handle: '@wulfila' },
// { username: 'machin', handle: '@machin' },
// { username: 'chuck norris', handle: '@chuck' },
// ];
//
// }
render() { render() {
return ( return (
<div > <div >
<div className='debug'>
messagerie todo <ContactsList />
<ConversationStack />
<ContactsList />
</div >
{/*<Conversation />*/}
</div > </div >
); );
} }

View File

@ -10,51 +10,50 @@ import LoadingBarContainer from './containers/loading_bar_container';
import ModalContainer from './containers/modal_container'; import ModalContainer from './containers/modal_container';
import { isMobile } from '../../is_mobile'; import { isMobile } from '../../is_mobile';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { uploadCompose, resetCompose } from '../../actions/compose'; import { resetCompose, uploadCompose } from '../../actions/compose';
import { expandHomeTimeline } from '../../actions/timelines'; import { expandHomeTimeline } from '../../actions/timelines';
import { expandNotifications } from '../../actions/notifications'; import { expandNotifications } from '../../actions/notifications';
import { fetchFilters } from '../../actions/filters'; import { fetchFilters } from '../../actions/filters';
import { clearHeight } from '../../actions/height_cache'; import { clearHeight } from '../../actions/height_cache';
import { focusApp, unfocusApp } from 'mastodon/actions/app'; import { focusApp, unfocusApp } from 'mastodon/actions/app';
import { submitMarkers } from 'mastodon/actions/markers'; import { submitMarkers } from 'mastodon/actions/markers';
import { WrappedSwitch, WrappedRoute } from './util/react_router_helpers'; import { WrappedRoute, WrappedSwitch } from './util/react_router_helpers';
import UploadArea from './components/upload_area'; import UploadArea from './components/upload_area';
import ColumnsAreaContainer from './containers/columns_area_container'; import ColumnsAreaContainer from './containers/columns_area_container';
import DocumentTitle from './components/document_title'; import DocumentTitle from './components/document_title';
import { import {
Compose,
Status,
GettingStarted,
KeyboardShortcuts,
PublicTimeline,
CommunityTimeline,
AccountTimeline,
AccountGallery, AccountGallery,
HomeTimeline, AccountTimeline,
Blocks,
BookmarkedStatuses,
CommunityTimeline,
Compose,
Directory,
DirectTimeline,
DomainBlocks,
FavouritedStatuses,
Favourites,
Followers, Followers,
Following, Following,
Reblogs,
Favourites,
DirectTimeline,
HashtagTimeline,
Notifications,
FollowRequests, FollowRequests,
GenericNotFound, GenericNotFound,
FavouritedStatuses, GettingStarted,
BookmarkedStatuses, HashtagTimeline,
ListTimeline, HomeTimeline,
Blocks, KeyboardShortcuts,
DomainBlocks,
Mutes,
PinnedStatuses,
Lists, Lists,
ListTimeline,
Mutes,
Notifications,
PinnedStatuses,
PublicTimeline,
Reblogs,
Search, Search,
Directory, Status,
} from './util/async-components'; } from './util/async-components';
import { me, forceSingleColumn } from '../../initial_state'; import { forceSingleColumn, me } from '../../initial_state';
import { previewState as previewMediaState } from './components/media_modal'; import { previewState as previewMediaState } from './components/media_modal';
import { previewState as previewVideoState } from './components/video_modal'; import { previewState as previewVideoState } from './components/video_modal';
// Dummy import, to make sure that <Status /> ends up in the application bundle. // Dummy import, to make sure that <Status /> ends up in the application bundle.
// Without this it ends up in ~8 very commonly used bundles. // Without this it ends up in ~8 very commonly used bundles.
import '../../components/status'; import '../../components/status';
@ -64,58 +63,64 @@ const messages = defineMessages({
}); });
const mapStateToProps = state => ({ const mapStateToProps = state => ({
isComposing: state.getIn(['compose', 'is_composing']), isComposing : state.getIn(['compose', 'is_composing']),
hasComposingText: state.getIn(['compose', 'text']).trim().length !== 0, hasComposingText : state.getIn(['compose', 'text']).trim().length !== 0,
hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0, hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0,
canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < 4, canUploadMore : !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < 4,
dropdownMenuIsOpen: state.getIn(['dropdown_menu', 'openId']) !== null, dropdownMenuIsOpen : state.getIn(['dropdown_menu', 'openId']) !== null,
}); });
const keyMap = { const keyMap = {
help: '?', help : '?',
new: 'n', new : 'n',
search: 's', search : 's',
forceNew: 'option+n', forceNew : 'option+n',
focusColumn: ['1', '2', '3', '4', '5', '6', '7', '8', '9'], focusColumn : ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
reply: 'r', reply : 'r',
favourite: 'f', favourite : 'f',
boost: 'b', boost : 'b',
mention: 'm', mention : 'm',
open: ['enter', 'o'], open : ['enter', 'o'],
openProfile: 'p', openProfile : 'p',
moveDown: ['down', 'j'], moveDown : ['down', 'j'],
moveUp: ['up', 'k'], moveUp : ['up', 'k'],
back: 'backspace', back : 'backspace',
goToHome: 'g h', goToHome : 'g h',
goToNotifications: 'g n', goToNotifications: 'g n',
goToLocal: 'g l', goToLocal : 'g l',
goToFederated: 'g t', goToFederated : 'g t',
goToDirect: 'g d', goToDirect : 'g d',
goToStart: 'g s', goToStart : 'g s',
goToFavourites: 'g f', goToFavourites : 'g f',
goToPinned: 'g p', goToPinned : 'g p',
goToProfile: 'g u', goToProfile : 'g u',
goToBlocked: 'g b', goToBlocked : 'g b',
goToMuted: 'g m', goToMuted : 'g m',
goToRequests: 'g r', goToRequests : 'g r',
toggleHidden: 'x', toggleHidden : 'x',
toggleSensitive: 'h', toggleSensitive : 'h',
openMedia: 'e', openMedia : 'e',
}; };
class SwitchingColumnsArea extends React.PureComponent { class SwitchingColumnsArea extends React.PureComponent {
static propTypes = { static propTypes = {
children: PropTypes.node, children : PropTypes.node,
location: PropTypes.object, location : PropTypes.object,
onLayoutChange: PropTypes.func.isRequired, onLayoutChange: PropTypes.func.isRequired,
}; };
state = { state = {
mobile: isMobile(window.innerWidth), mobile: isMobile(window.innerWidth),
}; };
handleLayoutChange = debounce(() => {
// The cached heights are no longer accurate, invalidate
this.props.onLayoutChange();
}, 500, {
trailing: true,
});
componentWillMount () { componentWillMount() {
window.addEventListener('resize', this.handleResize, { passive: true }); window.addEventListener('resize', this.handleResize, { passive: true });
if (this.state.mobile || forceSingleColumn) { if (this.state.mobile || forceSingleColumn) {
@ -127,7 +132,7 @@ class SwitchingColumnsArea extends React.PureComponent {
} }
} }
componentDidUpdate (prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (![this.props.location.pathname, '/'].includes(prevProps.location.pathname)) { if (![this.props.location.pathname, '/'].includes(prevProps.location.pathname)) {
this.node.handleChildrenContentChange(); this.node.handleChildrenContentChange();
} }
@ -138,21 +143,14 @@ class SwitchingColumnsArea extends React.PureComponent {
} }
} }
componentWillUnmount () { componentWillUnmount() {
window.removeEventListener('resize', this.handleResize); window.removeEventListener('resize', this.handleResize);
} }
shouldUpdateScroll (_, { location }) { shouldUpdateScroll(_, { location }) {
return location.state !== previewMediaState && location.state !== previewVideoState; return location.state !== previewMediaState && location.state !== previewVideoState;
} }
handleLayoutChange = debounce(() => {
// The cached heights are no longer accurate, invalidate
this.props.onLayoutChange();
}, 500, {
trailing: true,
})
handleResize = () => { handleResize = () => {
const mobile = isMobile(window.innerWidth); const mobile = isMobile(window.innerWidth);
@ -163,61 +161,219 @@ class SwitchingColumnsArea extends React.PureComponent {
} else { } else {
this.handleLayoutChange(); this.handleLayoutChange();
} }
} };
setRef = c => { setRef = c => {
if (c) { if (c) {
this.node = c.getWrappedInstance(); this.node = c.getWrappedInstance();
} }
} };
render () { render() {
const { children } = this.props; const { children } = this.props;
const { mobile } = this.state; const { mobile } = this.state;
const singleColumn = forceSingleColumn || mobile; const singleColumn = forceSingleColumn || mobile;
const redirect = singleColumn ? <Redirect from='/' to='/timelines/home' exact /> : <Redirect from='/' to='/getting-started' exact />; const redirect = singleColumn ? (<Redirect
from='/'
to='/timelines/home'
exact
/>) : (<Redirect
from='/'
to='/getting-started'
exact
/>);
return ( return (
<ColumnsAreaContainer ref={this.setRef} singleColumn={singleColumn}> <ColumnsAreaContainer
<WrappedSwitch> ref={this.setRef}
singleColumn={singleColumn}
>
<WrappedSwitch >
{redirect} {redirect}
<WrappedRoute path='/getting-started' component={GettingStarted} content={children} /> <WrappedRoute
<WrappedRoute path='/keyboard-shortcuts' component={KeyboardShortcuts} content={children} /> path='/tk-example'
<WrappedRoute path='/timelines/home' component={HomeTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> component={GettingStarted}
<WrappedRoute path='/timelines/public' exact component={PublicTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> content={children}
<WrappedRoute path='/timelines/public/local' exact component={CommunityTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> />
<WrappedRoute path='/timelines/direct' component={DirectTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> <WrappedRoute
<WrappedRoute path='/timelines/tag/:id' component={HashtagTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> path='/getting-started'
<WrappedRoute path='/timelines/list/:id' component={ListTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> component={GettingStarted}
content={children}
/>
<WrappedRoute
path='/keyboard-shortcuts'
component={KeyboardShortcuts}
content={children}
/>
<WrappedRoute
path='/timelines/home'
component={HomeTimeline}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/timelines/public'
exact
component={PublicTimeline}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/timelines/public/local'
exact
component={CommunityTimeline}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/timelines/direct'
component={DirectTimeline}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/timelines/tag/:id'
component={HashtagTimeline}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/timelines/list/:id'
component={ListTimeline}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute path='/notifications' component={Notifications} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> <WrappedRoute
<WrappedRoute path='/favourites' component={FavouritedStatuses} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> path='/notifications'
<WrappedRoute path='/bookmarks' component={BookmarkedStatuses} content={children} /> component={Notifications}
<WrappedRoute path='/pinned' component={PinnedStatuses} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/favourites'
component={FavouritedStatuses}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/bookmarks'
component={BookmarkedStatuses}
content={children}
/>
<WrappedRoute
path='/pinned'
component={PinnedStatuses}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute path='/search' component={Search} content={children} /> <WrappedRoute
<WrappedRoute path='/directory' component={Directory} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> path='/search'
component={Search}
content={children}
/>
<WrappedRoute
path='/directory'
component={Directory}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute path='/statuses/new' component={Compose} content={children} /> <WrappedRoute
<WrappedRoute path='/statuses/:statusId' exact component={Status} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> path='/statuses/new'
<WrappedRoute path='/statuses/:statusId/reblogs' component={Reblogs} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> component={Compose}
<WrappedRoute path='/statuses/:statusId/favourites' component={Favourites} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> content={children}
/>
<WrappedRoute
path='/statuses/:statusId'
exact
component={Status}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/statuses/:statusId/reblogs'
component={Reblogs}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/statuses/:statusId/favourites'
component={Favourites}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute path='/accounts/:accountId' exact component={AccountTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> <WrappedRoute
<WrappedRoute path='/accounts/:accountId/with_replies' component={AccountTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll, withReplies: true }} /> path='/accounts/:accountId'
<WrappedRoute path='/accounts/:accountId/followers' component={Followers} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> exact
<WrappedRoute path='/accounts/:accountId/following' component={Following} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> component={AccountTimeline}
<WrappedRoute path='/accounts/:accountId/media' component={AccountGallery} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/accounts/:accountId/with_replies'
component={AccountTimeline}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll, withReplies: true }}
/>
<WrappedRoute
path='/accounts/:accountId/followers'
component={Followers}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/accounts/:accountId/following'
component={Following}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/accounts/:accountId/media'
component={AccountGallery}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute path='/follow_requests' component={FollowRequests} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> <WrappedRoute
<WrappedRoute path='/blocks' component={Blocks} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> path='/follow_requests'
<WrappedRoute path='/domain_blocks' component={DomainBlocks} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> component={FollowRequests}
<WrappedRoute path='/mutes' component={Mutes} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> content={children}
<WrappedRoute path='/lists' component={Lists} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/blocks'
component={Blocks}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/domain_blocks'
component={DomainBlocks}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/mutes'
component={Mutes}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute
path='/lists'
component={Lists}
content={children}
componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }}
/>
<WrappedRoute component={GenericNotFound} content={children} /> <WrappedRoute
</WrappedSwitch> component={GenericNotFound}
</ColumnsAreaContainer> content={children}
/>
</WrappedSwitch >
</ColumnsAreaContainer >
); );
} }
@ -233,15 +389,15 @@ class UI extends React.PureComponent {
}; };
static propTypes = { static propTypes = {
dispatch: PropTypes.func.isRequired, dispatch : PropTypes.func.isRequired,
children: PropTypes.node, children : PropTypes.node,
isComposing: PropTypes.bool, isComposing : PropTypes.bool,
hasComposingText: PropTypes.bool, hasComposingText : PropTypes.bool,
hasMediaAttachments: PropTypes.bool, hasMediaAttachments: PropTypes.bool,
canUploadMore: PropTypes.bool, canUploadMore : PropTypes.bool,
location: PropTypes.object, location : PropTypes.object,
intl: PropTypes.object.isRequired, intl : PropTypes.object.isRequired,
dropdownMenuIsOpen: PropTypes.bool, dropdownMenuIsOpen : PropTypes.bool,
}; };
state = { state = {
@ -259,20 +415,20 @@ class UI extends React.PureComponent {
// but we set user-friendly message for other browsers, e.g. Edge. // but we set user-friendly message for other browsers, e.g. Edge.
e.returnValue = intl.formatMessage(messages.beforeUnload); e.returnValue = intl.formatMessage(messages.beforeUnload);
} }
} };
handleWindowFocus = () => { handleWindowFocus = () => {
this.props.dispatch(focusApp()); this.props.dispatch(focusApp());
} };
handleWindowBlur = () => { handleWindowBlur = () => {
this.props.dispatch(unfocusApp()); this.props.dispatch(unfocusApp());
} };
handleLayoutChange = () => { handleLayoutChange = () => {
// The cached heights are no longer accurate, invalidate // The cached heights are no longer accurate, invalidate
this.props.dispatch(clearHeight()); this.props.dispatch(clearHeight());
} };
handleDragEnter = (e) => { handleDragEnter = (e) => {
e.preventDefault(); e.preventDefault();
@ -288,7 +444,7 @@ class UI extends React.PureComponent {
if (e.dataTransfer && Array.from(e.dataTransfer.types).includes('Files') && this.props.canUploadMore) { if (e.dataTransfer && Array.from(e.dataTransfer.types).includes('Files') && this.props.canUploadMore) {
this.setState({ draggingOver: true }); this.setState({ draggingOver: true });
} }
} };
handleDragOver = (e) => { handleDragOver = (e) => {
if (this.dataTransferIsText(e.dataTransfer)) return false; if (this.dataTransferIsText(e.dataTransfer)) return false;
@ -303,7 +459,7 @@ class UI extends React.PureComponent {
} }
return false; return false;
} };
handleDrop = (e) => { handleDrop = (e) => {
if (this.dataTransferIsText(e.dataTransfer)) return; if (this.dataTransferIsText(e.dataTransfer)) return;
@ -316,7 +472,7 @@ class UI extends React.PureComponent {
if (e.dataTransfer && e.dataTransfer.files.length >= 1 && this.props.canUploadMore) { if (e.dataTransfer && e.dataTransfer.files.length >= 1 && this.props.canUploadMore) {
this.props.dispatch(uploadCompose(e.dataTransfer.files)); this.props.dispatch(uploadCompose(e.dataTransfer.files));
} }
} };
handleDragLeave = (e) => { handleDragLeave = (e) => {
e.preventDefault(); e.preventDefault();
@ -329,15 +485,15 @@ class UI extends React.PureComponent {
} }
this.setState({ draggingOver: false }); this.setState({ draggingOver: false });
} };
dataTransferIsText = (dataTransfer) => { dataTransferIsText = (dataTransfer) => {
return (dataTransfer && Array.from(dataTransfer.types).filter((type) => type === 'text/plain').length === 1); return (dataTransfer && Array.from(dataTransfer.types).filter((type) => type === 'text/plain').length === 1);
} };
closeUploadModal = () => { closeUploadModal = () => {
this.setState({ draggingOver: false }); this.setState({ draggingOver: false });
} };
handleServiceWorkerPostMessage = ({ data }) => { handleServiceWorkerPostMessage = ({ data }) => {
if (data.type === 'navigate') { if (data.type === 'navigate') {
@ -345,9 +501,9 @@ class UI extends React.PureComponent {
} else { } else {
console.warn('Unknown message type:', data.type); console.warn('Unknown message type:', data.type);
} }
} };
componentWillMount () { componentWillMount() {
window.addEventListener('focus', this.handleWindowFocus, false); window.addEventListener('focus', this.handleWindowFocus, false);
window.addEventListener('blur', this.handleWindowBlur, false); window.addEventListener('blur', this.handleWindowBlur, false);
window.addEventListener('beforeunload', this.handleBeforeUnload, false); window.addEventListener('beforeunload', this.handleBeforeUnload, false);
@ -358,7 +514,7 @@ class UI extends React.PureComponent {
document.addEventListener('dragleave', this.handleDragLeave, false); document.addEventListener('dragleave', this.handleDragLeave, false);
document.addEventListener('dragend', this.handleDragEnd, false); document.addEventListener('dragend', this.handleDragEnd, false);
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
navigator.serviceWorker.addEventListener('message', this.handleServiceWorkerPostMessage); navigator.serviceWorker.addEventListener('message', this.handleServiceWorkerPostMessage);
} }
@ -372,13 +528,13 @@ class UI extends React.PureComponent {
setTimeout(() => this.props.dispatch(fetchFilters()), 500); setTimeout(() => this.props.dispatch(fetchFilters()), 500);
} }
componentDidMount () { componentDidMount() {
this.hotkeys.__mousetrap__.stopCallback = (e, element) => { this.hotkeys.__mousetrap__.stopCallback = (e, element) => {
return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName); return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName);
}; };
} }
componentWillUnmount () { componentWillUnmount() {
window.removeEventListener('focus', this.handleWindowFocus); window.removeEventListener('focus', this.handleWindowFocus);
window.removeEventListener('blur', this.handleWindowBlur); window.removeEventListener('blur', this.handleWindowBlur);
window.removeEventListener('beforeunload', this.handleBeforeUnload); window.removeEventListener('beforeunload', this.handleBeforeUnload);
@ -392,7 +548,7 @@ class UI extends React.PureComponent {
setRef = c => { setRef = c => {
this.node = c; this.node = c;
} };
handleHotkeyNew = e => { handleHotkeyNew = e => {
e.preventDefault(); e.preventDefault();
@ -402,7 +558,7 @@ class UI extends React.PureComponent {
if (element) { if (element) {
element.focus(); element.focus();
} }
} };
handleHotkeySearch = e => { handleHotkeySearch = e => {
e.preventDefault(); e.preventDefault();
@ -412,15 +568,15 @@ class UI extends React.PureComponent {
if (element) { if (element) {
element.focus(); element.focus();
} }
} };
handleHotkeyForceNew = e => { handleHotkeyForceNew = e => {
this.handleHotkeyNew(e); this.handleHotkeyNew(e);
this.props.dispatch(resetCompose()); this.props.dispatch(resetCompose());
} };
handleHotkeyFocusColumn = e => { handleHotkeyFocusColumn = e => {
const index = (e.key * 1) + 1; // First child is drawer, skip that const index = (e.key * 1) + 1; // First child is drawer, skip that
const column = this.node.querySelector(`.column:nth-child(${index})`); const column = this.node.querySelector(`.column:nth-child(${index})`);
if (!column) return; if (!column) return;
const container = column.querySelector('.scrollable'); const container = column.querySelector('.scrollable');
@ -435,7 +591,7 @@ class UI extends React.PureComponent {
status.focus(); status.focus();
} }
} }
} };
handleHotkeyBack = () => { handleHotkeyBack = () => {
if (window.history && window.history.length === 1) { if (window.history && window.history.length === 1) {
@ -443,11 +599,11 @@ class UI extends React.PureComponent {
} else { } else {
this.context.router.history.goBack(); this.context.router.history.goBack();
} }
} };
setHotkeysRef = c => { setHotkeysRef = c => {
this.hotkeys = c; this.hotkeys = c;
} };
handleHotkeyToggleHelp = () => { handleHotkeyToggleHelp = () => {
if (this.props.location.pathname === '/keyboard-shortcuts') { if (this.props.location.pathname === '/keyboard-shortcuts') {
@ -455,95 +611,111 @@ class UI extends React.PureComponent {
} else { } else {
this.context.router.history.push('/keyboard-shortcuts'); this.context.router.history.push('/keyboard-shortcuts');
} }
} };
handleHotkeyGoToHome = () => { handleHotkeyGoToHome = () => {
this.context.router.history.push('/timelines/home'); this.context.router.history.push('/timelines/home');
} };
handleHotkeyGoToNotifications = () => { handleHotkeyGoToNotifications = () => {
this.context.router.history.push('/notifications'); this.context.router.history.push('/notifications');
} };
handleHotkeyGoToLocal = () => { handleHotkeyGoToLocal = () => {
this.context.router.history.push('/timelines/public/local'); this.context.router.history.push('/timelines/public/local');
} };
handleHotkeyGoToFederated = () => { handleHotkeyGoToFederated = () => {
this.context.router.history.push('/timelines/public'); this.context.router.history.push('/timelines/public');
} };
handleHotkeyGoToDirect = () => { handleHotkeyGoToDirect = () => {
this.context.router.history.push('/timelines/direct'); this.context.router.history.push('/timelines/direct');
} };
handleHotkeyGoToStart = () => { handleHotkeyGoToStart = () => {
this.context.router.history.push('/getting-started'); this.context.router.history.push('/getting-started');
} };
handleHotkeyGoToFavourites = () => { handleHotkeyGoToFavourites = () => {
this.context.router.history.push('/favourites'); this.context.router.history.push('/favourites');
} };
handleHotkeyGoToPinned = () => { handleHotkeyGoToPinned = () => {
this.context.router.history.push('/pinned'); this.context.router.history.push('/pinned');
} };
handleHotkeyGoToProfile = () => { handleHotkeyGoToProfile = () => {
this.context.router.history.push(`/accounts/${me}`); this.context.router.history.push(`/accounts/${me}`);
} };
handleHotkeyGoToBlocked = () => { handleHotkeyGoToBlocked = () => {
this.context.router.history.push('/blocks'); this.context.router.history.push('/blocks');
} };
handleHotkeyGoToMuted = () => { handleHotkeyGoToMuted = () => {
this.context.router.history.push('/mutes'); this.context.router.history.push('/mutes');
} };
handleHotkeyGoToRequests = () => { handleHotkeyGoToRequests = () => {
this.context.router.history.push('/follow_requests'); this.context.router.history.push('/follow_requests');
} };
render () { render() {
const { draggingOver } = this.state; const { draggingOver } = this.state;
const { children, isComposing, location, dropdownMenuIsOpen } = this.props; const { children, isComposing, location, dropdownMenuIsOpen } = this.props;
const handlers = { const handlers = {
help: this.handleHotkeyToggleHelp, help : this.handleHotkeyToggleHelp,
new: this.handleHotkeyNew, new : this.handleHotkeyNew,
search: this.handleHotkeySearch, search : this.handleHotkeySearch,
forceNew: this.handleHotkeyForceNew, forceNew : this.handleHotkeyForceNew,
focusColumn: this.handleHotkeyFocusColumn, focusColumn : this.handleHotkeyFocusColumn,
back: this.handleHotkeyBack, back : this.handleHotkeyBack,
goToHome: this.handleHotkeyGoToHome, goToHome : this.handleHotkeyGoToHome,
goToNotifications: this.handleHotkeyGoToNotifications, goToNotifications: this.handleHotkeyGoToNotifications,
goToLocal: this.handleHotkeyGoToLocal, goToLocal : this.handleHotkeyGoToLocal,
goToFederated: this.handleHotkeyGoToFederated, goToFederated : this.handleHotkeyGoToFederated,
goToDirect: this.handleHotkeyGoToDirect, goToDirect : this.handleHotkeyGoToDirect,
goToStart: this.handleHotkeyGoToStart, goToStart : this.handleHotkeyGoToStart,
goToFavourites: this.handleHotkeyGoToFavourites, goToFavourites : this.handleHotkeyGoToFavourites,
goToPinned: this.handleHotkeyGoToPinned, goToPinned : this.handleHotkeyGoToPinned,
goToProfile: this.handleHotkeyGoToProfile, goToProfile : this.handleHotkeyGoToProfile,
goToBlocked: this.handleHotkeyGoToBlocked, goToBlocked : this.handleHotkeyGoToBlocked,
goToMuted: this.handleHotkeyGoToMuted, goToMuted : this.handleHotkeyGoToMuted,
goToRequests: this.handleHotkeyGoToRequests, goToRequests : this.handleHotkeyGoToRequests,
}; };
return ( return (
<HotKeys keyMap={keyMap} handlers={handlers} ref={this.setHotkeysRef} attach={window} focused> <HotKeys
<div className={classNames('ui', { 'is-composing': isComposing })} ref={this.setRef} style={{ pointerEvents: dropdownMenuIsOpen ? 'none' : null }}> keyMap={keyMap}
<SwitchingColumnsArea location={location} onLayoutChange={this.handleLayoutChange}> handlers={handlers}
ref={this.setHotkeysRef}
attach={window}
focused
>
<div
className={classNames('ui', { 'is-composing': isComposing })}
ref={this.setRef}
style={{ pointerEvents: dropdownMenuIsOpen ? 'none' : null }}
>
<SwitchingColumnsArea
location={location}
onLayoutChange={this.handleLayoutChange}
>
{children} {children}
</SwitchingColumnsArea> </SwitchingColumnsArea >
<NotificationsContainer /> <NotificationsContainer />
<LoadingBarContainer className='loading-bar' /> <LoadingBarContainer className='loading-bar' />
<ModalContainer /> <ModalContainer />
<UploadArea active={draggingOver} onClose={this.closeUploadModal} /> <UploadArea
active={draggingOver}
onClose={this.closeUploadModal}
/>
<DocumentTitle /> <DocumentTitle />
</div> </div >
</HotKeys> </HotKeys >
); );
} }

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Switch, Route } from 'react-router-dom'; import { Route, Switch } from 'react-router-dom';
import ColumnLoading from '../components/column_loading'; import ColumnLoading from '../components/column_loading';
import BundleColumnError from '../components/bundle_column_error'; import BundleColumnError from '../components/bundle_column_error';
@ -9,13 +9,13 @@ import BundleContainer from '../containers/bundle_container';
// Small wrapper to pass multiColumn to the route components // Small wrapper to pass multiColumn to the route components
export class WrappedSwitch extends React.PureComponent { export class WrappedSwitch extends React.PureComponent {
render () { render() {
const { multiColumn, children } = this.props; const { multiColumn, children } = this.props;
return ( return (
<Switch> <Switch >
{React.Children.map(children, child => React.cloneElement(child, { multiColumn }))} {React.Children.map(children, child => React.cloneElement(child, { multiColumn }))}
</Switch> </Switch >
); );
} }
@ -23,7 +23,7 @@ export class WrappedSwitch extends React.PureComponent {
WrappedSwitch.propTypes = { WrappedSwitch.propTypes = {
multiColumn: PropTypes.bool, multiColumn: PropTypes.bool,
children: PropTypes.node, children : PropTypes.node,
}; };
// Small Wrapper to extract the params from the route and pass // Small Wrapper to extract the params from the route and pass
@ -32,9 +32,9 @@ WrappedSwitch.propTypes = {
export class WrappedRoute extends React.Component { export class WrappedRoute extends React.Component {
static propTypes = { static propTypes = {
component: PropTypes.func.isRequired, component : PropTypes.func.isRequired,
content: PropTypes.node, content : PropTypes.node,
multiColumn: PropTypes.bool, multiColumn : PropTypes.bool,
componentParams: PropTypes.object, componentParams: PropTypes.object,
}; };
@ -46,21 +46,28 @@ export class WrappedRoute extends React.Component {
const { component, content, multiColumn, componentParams } = this.props; const { component, content, multiColumn, componentParams } = this.props;
return ( return (
<BundleContainer fetchComponent={component} loading={this.renderLoading} error={this.renderError}> <BundleContainer
{Component => <Component params={match.params} multiColumn={multiColumn} {...componentParams}>{content}</Component>} fetchComponent={component}
</BundleContainer> loading={this.renderLoading}
error={this.renderError}
>
{Component => (<Component
params={match.params}
multiColumn={multiColumn} {...componentParams}
>{content}</Component >)}
</BundleContainer >
); );
} };
renderLoading = () => { renderLoading = () => {
return <ColumnLoading />; return <ColumnLoading />;
} };
renderError = (props) => { renderError = (props) => {
return <BundleColumnError {...props} />; return <BundleColumnError {...props} />;
} };
render () { render() {
const { component: Component, content, ...rest } = this.props; const { component: Component, content, ...rest } = this.props;
return <Route {...rest} render={this.renderComponent} />; return <Route {...rest} render={this.renderComponent} />;

View File

@ -4,7 +4,6 @@ import { fromJS, Map as ImmutableMap } from 'immutable';
const initialState = ImmutableMap(); const initialState = ImmutableMap();
const normalizeAccount = (state, account) => { const normalizeAccount = (state, account) => {
console.log('account', account);
account = { ...account }; account = { ...account };
delete account.followers_count; delete account.followers_count;

View File

@ -1,3 +1,6 @@
@import '~bulma/bulma';
@import '~bulma/sass/utilities/mixins';
@import 'bliss/variables'; @import 'bliss/variables';
@import 'bliss/mixins'; @import 'bliss/mixins';
@import 'bliss/variables'; @import 'bliss/variables';

View File

@ -2265,9 +2265,7 @@ a.account__display-name {
.columns-area__panels__pane--compositional { .columns-area__panels__pane--compositional {
display: none; display: none;
} }
.hide-on-smaller-screens{
display: none;
}
} }
@media screen and (min-width: 600px + (285px * 1) + (10px * 1)) { @media screen and (min-width: 600px + (285px * 1) + (10px * 1)) {

View File

@ -136,7 +136,7 @@
} }
} }
.getting-started__footer { .links-started__footer {
display: block; display: block;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
@ -144,6 +144,11 @@
width: 32vw; width: 32vw;
z-index: 10; z-index: 10;
text-align: right; text-align: right;
color: $ui-primary-color;
hr {
border-color: $ui-primary-color;
}
.fa { .fa {
margin-right: 1ch; margin-right: 1ch;
@ -164,5 +169,6 @@
a { a {
margin-left: 2ch; margin-left: 2ch;
color: $ui-primary-color;
} }
} }

View File

@ -1,5 +1,5 @@
$messagingBoxWidth: 15em; $messagingBoxWidth: 20em;
$messagingBoxHeight: 20em; $messagingBoxHeight: 100%;
.fixed-box { .fixed-box {
border: solid 1px white; border: solid 1px white;
@ -26,8 +26,13 @@ $messagingBoxHeight: 20em;
right: 1em; right: 1em;
width: $messagingBoxWidth; width: $messagingBoxWidth;
background: $ui-base-color; background: $ui-base-color;
height: 80%; height: 4em;
color: white; color: white;
z-index: 10;
&.active {
height: $messagingBoxHeight;
}
.messager-textarea { .messager-textarea {
width: 100%; width: 100%;
@ -38,6 +43,10 @@ $messagingBoxHeight: 20em;
} }
} }
.contact-list-container {
overflow-x: auto;
}
.contact-list { .contact-list {
display: block; display: block;
padding: 1em; padding: 1em;
@ -45,8 +54,12 @@ $messagingBoxHeight: 20em;
list-style-type: none; list-style-type: none;
color: white; color: white;
.contact {
margin-bottom: 0.5rem;
}
} }
.toggle-list { .toggle-list {
float: right; float: right;
margin-left: 1em; margin-left: 1em;