hashtag in top of tag feed, scroll to comment, chat blocking, muting, filtering
This commit is contained in:
mgabdev
2020-12-21 18:30:46 -05:00
parent ee91809e8d
commit 67d94858dc
39 changed files with 576 additions and 179 deletions

View File

@@ -123,7 +123,7 @@ export const fetchChatMessengerBlocks = () => (dispatch, getState) => {
dispatch(fetchChatMessengerBlocksRequest())
api(getState).get('/api/v1/chat_conversation_accounts/blocked_chat_accounts').then(response => {
api(getState).get('/api/v1/chat_conversations/blocked_chat_accounts').then(response => {
const next = getLinks(response).refs.find(link => link.rel === 'next')
dispatch(importFetchedAccounts(response.data))
dispatch(fetchChatMessengerBlocksSuccess(response.data, next ? next.uri : null))

View File

@@ -1,4 +1,5 @@
import api, { getLinks } from '../api'
import debounce from 'lodash.debounce'
import { importFetchedAccounts } from './importer'
import { me } from '../initial_state'
@@ -12,7 +13,9 @@ export const CHAT_CONVERSATIONS_APPROVED_EXPAND_REQUEST = 'CHAT_CONVERSATIONS_AP
export const CHAT_CONVERSATIONS_APPROVED_EXPAND_SUCCESS = 'CHAT_CONVERSATIONS_APPROVED_EXPAND_SUCCESS'
export const CHAT_CONVERSATIONS_APPROVED_EXPAND_FAIL = 'CHAT_CONVERSATIONS_APPROVED_EXPAND_FAIL'
export const CHAT_CONVERSATION_APPROVED_UNREAD_COUNT_FETCH_SUCCESS = 'CHAT_CONVERSATIONS_APPROVED_EXPAND_FAIL'
export const CHAT_CONVERSATION_APPROVED_UNREAD_COUNT_FETCH_SUCCESS = 'CHAT_CONVERSATION_APPROVED_UNREAD_COUNT_FETCH_SUCCESS'
export const CHAT_CONVERSATION_APPROVED_SEARCH_FETCH_SUCCESS = 'CHAT_CONVERSATION_APPROVED_SEARCH_FETCH_SUCCESS'
//
@@ -38,6 +41,16 @@ export const CHAT_CONVERSATIONS_REQUESTED_EXPAND_FAIL = 'CHAT_CONVERSATIONS_R
//
export const CHAT_CONVERSATIONS_MUTED_FETCH_REQUEST = 'CHAT_CONVERSATIONS_MUTED_FETCH_REQUEST'
export const CHAT_CONVERSATIONS_MUTED_FETCH_SUCCESS = 'CHAT_CONVERSATIONS_MUTED_FETCH_SUCCESS'
export const CHAT_CONVERSATIONS_MUTED_FETCH_FAIL = 'CHAT_CONVERSATIONS_MUTED_FETCH_FAIL'
export const CHAT_CONVERSATIONS_MUTED_EXPAND_REQUEST = 'CHAT_CONVERSATIONS_MUTED_EXPAND_REQUEST'
export const CHAT_CONVERSATIONS_MUTED_EXPAND_SUCCESS = 'CHAT_CONVERSATIONS_MUTED_EXPAND_SUCCESS'
export const CHAT_CONVERSATIONS_MUTED_EXPAND_FAIL = 'CHAT_CONVERSATIONS_MUTED_EXPAND_FAIL'
//
export const CHAT_CONVERSATION_REQUEST_APPROVE_SUCCESS = 'CHAT_CONVERSATION_REQUEST_APPROVE_SUCCESS'
export const CHAT_CONVERSATION_REQUEST_APPROVE_FAIL = 'CHAT_CONVERSATION_REQUEST_APPROVE_FAIL'
@@ -215,6 +228,83 @@ export const expandChatConversationRequestedFail = (error) => ({
error,
})
/**
* @description Fetch paginated muted chat conversations, import accounts and set chat converations
*/
export const fetchChatConversationMuted = () => (dispatch, getState) => {
if (!me) return
dispatch(fetchChatConversationMutedRequest())
api(getState).get('/api/v1/chat_conversations/muted_conversations').then((response) => {
const next = getLinks(response).refs.find(link => link.rel === 'next')
const conversationsAccounts = [].concat.apply([], response.data.map((c) => c.other_accounts))
// const conversationsChatMessages = response.data.map((c) => c.last_chat_message)
dispatch(importFetchedAccounts(conversationsAccounts))
// dispatch(importFetchedChatMessages(conversationsChatMessages))
dispatch(fetchChatConversationMutedSuccess(response.data, next ? next.uri : null))
}).catch((error) => {
dispatch(fetchChatConversationMutedFail(error))
})
}
export const fetchChatConversationMutedRequest = () => ({
type: CHAT_CONVERSATIONS_MUTED_FETCH_REQUEST,
})
export const fetchChatConversationMutedSuccess = (chatConversations, next) => ({
type: CHAT_CONVERSATIONS_MUTED_FETCH_SUCCESS,
chatConversations,
next,
})
export const fetchChatConversationMutedFail = (error) => ({
type: CHAT_CONVERSATIONS_MUTED_FETCH_FAIL,
showToast: true,
error,
})
/**
* @description Expand paginated muted chat conversations, import accounts and set chat converations
*/
export const expandChatConversationMuted = () => (dispatch, getState) => {
if (!me) return
const url = getState().getIn(['chat_conversations', 'muted', 'next'])
const isLoading = getState().getIn(['chat_conversations', 'muted', 'isLoading'])
if (url === null || isLoading) return
dispatch(expandChatConversationMutedRequest())
api(getState).get(url).then(response => {
const next = getLinks(response).refs.find(link => link.rel === 'next')
const conversationsAccounts = [].concat.apply([], response.data.map((c) => c.other_accounts))
// const conversationsChatMessages = response.data.map((c) => c.last_chat_message)
dispatch(importFetchedAccounts(conversationsAccounts))
// dispatch(importFetchedChatMessages(conversationsChatMessages))
dispatch(expandChatConversationMutedSuccess(response.data, next ? next.uri : null))
}).catch(error => dispatch(expandChatConversationMutedFail(error)))
}
export const expandChatConversationMutedRequest = () => ({
type: CHAT_CONVERSATIONS_MUTED_EXPAND_REQUEST,
})
export const expandChatConversationMutedSuccess = (chatConversations, next) => ({
type: CHAT_CONVERSATIONS_MUTED_EXPAND_SUCCESS,
chatConversations,
next,
})
export const expandChatConversationMutedFail = (error) => ({
type: CHAT_CONVERSATIONS_MUTED_EXPAND_FAIL,
showToast: true,
error,
})
/**
* @description Create a chat conversation with given accountId. May fail because of blocks.
* @param {String} accountId
@@ -227,6 +317,7 @@ export const createChatConversation = (accountId) => (dispatch, getState) => {
api(getState).post('/api/v1/chat_conversation', { account_id: accountId }).then((response) => {
dispatch(createChatConversationSuccess(response.data))
}).catch((error) => {
console.log("error:", error)
dispatch(createChatConversationFail(error))
})
}
@@ -414,3 +505,40 @@ export const setChatConversationExpirationFail = (error) => ({
error,
})
/**
*
*/
export const fetchChatConversationAccountSuggestions = (query) => (dispatch, getState) => {
if (!query) return
debouncedFetchChatConversationAccountSuggestions(query, dispatch, getState)
}
export const debouncedFetchChatConversationAccountSuggestions = debounce((query, dispatch, getState) => {
if (!query) return
api(getState).get('/api/v1/accounts/search', {
params: {
q: query,
resolve: false,
limit: 4,
},
}).then((response) => {
// const next = getLinks(response).refs.find(link => link.rel === 'next')
// const conversationsAccounts = [].concat.apply([], response.data.map((c) => c.other_accounts))
dispatch(importFetchedAccounts(response.data))
// dispatch(importFetchedAccounts(conversationsAccounts))
// dispatch(importFetchedChatMessages(conversationsChatMessages))
// dispatch(fetchChatConversationsSuccess(response.data, next ? next.uri : null))
dispatch(fetchChatConversationAccountSuggestionsSuccess(response.data))
}).catch((error) => {
//
})
}, 650, { leading: true })
const fetchChatConversationAccountSuggestionsSuccess = (chatConversations) => ({
type: CHAT_CONVERSATION_APPROVED_SEARCH_FETCH_SUCCESS,
chatConversations,
})

View File

@@ -5,11 +5,11 @@ import { me } from '../initial_state'
export const CHAT_SETTING_CHANGE = 'CHAT_SETTING_CHANGE'
export const CHAT_SETTING_SAVE = 'CHAT_SETTING_SAVE'
export const changeChatSetting = (path, value) => (dispatch) => {
export const changeChatSetting = (path, checked) => (dispatch) => {
dispatch({
type: CHAT_SETTING_CHANGE,
path,
value,
checked,
})
dispatch(saveChatSettings())

View File

@@ -0,0 +1,29 @@
import api from '../api'
export const HASHTAG_FETCH_REQUEST = 'HASHTAG_FETCH_REQUEST'
export const HASHTAG_FETCH_SUCCESS = 'HASHTAG_FETCH_SUCCESS'
export const HASHTAG_FETCH_FAIL = 'HASHTAG_FETCH_FAIL'
export const fetchHashtag = (tag) => (dispatch, getState) => {
if (!tag) return
dispatch(fetchHashtagRequest())
api(getState).get(`/api/v1/hashtags/${tag.toLowerCase()}`)
.then(({ data }) => dispatch(fetchHashtagSuccess(data)))
.catch(err => dispatch(fetchHashtagFail(err)))
}
export const fetchHashtagRequest = () => ({
type: HASHTAG_FETCH_REQUEST,
})
export const fetchHashtagSuccess = (hashtag) => ({
type: HASHTAG_FETCH_SUCCESS,
hashtag,
})
export const fetchHashtagFail = error => ({
type: HASHTAG_FETCH_FAIL,
error,
})

View File

@@ -84,6 +84,8 @@ export const connectChatMessagesStream = (accountId) => {
onReceive (data) {
if (!data['event'] || !data['payload']) return
if (data.event === 'notification') {
// : todo :
//Play sound
dispatch(manageIncomingChatMessage(JSON.parse(data.payload)))
}
},

View File

@@ -51,6 +51,7 @@ class Account extends ImmutablePureComponent {
showDismiss,
withBio,
isCard,
noClick,
} = this.props
if (!account) return null
@@ -105,6 +106,8 @@ class Account extends ImmutablePureComponent {
noUnderline: 1,
overflowHidden: 1,
flexNormal: 1,
outlineNone: 1,
bgTransparent: 1,
aiStart: !isCard,
aiCenter: isCard,
})
@@ -133,26 +136,28 @@ class Account extends ImmutablePureComponent {
<div className={containerClasses}>
<div className={innerContainerClasses}>
<NavLink
className={[_s.d, _s.noUnderline].join(' ')}
<Button
noClasses
className={[_s.d, _s.noUnderline, _s.outlineNone, _s.bgTransparent].join(' ')}
title={account.get('acct')}
to={`/${account.get('acct')}`}
to={noClick ? undefined : `/${account.get('acct')}`}
>
<Avatar account={account} size={avatarSize} />
</NavLink>
</Button>
<div className={[_s.d, _s.px10, _s.overflowHidden, _s.flexNormal].join(' ')}>
<div className={[_s.d, _s.flexRow, _s.aiCenter].join(' ')}>
<NavLink
<Button
noClasses
title={account.get('acct')}
to={`/${account.get('acct')}`}
to={noClick ? undefined : `/${account.get('acct')}`}
className={buttonClasses}
>
<div className={displayNameWrapperClasses}>
<DisplayName account={account} isMultiline={compact || isCard} />
</div>
{!compact && actionButton}
</NavLink>
</Button>
<div className={[_s.d].join(' ')}>
{dismissBtn}
@@ -232,6 +237,7 @@ Account.propTypes = {
dismissAction: PropTypes.func,
withBio: PropTypes.bool,
isCard: PropTypes.bool,
noClick: PropTypes.bool,
}
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Account))

View File

@@ -88,6 +88,14 @@ class Comment extends ImmutablePureComponent {
this.moreNode = c
}
setContainerNode = (c) => {
this.containerNode = c
if (this.props.isHighlighted && this.containerNode) {
this.containerNode.scrollIntoView({ behavior: 'smooth' });
}
}
render() {
const {
indent,
@@ -101,7 +109,7 @@ class Comment extends ImmutablePureComponent {
if (isHidden) {
return (
<div tabIndex='0'>
<div tabIndex='0' ref={this.setContainerNode}>
{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])}
{status.get('content')}
</div>
@@ -133,7 +141,11 @@ class Comment extends ImmutablePureComponent {
})
return (
<div className={containerClasses} data-comment={status.get('id')}>
<div
className={containerClasses}
data-comment={status.get('id')}
ref={this.setContainerNode}
>
{
indent > 0 &&
<div className={[_s.d, _s.z3, _s.flexRow, _s.posAbs, _s.topNeg20PX, _s.left0, _s.bottom20PX, _s.aiCenter, _s.jcCenter].join(' ')}>

View File

@@ -1,10 +1,12 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Sparklines, SparklinesCurve } from 'react-sparklines'
import { FormattedMessage } from 'react-intl'
import ImmutablePropTypes from 'react-immutable-proptypes'
import ImmutablePureComponent from 'react-immutable-pure-component'
import { NavLink } from 'react-router-dom'
import Button from './button'
import Block from './block'
import Text from './text'
class HashtagItem extends ImmutablePureComponent {
@@ -12,44 +14,42 @@ class HashtagItem extends ImmutablePureComponent {
render() {
const { hashtag, isCompact } = this.props
if (!hashtag) return
const count = hashtag.get('history').map((block) => {
return parseInt(block.get('uses'))
}).reduce((a, c) => a + c)
return (
<NavLink
to={`/tags/${hashtag.get('name')}`}
className={[_s.d, _s.noUnderline, _s.bgSubtle_onHover, _s.px15, _s.py5].join(' ')}
>
<div className={[_s.d, _s.flexRow, _s.aiCenter].join(' ')}>
<div>
<Text color='brand' size='medium' weight='bold' className={[_s.py2, _s.lineHeight15].join(' ')}>
#{hashtag.get('name')}
</Text>
<Block>
<div className={[_s.d, _s.w100PC].join(' ')}>
<div className={[_s.d, _s.noUnderline, _s.px15, _s.py5].join(' ')}>
<div className={[_s.d, _s.flexRow, _s.aiCenter].join(' ')}>
<div>
<Text color='brand' size='medium' weight='bold' className={[_s.py2, _s.lineHeight15].join(' ')}>
#{hashtag.get('name')}
</Text>
</div>
</div>
{
!isCompact &&
<Text color='secondary' size='small' className={_s.py2}>
<FormattedMessage id='number_of_gabs' defaultMessage='{count} Gabs' values={{
count,
}} />
</Text>
}
</div>
{
!isCompact &&
<Button
isText
backgroundColor='none'
color='none'
title='Remove'
icon='close'
iconSize='8px'
iconClassName={_s.cSecondary}
className={_s.mlAuto}
/>
}
<Sparklines
width={50}
height={28}
data={hashtag.get('history').reverse().map((day) => day.get('uses')).toArray()}
>
<SparklinesCurve style={{ fill: 'none' }} />
</Sparklines>
</div>
{
!isCompact &&
<Text color='secondary' size='small' className={_s.py2}>
<FormattedMessage id='number_of_gabs' defaultMessage='{count} Gabs' values={{
count,
}} />
</Text>
}
</NavLink>
</Block>
)
}

View File

@@ -54,6 +54,7 @@ class ChatConversationOptionsPopover extends ImmutablePureComponent {
intl,
isXS,
isMuted,
isChatConversationRequest,
} = this.props
const items = [
@@ -62,21 +63,23 @@ class ChatConversationOptionsPopover extends ImmutablePureComponent {
title: 'Hide Conversation',
subtitle: 'Hide until next message',
onClick: () => this.handleOnHide(),
},
{
}
]
if (!isChatConversationRequest) {
items.push({
hideArrow: true,
title: isMuted ? 'Unmute Conversation' : 'Mute Conversation',
subtitle: isMuted ? null : "Don't get notified of new messages",
onClick: () => this.handleOnMute(),
},
{},
{
})
items.push({})
items.push({
hideArrow: true,
title: 'Purge messages',
subtitle: 'Remove all of your messages in this conversation',
onClick: () => this.handleOnPurge(),
},
]
})
}
return (
<PopoverLayout
@@ -125,6 +128,7 @@ ChatConversationOptionsPopover.propTypes = {
isXS: PropTypes.bool,
isPro: PropTypes.bool.isRequired,
chatConversation: ImmutablePropTypes.map,
isChatConversationRequest: PropTypes.bool,
onClosePopover: PropTypes.func.isRequired,
}

View File

@@ -16,6 +16,10 @@ import {
unbookmark,
isBookmark,
} from '../../actions/interactions';
import {
muteAccount,
unmuteAccount,
} from '../../actions/interactions';
import {
deleteStatus,
editStatus,
@@ -493,7 +497,16 @@ const mapDispatchToProps = (dispatch) => ({
accountId: account.get('id'),
}))
},
onMute(account) {
dispatch(closePopover())
if (account.getIn(['relationship', 'muting'])) {
dispatch(unmuteAccount(account.get('id')));
} else {
dispatch(openModal('MUTE', {
accountId: account.get('id'),
}))
}
},
onReport(status) {
dispatch(closePopover())
dispatch(initReport(status.get('account'), status))

View File

@@ -59,9 +59,9 @@ class ChatConversationBlockedAccounts extends ImmutablePureComponent {
key={`blocked-accounts-${id}`}
id={id}
compact
actionIcon='subtract'
actionIcon=''
onActionClick={() => this.props.onRemove(id)}
actionTitle='Remove'
actionTitle='Undo Chat Block'
/>
))
}

View File

@@ -56,6 +56,7 @@ class ChatConversationCreate extends React.PureComponent {
suggestionsIds.map((accountId) => (
<Account
compact
noClick
key={`chat-conversation-account-create-${accountId}`}
id={accountId}
onActionClick={() => this.handleOnCreateChatConversation(accountId)}

View File

@@ -11,7 +11,7 @@ class ChatConversationMutes extends React.PureComponent {
<div className={[_s.d, _s.h60PX, _s.w100PC, _s.px10, _s.py10, _s.borderBottom1PX, _s.borderColorSecondary].join(' ')}>
<BlockHeading title={'Muted Chat Conversations'} />
</div>
<ChatConversationsList source='mutes' />
<ChatConversationsList source='muted' />
</div>
)
}

View File

@@ -4,7 +4,9 @@ import { connect } from 'react-redux'
import { FormattedMessage } from 'react-intl'
import isEqual from 'lodash.isequal'
import { expandHashtagTimeline, clearTimeline } from '../actions/timelines'
import { fetchHashtag } from '../actions/hashtags'
import StatusList from '../components/status_list'
import HashtagItem from '../components/hashtag_item'
class HashtagTimeline extends React.PureComponent {
@@ -64,10 +66,11 @@ class HashtagTimeline extends React.PureComponent {
}
componentDidMount () {
const { dispatch } = this.props
const { dispatch, tagName } = this.props
const { id, tags } = this.props.params
dispatch(expandHashtagTimeline(id, { tags }))
dispatch(fetchHashtag(tagName))
}
componentWillReceiveProps (nextProps) {
@@ -86,21 +89,28 @@ class HashtagTimeline extends React.PureComponent {
}
render () {
const { id } = this.props.params
const { tag, tagName } = this.props
console.log("tagName:", tag)
return (
<StatusList
scrollKey='hashtag_timeline'
timelineId={`hashtag:${id}`}
onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.hashtag' defaultMessage='There is nothing in this hashtag yet.' />}
/>
);
<React.Fragment>
{ tag && <HashtagItem hashtag={tag} /> }
<StatusList
scrollKey='hashtag_timeline'
timelineId={`hashtag:${tagName}`}
onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.hashtag' defaultMessage='There is nothing in this hashtag yet.' />}
/>
</React.Fragment>
)
}
}
const mapStateToProps = (state, props) => ({
tagName: props.params.id,
tag: state.getIn(['hashtags', `${props.params.id}`]),
hasUnread: state.getIn(['timelines', `hashtag:${props.params.id}`, 'unread']) > 0,
})

View File

@@ -9,6 +9,8 @@ import {
expandChatConversations,
fetchChatConversationRequested,
expandChatConversationRequested,
fetchChatConversationMuted,
expandChatConversationMuted,
} from '../../../actions/chat_conversations'
import AccountPlaceholder from '../../../components/placeholder/account_placeholder'
import ChatConversationsListItem from './chat_conversations_list_item'
@@ -72,6 +74,8 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(fetchChatConversations())
} else if (source ==='requested') {
dispatch(fetchChatConversationRequested())
} else if (source ==='muted') {
dispatch(fetchChatConversationMuted())
}
},
onExpandChatConversations(source) {
@@ -79,6 +83,8 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(expandChatConversations())
} else if (source ==='requested') {
dispatch(expandChatConversationRequested())
} else if (source ==='muted') {
dispatch(expandChatConversationMuted())
}
},
})

View File

@@ -1,29 +1,31 @@
import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import Input from '../../../components/input'
class ChatConversationsSearch extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
state = {
value: '',
}
state = {
composeFocused: false,
handleOnChange = (value) => {
this.setState({ value })
this.props.onChange(value)
}
render() {
const {
children
} = this.props
const { value } = this.state
return (
<div className={[_s.d, _s.h60PX, _s.w100PC, _s.px10, _s.py10, _s.borderBottom1PX, _s.borderColorSecondary].join(' ')}>
<Input
type='search'
placeholder='Search for messages'
placeholder='Search for conversations'
id='messages-search'
prependIcon='search'
value={value}
onChange={this.handleOnChange}
/>
</div>
)
@@ -31,8 +33,10 @@ class ChatConversationsSearch extends React.PureComponent {
}
ChatConversationsSearch.propTypes = {
//
}
const mapDispatchToProps = (dispatch) => ({
onChange(value) {
// dispatch()
}
})
export default ChatConversationsSearch
export default connect(null, mapDispatchToProps)(ChatConversationsSearch)

View File

@@ -21,7 +21,12 @@ class ChatMessageHeader extends React.PureComponent {
}
handleOnOpenChatConversationOptionsPopover = () => {
this.props.onOpenChatConversationOptionsPopover(this.props.chatConversationId, this.optionsBtnRef)
const isChatConversationRequest = !!this.props.chatConversation ? !this.props.chatConversation.get('is_approved') : false
this.props.onOpenChatConversationOptionsPopover({
isChatConversationRequest,
chatConversationId: this.props.chatConversationId,
targetRef: this.optionsBtnRef,
})
}
setOptionsBtnRef = (c) => {
@@ -63,7 +68,7 @@ class ChatMessageHeader extends React.PureComponent {
onClick={this.handleOnApproveMessageRequest}
className={_s.ml10}
>
<Text>
<Text color='inherit'>
Approve Message Request
</Text>
</Button>
@@ -82,10 +87,9 @@ const mapDispatchToProps = (dispatch) => ({
onApproveChatConversationRequest(chatConversationId) {
dispatch(approveChatConversationRequest(chatConversationId))
},
onOpenChatConversationOptionsPopover(chatConversationId, targetRef) {
onOpenChatConversationOptionsPopover(options) {
dispatch(openPopover(POPOVER_CHAT_CONVERSATION_OPTIONS, {
chatConversationId,
targetRef,
...options,
position: 'left-end',
}))
},

View File

@@ -22,6 +22,7 @@ import ChatMessagePlaceholder from '../../../components/placeholder/chat_message
import ChatMessageItem from './chat_message_item'
import ColumnIndicator from '../../../components/column_indicator'
import LoadMore from '../../../components/load_more'
import Text from '../../../components/text'
class ChatMessageScrollingList extends ImmutablePureComponent {
@@ -238,6 +239,7 @@ class ChatMessageScrollingList extends ImmutablePureComponent {
isLoading,
isPartial,
hasMore,
amITalkingToMyself,
onScrollToBottom,
onScroll,
isXS,
@@ -299,6 +301,15 @@ class ChatMessageScrollingList extends ImmutablePureComponent {
className={[_s.d, _s.h100PC, _s.w100PC, _s.px15, _s.py15, _s.overflowYScroll].join(' ')}
ref={this.setScrollContainerRef}
>
{
amITalkingToMyself &&
<div className={[_s.d, _s.bgTertiary, _s.radiusSmall, _s.mt5, _s.ml10, _s.mr15, _s.px15, _s.py15, _s.mb15].join(' ')}>
<Text size='medium' color='secondary'>
This is a chat conversation with yourself. Use this space to keep messages, links and texts. Please remember that these messages are not encrypted.
</Text>
</div>
}
{
(hasMore && !isLoading) &&
<LoadMore onClick={this.handleLoadOlder} />
@@ -349,7 +360,11 @@ class ChatMessageScrollingList extends ImmutablePureComponent {
const mapStateToProps = (state, { chatConversationId }) => {
if (!chatConversationId) return {}
const otherAccountIds = state.getIn(['chat_conversations', chatConversationId, 'other_account_ids'], null)
const amITalkingToMyself = !!otherAccountIds ? otherAccountIds.size == 1 && otherAccountIds.get(0) === me : false
return {
amITalkingToMyself,
chatMessageIds: state.getIn(['chat_conversation_messages', chatConversationId, 'items'], ImmutableList()),
isLoading: state.getIn(['chat_conversation_messages', chatConversationId, 'isLoading'], true),
isPartial: state.getIn(['chat_conversation_messages', chatConversationId, 'isPartial'], false),

View File

@@ -1,36 +1,25 @@
import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { injectIntl, FormattedMessage } from 'react-intl'
import ImmutablePureComponent from 'react-immutable-pure-component'
import ImmutablePropTypes from 'react-immutable-proptypes'
import debounce from 'lodash.debounce'
import { me } from '../initial_state'
import { fetchMutes, expandMutes } from '../actions/mutes'
import Account from '../components/account'
import { changeChatSetting } from '../actions/chat_settings'
import BlockHeading from '../components/block_heading'
import Button from '../components/button'
import Form from '../components/form'
import Switch from '../components/switch'
import Text from '../components/text'
import SettingSwitch from '../components/setting_switch'
import Divider from '../components/divider'
class MessagesSettings extends ImmutablePureComponent {
componentWillMount() {
this.props.onFetchMutes()
handleOnChange = (key, checked) => {
this.props.onSave(key, checked)
}
handleLoadMore = debounce(() => {
this.props.onExpandMutes()
}, 300, { leading: true })
render() {
const {
accountIds,
hasMore,
isLoading,
} = this.props
const { chatSettings } = this.props
if (!chatSettings) return null
return (
<div className={[_s.d, _s.w100PC, _s.boxShadowNone].join(' ')}>
@@ -40,23 +29,34 @@ class MessagesSettings extends ImmutablePureComponent {
<div className={[_s.d, _s.px15, _s.py15, _s.overflowHidden].join(' ')}>
<Form>
<Switch
<SettingSwitch
label='Restrict messages from people you dont follow'
checked={true}
onChange={this.handleLockedChange}
settings={chatSettings}
settingPath='restrict_non_followers'
onChange={this.handleOnChange}
/>
{ /* : todo :
<div className={[_s.d, _s.w100PC, _s.my10, _s.borderColorSecondary, _s.borderBottom1PX].join(' ')} />
<Switch
<SettingSwitch
label='Show when you are active'
checked={false}
onChange={this.handleLockedChange}
settings={chatSettings}
settingPath='show_active'
onChange={this.handleOnChange}
/>
<div className={[_s.d, _s.w100PC, _s.my10, _s.borderColorSecondary, _s.borderBottom1PX].join(' ')} />
<Switch
label='Notification sound enabled'
checked={false}
onChange={this.handleLockedChange}
<SettingSwitch
label='Show read receipts'
settings={chatSettings}
settingPath='read_receipts'
onChange={this.handleOnChange}
/>
<div className={[_s.d, _s.w100PC, _s.my10, _s.borderColorSecondary, _s.borderBottom1PX].join(' ')} />
<SettingSwitch
label='Notification sound enabled'
settings={chatSettings}
settingPath='sounds'
onChange={this.handleOnChange}
/> */ }
</Form>
</div>
</div>
@@ -66,22 +66,18 @@ class MessagesSettings extends ImmutablePureComponent {
}
const mapStateToProps = (state) => ({
accountIds: state.getIn(['user_lists', 'mutes', me, 'items']),
hasMore: !!state.getIn(['user_lists', 'mutes', me, 'next']),
isLoading: state.getIn(['user_lists', 'mutes', me, 'isLoading']),
chatSettings: state.getIn(['chat_settings']),
})
const mapDispatchToProps = (dispatch) => ({
onFetchMutes: () => dispatch(fetchMutes()),
onExpandMutes: () => dispatch(expandMutes()),
onSave(key, checked) {
// dispatch(changeChatSetting(key, checked))
},
})
MessagesSettings.propTypes = {
accountIds: ImmutablePropTypes.list,
hasMore: PropTypes.bool,
isLoading: PropTypes.bool,
onExpandMutes: PropTypes.func.isRequired,
onFetchMutes: PropTypes.func.isRequired,
chatSettings: ImmutablePropTypes.map,
onSave: PropTypes.func.isRequired,
}
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(MessagesSettings))
export default connect(mapStateToProps, mapDispatchToProps)(MessagesSettings)

View File

@@ -76,7 +76,7 @@ class MessagesLayout extends React.PureComponent {
actions={[
{
icon: 'add',
to: `'/messages/new'`,
to: '/messages/new',
},
{
icon: 'cog',

View File

@@ -79,10 +79,6 @@ class SearchLayout extends React.PureComponent {
title: intl.formatMessage(messages.links),
to: '/search/links',
},
{
title: intl.formatMessage(messages.hashtags),
to: '/search/hashtags',
},
]
}

View File

@@ -15,6 +15,13 @@ import {
CHAT_CONVERSATIONS_REQUESTED_EXPAND_FAIL,
CHAT_CONVERSATION_REQUEST_APPROVE_SUCCESS,
CHAT_CONVERSATIONS_MUTED_FETCH_REQUEST,
CHAT_CONVERSATIONS_MUTED_FETCH_SUCCESS,
CHAT_CONVERSATIONS_MUTED_FETCH_FAIL,
CHAT_CONVERSATIONS_MUTED_EXPAND_REQUEST,
CHAT_CONVERSATIONS_MUTED_EXPAND_SUCCESS,
CHAT_CONVERSATIONS_MUTED_EXPAND_FAIL,
} from '../actions/chat_conversations'
const initialState = ImmutableMap({
@@ -28,6 +35,11 @@ const initialState = ImmutableMap({
isLoading: false,
items: ImmutableList(),
}),
muted: ImmutableMap({
next: null,
isLoading: false,
items: ImmutableList(),
}),
})
const normalizeList = (state, source, chatConversations, next) => {
@@ -79,6 +91,18 @@ export default function chat_conversation_lists(state = initialState, action) {
case CHAT_CONVERSATION_REQUEST_APPROVE_SUCCESS:
return removeOneFromList(state, 'requested', action.chatConversation.chat_conversation_id)
case CHAT_CONVERSATIONS_MUTED_FETCH_REQUEST:
case CHAT_CONVERSATIONS_MUTED_EXPAND_REQUEST:
return state.setIn(['muted', 'isLoading'], true)
case CHAT_CONVERSATIONS_MUTED_FETCH_FAIL:
case CHAT_CONVERSATIONS_MUTED_EXPAND_FAIL:
return state.setIn(['muted', 'isLoading'], false)
case CHAT_CONVERSATIONS_MUTED_FETCH_SUCCESS:
return normalizeList(state, 'muted', action.chatConversations, action.next)
case CHAT_CONVERSATIONS_MUTED_EXPAND_SUCCESS:
return appendToList(state, 'muted', action.chatConversations, action.next)
default:
return state
}

View File

@@ -17,9 +17,7 @@ const initialState = ImmutableMap({
export default function chat_settings(state = initialState, action) {
switch(action.type) {
case CHAT_SETTING_CHANGE:
return state
.setIn(action.path, action.value)
.set('saved', false)
return state.set(action.path, action.checked).set('saved', false)
default:
return state
}

View File

@@ -0,0 +1,20 @@
import {
HASHTAG_FETCH_REQUEST,
HASHTAG_FETCH_SUCCESS,
HASHTAG_FETCH_FAIL,
} from '../actions/hashtags'
import { Map as ImmutableMap, fromJS } from 'immutable'
const importHashtag = (state, hashtag) => state.set(`${hashtag.name}`.toLowerCase(), fromJS(hashtag))
const initialState = ImmutableMap()
export default function hashtags(state = initialState, action) {
switch (action.type) {
case HASHTAG_FETCH_SUCCESS:
console.log("HASHTAG_FETCH_SUCCESS:", action)
return importHashtag(state, action.hashtag)
default:
return state
}
}

View File

@@ -21,6 +21,7 @@ import group_categories from './group_categories'
import group_editor from './group_editor'
import group_lists from './group_lists'
import group_relationships from './group_relationships'
import hashtags from './hashtags'
import height_cache from './height_cache'
import links from './links.js'
import lists from './lists'
@@ -75,6 +76,7 @@ const reducers = {
group_editor,
group_lists,
group_relationships,
hashtags,
height_cache,
links,
lists,