From 67eb9d58902bb1567ffe62ced5e3355e3fbcf540 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Sun, 20 Dec 2020 12:27:24 -0500 Subject: [PATCH] Progress Report modal style fix, chat updates, statusserializer revert, display name truncation --- .../api/v1/accounts/statuses_controller.rb | 1 - .../api/v1/chat_conversation_controller.rb | 2 +- .../api/v1/timelines/group_controller.rb | 2 +- .../v1/timelines/preview_card_controller.rb | 2 +- .../api/web/chat_settings_controller.rb | 20 +++++++ app/javascript/gabsocial/actions/accounts.js | 1 - .../gabsocial/actions/chat_conversations.js | 1 - .../gabsocial/actions/chat_messages.js | 2 - .../gabsocial/actions/chat_settings.js | 35 ++++++++++++ app/javascript/gabsocial/actions/timelines.js | 1 - .../gabsocial/components/display_name.js | 14 ++--- .../components/modal/report_modal.js | 11 ++-- .../navigation_bar/chat_navigation_bar_xs.js | 25 ++++++--- .../navigation_bar/profile_navigation_bar.js | 20 ++++--- ...conversation_expiration_options_popover.js | 1 - .../chat_conversation_options_popover.js | 2 + .../popover/chat_settings_popover.js | 54 +++++++++++++++++++ .../components/popover/date_picker_popover.js | 2 +- .../components/popover/popover_root.js | 5 +- app/javascript/gabsocial/components/status.js | 7 ++- .../gabsocial/components/status_check_box.js | 18 +++++-- .../gabsocial/components/status_header.js | 13 +++-- .../user_suggestions_injection.js | 2 +- app/javascript/gabsocial/constants.js | 1 + .../features/chat_conversation_create.js | 50 ++++++++--------- .../features/chat_conversation_mutes.js | 21 ++++++++ .../gabsocial/features/group_members.js | 31 +++++------ .../features/group_removed_accounts.js | 14 +++++ .../components/chat_message_compose_form.js | 11 ++-- .../components/chat_message_scrolling_list.js | 17 ++++-- .../gabsocial/features/messages_settings.js | 2 +- app/javascript/gabsocial/features/status.js | 1 + app/javascript/gabsocial/features/ui/ui.js | 3 +- .../features/ui/util/async_components.js | 2 + .../features/ui/util/wrapped_route.js | 9 ---- .../gabsocial/layouts/messages_layout.js | 29 ++++++++-- app/javascript/gabsocial/pages/modal_page.js | 1 + .../gabsocial/reducers/chat_settings.js | 26 +++++++++ app/javascript/gabsocial/reducers/index.js | 2 + app/javascript/gabsocial/reducers/toasts.js | 1 - app/javascript/gabsocial/selectors/index.js | 6 --- app/javascript/gabsocial/utils/scroll_to.js | 2 +- app/javascript/styles/global.css | 10 ++++ app/models/chat_conversation_account.rb | 8 +++ app/models/home_feed.rb | 1 - app/serializers/rest/status_serializer.rb | 34 ++---------- app/views/admin/accounts/_account.html.haml | 2 + config/navigation.rb | 1 + config/routes.rb | 1 + 49 files changed, 369 insertions(+), 158 deletions(-) create mode 100644 app/controllers/api/web/chat_settings_controller.rb create mode 100644 app/javascript/gabsocial/actions/chat_settings.js create mode 100644 app/javascript/gabsocial/components/popover/chat_settings_popover.js create mode 100644 app/javascript/gabsocial/features/chat_conversation_mutes.js create mode 100644 app/javascript/gabsocial/reducers/chat_settings.js diff --git a/app/controllers/api/v1/accounts/statuses_controller.rb b/app/controllers/api/v1/accounts/statuses_controller.rb index b4563d28..68703ed3 100644 --- a/app/controllers/api/v1/accounts/statuses_controller.rb +++ b/app/controllers/api/v1/accounts/statuses_controller.rb @@ -9,7 +9,6 @@ class Api::V1::Accounts::StatusesController < Api::BaseController @statuses = load_statuses render json: @statuses, each_serializer: REST::StatusSerializer, - account_id: params[:account_id], relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id) end diff --git a/app/controllers/api/v1/chat_conversation_controller.rb b/app/controllers/api/v1/chat_conversation_controller.rb index 8a146645..db796456 100644 --- a/app/controllers/api/v1/chat_conversation_controller.rb +++ b/app/controllers/api/v1/chat_conversation_controller.rb @@ -25,6 +25,7 @@ class Api::V1::ChatConversationController < Api::BaseController # check if chat blocked # check if allow anyone to message then create with approved:true # unique account id, participants + chat_conversation_account = find_or_create_conversation render json: chat_conversation_account, each_serializer: REST::ChatConversationAccountSerializer end @@ -67,7 +68,6 @@ class Api::V1::ChatConversationController < Api::BaseController else @expires_at = nil end - puts "tilly @expires_at: " + @expires_at.inspect @chat_conversation_account.chat_message_expiration_policy = @expires_at @chat_conversation_account.save! render json: @chat_conversation_account, serializer: REST::ChatConversationAccountSerializer diff --git a/app/controllers/api/v1/timelines/group_controller.rb b/app/controllers/api/v1/timelines/group_controller.rb index 01e0a31b..489ddae3 100644 --- a/app/controllers/api/v1/timelines/group_controller.rb +++ b/app/controllers/api/v1/timelines/group_controller.rb @@ -13,7 +13,7 @@ class Api::V1::Timelines::GroupController < Api::BaseController if current_user render json: @statuses, each_serializer: REST::StatusSerializer, - group_id: params[:id], + group_id: params[:id], # : todo : relationships: StatusRelationshipsPresenter.new(@statuses, current_user.account_id, group_id: @group.id) else render json: @statuses, each_serializer: REST::StatusSerializer diff --git a/app/controllers/api/v1/timelines/preview_card_controller.rb b/app/controllers/api/v1/timelines/preview_card_controller.rb index 4734ea2a..4b7fcf00 100644 --- a/app/controllers/api/v1/timelines/preview_card_controller.rb +++ b/app/controllers/api/v1/timelines/preview_card_controller.rb @@ -10,7 +10,7 @@ class Api::V1::Timelines::PreviewCardController < Api::BaseController def show render json: @statuses, each_serializer: REST::StatusSerializer, - preview_card_id: params[:id], + preview_card_id: params[:id], # : todo : relationships: StatusRelationshipsPresenter.new(@statuses, current_user.account_id) end diff --git a/app/controllers/api/web/chat_settings_controller.rb b/app/controllers/api/web/chat_settings_controller.rb new file mode 100644 index 00000000..32fee0ba --- /dev/null +++ b/app/controllers/api/web/chat_settings_controller.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class Api::Web::ChatSettingsController < Api::Web::BaseController + before_action :require_user! + + def update + setting.data = params[:data] + setting.save! + + # todo validate all data objects + + render_empty_success + end + + private + + def setting + @_setting ||= ::Web::Setting.where(user: current_user).first_or_initialize(user: current_user) + end +end diff --git a/app/javascript/gabsocial/actions/accounts.js b/app/javascript/gabsocial/actions/accounts.js index 7677afd9..702cc345 100644 --- a/app/javascript/gabsocial/actions/accounts.js +++ b/app/javascript/gabsocial/actions/accounts.js @@ -162,7 +162,6 @@ export const followAccount = (id, reblogs = true) => (dispatch, getState) => { dispatch(followAccountRequest(id, locked)) api(getState).post(`/api/v1/accounts/${id}/follow`, { reblogs }).then((response) => { - console.log("response:", response) dispatch(followAccountSuccess(response.data, alreadyFollowing)) }).catch((error) => { dispatch(followAccountFail(error, locked)) diff --git a/app/javascript/gabsocial/actions/chat_conversations.js b/app/javascript/gabsocial/actions/chat_conversations.js index 3386009d..777a099c 100644 --- a/app/javascript/gabsocial/actions/chat_conversations.js +++ b/app/javascript/gabsocial/actions/chat_conversations.js @@ -258,7 +258,6 @@ export const deleteChatConversation = (chatConversationId) => (dispatch, getStat dispatch(deleteChatConversationRequest(conversationId)) api(getState).delete(`/api/v1/chat_conversation/${chatConversationId}`).then((response) => { - console.log("chat_conversations delete response: ", response) dispatch(deleteChatConversationSuccess()) }).catch((error) => { dispatch(deleteChatConversationFail(error)) diff --git a/app/javascript/gabsocial/actions/chat_messages.js b/app/javascript/gabsocial/actions/chat_messages.js index 43e85700..41844f15 100644 --- a/app/javascript/gabsocial/actions/chat_messages.js +++ b/app/javascript/gabsocial/actions/chat_messages.js @@ -62,11 +62,9 @@ const sendChatMessageFail = (error) => ({ export const manageIncomingChatMessage = (chatMessage) => (dispatch, getState) => { if (!chatMessage) return - console.log("chatMessage:", chatMessage) dispatch(sendChatMessageSuccess(chatMessage)) const isOnline = getState().getIn(['chat_conversation_messages', chatMessage.chat_conversation_id, 'online']) - console.log("isOnline: ", isOnline) // : todo : // Check if is online for conversation, if not increase total/convo unread count diff --git a/app/javascript/gabsocial/actions/chat_settings.js b/app/javascript/gabsocial/actions/chat_settings.js new file mode 100644 index 00000000..7eab5433 --- /dev/null +++ b/app/javascript/gabsocial/actions/chat_settings.js @@ -0,0 +1,35 @@ +import api from '../api' +import debounce from 'lodash.debounce' +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) => { + dispatch({ + type: CHAT_SETTING_CHANGE, + path, + value, + }) + + dispatch(saveChatSettings()) +} + +/** + * + */ +export const saveChatSettings = () => (dispatch, getState) => { + debouncedChatSettingsSave(dispatch, getState) +} + +const debouncedChatSettingsSave = debounce((dispatch, getState) => { + if (!me) return + + if (getState().getIn(['chat_settings', 'saved'])) return + + const data = getState().get('chat_settings').filter((_, path) => path !== 'saved').toJS() + + api().put('/api/web/chat_settings', { data }) + .then(() => dispatch({ type: CHAT_SETTING_SAVE })) + .catch(() => { /* */ }) +}, 350, { trailing: true }) diff --git a/app/javascript/gabsocial/actions/timelines.js b/app/javascript/gabsocial/actions/timelines.js index 2429c6d6..08a91207 100644 --- a/app/javascript/gabsocial/actions/timelines.js +++ b/app/javascript/gabsocial/actions/timelines.js @@ -151,7 +151,6 @@ export const expandTimeline = (timelineId, path, params = {}, done = noop) => (d dispatch(expandTimelineRequest(timelineId, isLoadingMore)) api(getState).get(path, { params }).then((response) => { - console.log("response:", response) const next = getLinks(response).refs.find(link => link.rel === 'next') dispatch(importFetchedStatuses(response.data)) dispatch(expandTimelineSuccess(timelineId, response.data, next ? next.uri : null, response.code === 206, isLoadingRecent, isLoadingMore)) diff --git a/app/javascript/gabsocial/components/display_name.js b/app/javascript/gabsocial/components/display_name.js index 3c3bd16f..16926bea 100644 --- a/app/javascript/gabsocial/components/display_name.js +++ b/app/javascript/gabsocial/components/display_name.js @@ -106,8 +106,7 @@ class DisplayName extends ImmutablePureComponent { const usernameClasses = CX({ text: 1, displayFlex: 1, - flexNormal: 1, - flexShrink1: 1, + flexShrink0: 1, overflowWrapBreakWord: 1, textOverflowEllipsis: 1, cSecondary: 1, @@ -131,17 +130,10 @@ class DisplayName extends ImmutablePureComponent { const isFollowedBy = (me !== accountId && account.getIn(['relationship', 'followed_by'])) if (isFollowedBy) { - relationshipLabel = 'Follows you'//intl.formatMessage(messages.accountFollowsYou) + relationshipLabel = 'Follows you' } } - // { - // /* : todo : audio-mute, bot - // account.getIn(['relationship', 'muting']) - // */ - // } - // bot: { id: 'account.badges.bot', defaultMessage: 'Bot' }, - return (