Progress
hashtag in top of tag feed, scroll to comment, chat blocking, muting, filtering
This commit is contained in:
parent
ee91809e8d
commit
67d94858dc
|
@ -1,11 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::ChatConversationAccounts::BlockedChatAccountsController < Api::BaseController
|
||||
class Api::V1::ChatConversations::BlockedChatAccountsController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :follow, :'read:blocks' }
|
||||
before_action :require_user!
|
||||
after_action :insert_pagination_headers
|
||||
|
||||
def show
|
||||
def index
|
||||
@accounts = load_accounts
|
||||
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||
end
|
||||
|
@ -32,13 +32,13 @@ class Api::V1::ChatConversationAccounts::BlockedChatAccountsController < Api::Ba
|
|||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_chat_conversation_accounts_chat_blocked_accounts_url pagination_params(max_id: pagination_max_id)
|
||||
api_v1_chat_conversations_blocked_chat_accounts_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless paginated_blocks.empty?
|
||||
api_v1_chat_conversation_accounts_blocked_chat_accounts_url pagination_params(since_id: pagination_since_id)
|
||||
api_v1_chat_conversations_blocked_chat_accounts_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
end
|
||||
|
|
@ -47,7 +47,7 @@ class Api::V1::ChatConversations::MessagesController < Api::BaseController
|
|||
).paginate_by_id(
|
||||
limit_param(DEFAULT_CHAT_CONVERSATION_MESSAGE_LIMIT),
|
||||
params_slice(:max_id, :since_id, :min_id)
|
||||
)
|
||||
).reject { |chat_message| FeedManager.instance.filter?(:chat_message, chat_message, current_account.id) }
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::ChatConversations::MutedConversationsController < Api::BaseController
|
||||
before_action -> { authorize_if_got_token! :read, :'read:chats' }
|
||||
|
||||
before_action :require_user!
|
||||
after_action :insert_pagination_headers
|
||||
|
||||
def index
|
||||
@chat_conversations = load_chat_conversations
|
||||
render json: @chat_conversations, each_serializer: REST::ChatConversationAccountSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_chat_conversations
|
||||
paginated_chat_conversations
|
||||
end
|
||||
|
||||
def paginated_chat_conversations
|
||||
ChatConversationAccount.where(
|
||||
account: current_account,
|
||||
is_muted: true,
|
||||
).paginate_by_max_id(
|
||||
limit_param(DEFAULT_CHAT_CONVERSATION_LIMIT),
|
||||
params[:max_id],
|
||||
params[:since_id]
|
||||
)
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_chat_conversations_muted_conversations_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless paginated_chat_conversations.empty?
|
||||
api_v1_chat_conversations_muted_conversations_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
paginated_chat_conversations.last.id
|
||||
end
|
||||
|
||||
def pagination_since_id
|
||||
paginated_chat_conversations.first.id
|
||||
end
|
||||
|
||||
def records_continue?
|
||||
paginated_chat_conversations.size == limit_param(DEFAULT_CHAT_CONVERSATION_LIMIT)
|
||||
end
|
||||
|
||||
def pagination_params(core_params)
|
||||
params.slice(:limit).permit(:limit).merge(core_params)
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::HashtagsController < Api::BaseController
|
||||
before_action :require_user!
|
||||
before_action :set_hashtag
|
||||
|
||||
def show
|
||||
render json: @hashtag, serializer: REST::TagSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_hashtag
|
||||
@hashtag = Tag.where(name: params[:id]).first
|
||||
end
|
||||
|
||||
end
|
|
@ -4,8 +4,8 @@ class Api::Web::ChatSettingsController < Api::Web::BaseController
|
|||
before_action :require_user!
|
||||
|
||||
def update
|
||||
setting.data = params[:data]
|
||||
setting.save!
|
||||
# setting.data = params[:data]
|
||||
# setting.save!
|
||||
|
||||
# todo validate all data objects
|
||||
|
||||
|
@ -15,6 +15,6 @@ class Api::Web::ChatSettingsController < Api::Web::BaseController
|
|||
private
|
||||
|
||||
def setting
|
||||
@_setting ||= ::Web::Setting.where(user: current_user).first_or_initialize(user: current_user)
|
||||
# @_setting ||= ::Web::Setting.where(user: current_user).first_or_initialize(user: current_user)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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,
|
||||
})
|
|
@ -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())
|
||||
|
|
|
@ -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,
|
||||
})
|
|
@ -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)))
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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))
|
|
@ -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(' ')}>
|
||||
|
|
|
@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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'
|
||||
/>
|
||||
))
|
||||
}
|
||||
|
|
|
@ -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)}
|
||||
|
|
|
@ -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>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
},
|
||||
})
|
||||
|
|
|
@ -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)
|
|
@ -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',
|
||||
}))
|
||||
},
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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)
|
|
@ -76,7 +76,7 @@ class MessagesLayout extends React.PureComponent {
|
|||
actions={[
|
||||
{
|
||||
icon: 'add',
|
||||
to: `'/messages/new'`,
|
||||
to: '/messages/new',
|
||||
},
|
||||
{
|
||||
icon: 'cog',
|
||||
|
|
|
@ -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',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
|
|
|
@ -17,9 +17,12 @@ class FeedManager
|
|||
"feed:#{type}:#{id}:#{subtype}"
|
||||
end
|
||||
|
||||
# status or chatMessage
|
||||
def filter?(timeline_type, status, receiver_id)
|
||||
if timeline_type == :home
|
||||
filter_from_home?(status, receiver_id)
|
||||
elsif timeline_type == :chat_message
|
||||
filter_from_chat_messages?(status, receiver_id)
|
||||
elsif timeline_type == :mentions
|
||||
filter_from_mentions?(status, receiver_id)
|
||||
else
|
||||
|
@ -140,6 +143,10 @@ class FeedManager
|
|||
(context == :home ? Mute.where(account_id: receiver_id, target_account_id: account_ids).any? : Mute.where(account_id: receiver_id, target_account_id: account_ids, hide_notifications: true).any?)
|
||||
end
|
||||
|
||||
def chat_blocks?(receiver_id, account_ids)
|
||||
ChatBlock.where(account_id: receiver_id, target_account_id: account_ids).any?
|
||||
end
|
||||
|
||||
def filter_from_home?(status, receiver_id)
|
||||
return false if receiver_id == status.account_id
|
||||
return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
|
||||
|
@ -170,6 +177,18 @@ class FeedManager
|
|||
false
|
||||
end
|
||||
|
||||
def filter_from_chat_messages?(chat_message, receiver_id)
|
||||
return false if receiver_id == chat_message.from_account_id
|
||||
return true if phrase_filtered_from_chat_message?(chat_message, receiver_id, :thread)
|
||||
|
||||
check_for_blocks = [chat_message.from_account_id]
|
||||
|
||||
return true if blocks_or_mutes?(receiver_id, check_for_blocks, :home)
|
||||
return true if chat_blocks?(receiver_id, check_for_blocks)
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def filter_from_mentions?(status, receiver_id)
|
||||
return true if receiver_id == status.account_id
|
||||
return true if phrase_filtered?(status, receiver_id, :notifications)
|
||||
|
@ -211,6 +230,29 @@ class FeedManager
|
|||
(status.spoiler_text.present? && !combined_regex.match(status.spoiler_text).nil?)
|
||||
end
|
||||
|
||||
def phrase_filtered_from_chat_message?(chat_message, receiver_id, context)
|
||||
active_filters = Rails.cache.fetch("filters:#{receiver_id}") { CustomFilter.where(account_id: receiver_id).active_irreversible.to_a }.to_a
|
||||
|
||||
active_filters.select! { |filter| filter.context.include?(context.to_s) && !filter.expired? }
|
||||
|
||||
active_filters.map! do |filter|
|
||||
if filter.whole_word
|
||||
sb = filter.phrase =~ /\A[[:word:]]/ ? '\b' : ''
|
||||
eb = filter.phrase =~ /[[:word:]]\z/ ? '\b' : ''
|
||||
|
||||
/(?mix:#{sb}#{Regexp.escape(filter.phrase)}#{eb})/
|
||||
else
|
||||
/#{Regexp.escape(filter.phrase)}/i
|
||||
end
|
||||
end
|
||||
|
||||
return false if active_filters.empty?
|
||||
|
||||
combined_regex = active_filters.reduce { |memo, obj| Regexp.union(memo, obj) }
|
||||
|
||||
!combined_regex.match(chat_message.text).nil?
|
||||
end
|
||||
|
||||
# Adds a status to an account's feed, returning true if a status was
|
||||
# added, and false if it was not added to the feed. Note that this is
|
||||
# an internal helper: callers must call trim or push updates if
|
||||
|
|
|
@ -39,6 +39,7 @@ class SortingQueryBuilder < BaseService
|
|||
query = query.where('statuses.id > ? AND statuses.id <> ?', max_id, max_id) unless max_id.nil? || max_id.empty?
|
||||
query = query.limit(20)
|
||||
|
||||
# : todo : reject blocks, etc. in feedmanager
|
||||
# SELECT "statuses".*
|
||||
# FROM "statuses"
|
||||
# INNER JOIN "status_stats" ON "status_stats"."status_id" = "statuses"."id"
|
||||
|
|
|
@ -37,8 +37,6 @@ class ChatConversationAccount < ApplicationRecord
|
|||
belongs_to :chat_conversation
|
||||
belongs_to :last_chat_message, class_name: 'ChatMessage', optional: true
|
||||
|
||||
validate :validate_total_limit
|
||||
|
||||
def participant_accounts
|
||||
if participant_account_ids.empty?
|
||||
[account]
|
||||
|
@ -50,8 +48,4 @@ class ChatConversationAccount < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
def validate_total_limit
|
||||
# errors.add(:base, I18n.t('scheduled_statuses.over_total_limit', limit: PER_ACCOUNT_APPROVED_LIMIT)) if account.scheduled_statuses.count >= PER_ACCOUNT_APPROVED_LIMIT
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -84,8 +84,8 @@ class MediaAttachment < ApplicationRecord
|
|||
},
|
||||
}.freeze
|
||||
|
||||
IMAGE_LIMIT = Proc.new { |account| account.is_pro ? 50.megabytes : 8.megabytes }
|
||||
VIDEO_LIMIT = Proc.new { |account| account.is_pro ? 1.gigabytes : 40.megabytes}
|
||||
IMAGE_LIMIT = Proc.new { |account| account.is_pro ? 100.megabytes : 20.megabytes }
|
||||
VIDEO_LIMIT = Proc.new { |account| account.is_pro ? 2.gigabytes : 250.megabytes}
|
||||
|
||||
belongs_to :account, inverse_of: :media_attachments, optional: true
|
||||
belongs_to :status, inverse_of: :media_attachments, optional: true
|
||||
|
|
|
@ -15,26 +15,36 @@ class CreateChatConversationService < BaseService
|
|||
|
||||
# : todo :
|
||||
# check if allow anyone to message then create with approved:true
|
||||
# unique account id, participants
|
||||
|
||||
chat_conversation = ChatConversation.create
|
||||
@chat_conversation = ChatConversation.create
|
||||
|
||||
my_chat = ChatConversationAccount.create!(
|
||||
account: current_account,
|
||||
participant_account_ids: [@account.id.to_s],
|
||||
chat_conversation: chat_conversation,
|
||||
account: @current_account,
|
||||
participant_account_ids: account_ids_as_array,
|
||||
chat_conversation: @chat_conversation,
|
||||
is_approved: true
|
||||
)
|
||||
|
||||
# : todo : if multiple ids
|
||||
if @account.id != current_account.id
|
||||
their_chat = ChatConversationAccount.create!(
|
||||
account: @account,
|
||||
participant_account_ids: [current_account.id.to_s],
|
||||
chat_conversation: chat_conversation,
|
||||
is_approved: false # : todo : check if allow all else default as request
|
||||
)
|
||||
if @other_accounts.length == 1 && @other_accounts[0].id == @current_account.id
|
||||
# dont create two conversations if you are chatting with yourself
|
||||
else
|
||||
for other_account in @other_accounts
|
||||
this_conversation_participants = @other_accounts.map { |account|
|
||||
account.id.to_s
|
||||
}.reject { |id| id == other_account.id.to_s } << @current_account.id.to_s
|
||||
|
||||
# is_approved = other_account&.user&.setting_chat_messages_restrict_non_followers == true
|
||||
|
||||
ChatConversationAccount.create!(
|
||||
account: other_account,
|
||||
participant_account_ids: this_conversation_participants,
|
||||
chat_conversation: @chat_conversation,
|
||||
is_approved: false
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
my_chat
|
||||
end
|
||||
|
||||
def account_ids_as_array
|
||||
|
|
|
@ -54,13 +54,16 @@ class PostChatMessageService < BaseService
|
|||
|
||||
# Get not mine
|
||||
if @account_conversation.id != recipient.id
|
||||
recipient.unread_count = recipient.unread_count + 1
|
||||
recipient.is_hidden = false
|
||||
# check if recipient is blocking me
|
||||
unless recipient.account.chat_blocking?(@account)
|
||||
recipient.unread_count = recipient.unread_count + 1
|
||||
recipient.is_hidden = false
|
||||
|
||||
# check if muting
|
||||
unless recipient.is_muted
|
||||
payload = InlineRenderer.render(@chat, recipient.account, :chat_message)
|
||||
Redis.current.publish("chat_messages:#{recipient.account.id}", Oj.dump(event: :notification, payload: payload))
|
||||
# check if muting
|
||||
unless recipient.is_muted
|
||||
payload = InlineRenderer.render(@chat, recipient.account, :chat_message)
|
||||
Redis.current.publish("chat_messages:#{recipient.account.id}", Oj.dump(event: :notification, payload: payload))
|
||||
end
|
||||
end
|
||||
else
|
||||
recipient.unread_count = 0
|
||||
|
@ -73,20 +76,6 @@ class PostChatMessageService < BaseService
|
|||
def set_chat_conversation_recipients!
|
||||
@account_conversation = ChatConversationAccount.where(account: @account, chat_conversation: @chat_conversation).first
|
||||
@chat_conversation_recipients_accounts = ChatConversationAccount.where(chat_conversation: @chat_conversation)
|
||||
|
||||
# if 1-to-1 chat, check for blocking and dont allow message to send if blocking
|
||||
# if 1-to-many let chat go through but keep is_hidden
|
||||
@chat_conversation_recipients_accounts.each do |recipient|
|
||||
# : todo :
|
||||
# check if chat blocked
|
||||
# check if normal blocked
|
||||
|
||||
if recipient.account.blocking?(@account) || recipient.account.chat_blocking?(@account)
|
||||
raise GabSocial::NotPermittedError
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
rescue ArgumentError
|
||||
raise ActiveRecord::RecordInvalid
|
||||
end
|
||||
|
|
|
@ -227,7 +227,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
namespace :chat_conversation_accounts do
|
||||
resource :blocked_chat_accounts, only: :show, controller: 'chat_conversation_accounts/blocked_chat_accounts'
|
||||
#
|
||||
end
|
||||
|
||||
resources :chat_conversation_accounts, only: :show do
|
||||
|
@ -256,6 +256,8 @@ Rails.application.routes.draw do
|
|||
get :count
|
||||
end
|
||||
end
|
||||
resources :blocked_chat_accounts, only: :index
|
||||
resources :muted_conversations, only: :index
|
||||
end
|
||||
|
||||
resources :chat_conversation, only: [:show, :create] do
|
||||
|
@ -268,6 +270,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
resources :links, only: :show
|
||||
resources :hashtags, only: :show
|
||||
resource :popular_links, only: :show
|
||||
resources :streaming, only: [:index]
|
||||
resources :custom_emojis, only: [:index]
|
||||
|
|
|
@ -114,6 +114,7 @@
|
|||
"react-router-dom": "^4.1.1",
|
||||
"react-router-scroll-4": "^1.0.0-beta.2",
|
||||
"react-sortable-hoc": "^1.11.0",
|
||||
"react-sparklines": "^1.7.0",
|
||||
"react-stickynode": "^3.0.4",
|
||||
"react-swipeable-views": "^0.13.9",
|
||||
"react-textarea-autosize": "^7.1.0",
|
||||
|
|
|
@ -6618,6 +6618,13 @@ react-sortable-hoc@^1.11.0:
|
|||
invariant "^2.2.4"
|
||||
prop-types "^15.5.7"
|
||||
|
||||
react-sparklines@^1.7.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/react-sparklines/-/react-sparklines-1.7.0.tgz#9b1d97e8c8610095eeb2ad658d2e1fcf91f91a60"
|
||||
integrity sha512-bJFt9K4c5Z0k44G8KtxIhbG+iyxrKjBZhdW6afP+R7EnIq+iKjbWbEFISrf3WKNFsda+C46XAfnX0StS5fbDcg==
|
||||
dependencies:
|
||||
prop-types "^15.5.10"
|
||||
|
||||
react-stickynode@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/react-stickynode/-/react-stickynode-3.0.4.tgz#1e9c096cec3613cc8294807eba319ced074c8b21"
|
||||
|
|
Loading…
Reference in New Issue