import { MediaGallery, Video } from 'themes/glitch/util/async-components';
import { HotKeys } from 'react-hotkeys';
import NotificationOverlayContainer from 'themes/glitch/features/notifications/containers/overlay_container';
+import classNames from 'classnames';
// We use the component (and not the container) since we do not want
// to use the progress bar to show download progress
};
static propTypes = {
+ containerId: PropTypes.string,
id: PropTypes.string,
status: ImmutablePropTypes.map,
account: ImmutablePropTypes.map,
}
handleExpandedToggle = () => {
- this.setExpansion(this.state.isExpanded || !this.props.status.get('spoiler') ? null : true);
+ if (this.props.status.get('spoiler_text')) {
+ this.setExpansion(this.state.isExpanded ? null : true);
+ }
};
handleOpenVideo = startTime => {
}
handleHotkeyMoveUp = () => {
- this.props.onMoveUp(this.props.status.get('id'));
+ this.props.onMoveUp(this.props.containerId || this.props.id);
}
handleHotkeyMoveDown = () => {
- this.props.onMoveDown(this.props.status.get('id'));
+ this.props.onMoveDown(this.props.containerId || this.props.id);
}
handleRef = c => {
openProfile: this.handleHotkeyOpenProfile,
moveUp: this.handleHotkeyMoveUp,
moveDown: this.handleHotkeyMoveDown,
+ toggleSpoiler: this.handleExpandedToggle,
};
+ const computedClass = classNames('status', `status-${status.get('visibility')}`, {
+ collapsed: isExpanded === false,
+ 'has-background': isExpanded === false && background,
+ 'marked-for-delete': this.state.markedForDelete,
+ muted,
+ }, 'focusable');
+
return (
<HotKeys handlers={handlers}>
<div
- className={
- `status${
- muted ? ' muted' : ''
- } status-${status.get('visibility')}${
- isExpanded === false ? ' collapsed' : ''
- }${
- isExpanded === false && background ? ' has-background' : ''
- }${
- this.state.markedForDelete ? ' marked-for-delete' : ''
- }`
- }
- style={{
- backgroundImage: (
- isExpanded === false && background ?
- `url(${background})` :
- 'none'
- ),
- }}
+ className={computedClass}
+ style={isExpanded === false && background ? { backgroundImage: `url(${background})` } : null}
{...selectorAttribs}
ref={handleRef}
+ tabIndex='0'
>
{prepend && account ? (
<StatusPrepend
}
return {
+ containerId : props.containerId || props.id, // Should match reblogStatus's id for reblogs
status : status,
account : account || props.account,
settings : state.get('local_settings'),
export default class NotificationFollow extends ImmutablePureComponent {
static propTypes = {
+ hidden: PropTypes.bool,
id: PropTypes.string.isRequired,
account: ImmutablePropTypes.map.isRequired,
notification: ImmutablePropTypes.map.isRequired,
}
render () {
- const { account, notification } = this.props;
+ const { account, notification, hidden } = this.props;
// Links to the display name.
const displayName = account.get('display_name_html') || account.get('username');
/>
</div>
- <AccountContainer id={account.get('id')} withNote={false} />
+ <AccountContainer hidden={hidden} id={account.get('id')} withNote={false} />
<NotificationOverlayContainer notification={notification} />
</div>
</HotKeys>
onMoveUp: PropTypes.func.isRequired,
onMoveDown: PropTypes.func.isRequired,
onMention: PropTypes.func.isRequired,
- settings: ImmutablePropTypes.map.isRequired,
};
- renderFollow () {
- const { notification } = this.props;
- return (
- <NotificationFollow
- id={notification.get('id')}
- account={notification.get('account')}
- notification={notification}
- />
- );
- }
-
- renderMention () {
- const { notification } = this.props;
- return (
- <StatusContainer
- id={notification.get('status')}
- notification={notification}
- withDismiss
- />
- );
- }
-
- renderFavourite () {
- const { notification } = this.props;
- return (
- <StatusContainer
- id={notification.get('status')}
- account={notification.get('account')}
- prepend='favourite'
- muted
- notification={notification}
- withDismiss
- />
- );
- }
-
- renderReblog () {
- const { notification } = this.props;
- return (
- <StatusContainer
- id={notification.get('status')}
- account={notification.get('account')}
- prepend='reblog'
- muted
- notification={notification}
- withDismiss
- />
- );
- }
-
render () {
- const { notification } = this.props;
+ const {
+ hidden,
+ notification,
+ onMoveDown,
+ onMoveUp,
+ onMention,
+ } = this.props;
+
switch(notification.get('type')) {
case 'follow':
- return this.renderFollow();
+ return (
+ <NotificationFollow
+ hidden={hidden}
+ id={notification.get('id')}
+ account={notification.get('account')}
+ notification={notification}
+ onMoveDown={onMoveDown}
+ onMoveUp={onMoveUp}
+ onMention={onMention}
+ />
+ );
case 'mention':
- return this.renderMention();
+ return (
+ <StatusContainer
+ containerId={notification.get('id')}
+ hidden={hidden}
+ id={notification.get('status')}
+ notification={notification}
+ onMoveDown={onMoveDown}
+ onMoveUp={onMoveUp}
+ onMention={onMention}
+ withDismiss
+ />
+ );
case 'favourite':
- return this.renderFavourite();
+ return (
+ <StatusContainer
+ containerId={notification.get('id')}
+ hidden={hidden}
+ id={notification.get('status')}
+ account={notification.get('account')}
+ prepend='favourite'
+ muted
+ notification={notification}
+ onMoveDown={onMoveDown}
+ onMoveUp={onMoveUp}
+ onMention={onMention}
+ withDismiss
+ />
+ );
case 'reblog':
- return this.renderReblog();
+ return (
+ <StatusContainer
+ containerId={notification.get('id')}
+ hidden={hidden}
+ id={notification.get('status')}
+ account={notification.get('account')}
+ prepend='reblog'
+ muted
+ notification={notification}
+ onMoveDown={onMoveDown}
+ onMoveUp={onMoveUp}
+ onMention={onMention}
+ withDismiss
+ />
+ );
default:
return null;
}
const mapStateToProps = (state, props) => ({
notification: getNotification(state, props.notification, props.accountId),
- settings: state.get('local_settings'),
notifCleaning: state.getIn(['notifications', 'cleaningMode']),
});
goToProfile: 'g u',
goToBlocked: 'g b',
goToMuted: 'g m',
+ toggleSpoiler: 'x',
};
@connect(mapStateToProps)