[Glitch] Profile redirect notes

Port WebUI changes from 58cede4808
master
Thibaut Girka 6 years ago
parent 4e45954280
commit a59c146bf8
  1. 7
      app/javascript/flavours/glitch/features/account/components/header.js
  2. 3
      app/javascript/flavours/glitch/features/account_timeline/components/header.js
  3. 48
      app/javascript/flavours/glitch/features/account_timeline/components/moved_note.js
  4. 5
      app/javascript/flavours/glitch/reducers/accounts.js
  5. 8
      app/javascript/flavours/glitch/selectors/index.js

@ -10,6 +10,7 @@ import IconButton from 'flavours/glitch/components/icon_button';
import emojify from 'flavours/glitch/util/emoji';
import { me } from 'flavours/glitch/util/initial_state';
import { processBio } from 'flavours/glitch/util/bio_metadata';
import classNames from 'classnames';
const messages = defineMessages({
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
@ -75,11 +76,15 @@ export default class Header extends ImmutablePureComponent {
}
}
if (account.get('moved')) {
actionBtn = '';
}
const { text, metadata } = processBio(account.get('note'));
return (
<div className='account__header__wrapper'>
<div className='account__header' style={{ backgroundImage: `url(${account.get('header')})` }}>
<div className={classNames('account__header', { inactive: !!account.get('moved') })} style={{ backgroundImage: `url(${account.get('header')})` }}>
<div>
<a
href={account.get('url')}

@ -7,6 +7,7 @@ import MissingIndicator from 'flavours/glitch/components/missing_indicator';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { FormattedMessage } from 'react-intl';
import { NavLink } from 'react-router-dom';
import MovedNote from './moved_note';
export default class Header extends ImmutablePureComponent {
@ -76,6 +77,8 @@ export default class Header extends ImmutablePureComponent {
return (
<div className='account-timeline__header'>
{account.get('moved') && <MovedNote from={account} to={account.get('moved')} />}
<InnerHeader
account={account}
onFollow={this.handleFollow}

@ -0,0 +1,48 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import AvatarOverlay from '../../../components/avatar_overlay';
import DisplayName from '../../../components/display_name';
export default class MovedNote extends ImmutablePureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
from: ImmutablePropTypes.map.isRequired,
to: ImmutablePropTypes.map.isRequired,
};
handleAccountClick = e => {
if (e.button === 0) {
e.preventDefault();
this.context.router.history.push(`/accounts/${this.props.to.get('id')}`);
}
e.stopPropagation();
}
render () {
const { from, to } = this.props;
const displayNameHtml = { __html: from.get('display_name_html') };
return (
<div className='account__moved-note'>
<div className='account__moved-note__message'>
<div className='account__moved-note__icon-wrapper'><i className='fa fa-fw fa-suitcase account__moved-note__icon' /></div>
<FormattedMessage id='account.moved_to' defaultMessage='{name} has moved to:' values={{ name: <strong dangerouslySetInnerHTML={displayNameHtml} /> }} />
</div>
<a href={to.get('url')} onClick={this.handleAccountClick} className='detailed-status__display-name'>
<div className='detailed-status__display-avatar'><AvatarOverlay account={to} friend={from} /></div>
<DisplayName account={to} />
</a>
</div>
);
}
}

@ -63,6 +63,11 @@ const normalizeAccount = (state, account) => {
account.display_name_html = emojify(escapeTextContentForBrowser(displayName));
account.note_emojified = emojify(account.note);
if (account.moved) {
state = normalizeAccount(state, account.moved);
account.moved = account.moved.id;
}
return state.set(account.id, fromJS(account));
};

@ -4,14 +4,18 @@ import { List as ImmutableList } from 'immutable';
const getAccountBase = (state, id) => state.getIn(['accounts', id], null);
const getAccountCounters = (state, id) => state.getIn(['accounts_counters', id], null);
const getAccountRelationship = (state, id) => state.getIn(['relationships', id], null);
const getAccountMoved = (state, id) => state.getIn(['accounts', state.getIn(['accounts', id, 'moved'])]);
export const makeGetAccount = () => {
return createSelector([getAccountBase, getAccountCounters, getAccountRelationship], (base, counters, relationship) => {
return createSelector([getAccountBase, getAccountCounters, getAccountRelationship, getAccountMoved], (base, counters, relationship, moved) => {
if (base === null) {
return null;
}
return base.merge(counters).set('relationship', relationship);
return base.merge(counters).withMutations(map => {
map.set('relationship', relationship);
map.set('moved', moved);
});
});
};

Loading…
Cancel
Save