diff --git a/.vscode/settings.json b/.vscode/settings.json index 7de1b8db0..226bd2872 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,5 +7,21 @@ } }, "ruby.format": "rubocop", - "ruby.intellisense": "rubyLocate" + "ruby.intellisense": "rubyLocate", + "workbench.colorCustomizations": { + "activityBar.background": "#ab307e", + "activityBar.activeBorder": "#25320e", + "activityBar.foreground": "#e7e7e7", + "activityBar.inactiveForeground": "#e7e7e799", + "activityBarBadge.background": "#25320e", + "activityBarBadge.foreground": "#e7e7e7", + "titleBar.activeBackground": "#832561", + "titleBar.inactiveBackground": "#83256199", + "titleBar.activeForeground": "#e7e7e7", + "titleBar.inactiveForeground": "#e7e7e799", + "statusBar.background": "#832561", + "statusBarItem.hoverBackground": "#ab307e", + "statusBar.foreground": "#e7e7e7" + }, + "peacock.color": "#832561" } diff --git a/app/assets/stylesheets/chat.scss b/app/assets/stylesheets/chat.scss index a8e15353c..2d24038f5 100644 --- a/app/assets/stylesheets/chat.scss +++ b/app/assets/stylesheets/chat.scss @@ -1104,6 +1104,7 @@ display: flex; height: inherit; align-items: stretch; + position: relative; } .messagecomposer__input { @@ -1249,6 +1250,7 @@ display: none; justify-content: end; -webkit-justify-content: flex-end; + } .message__actions span { @@ -1256,7 +1258,6 @@ font-size: 13px; font-weight: bold; cursor: pointer; - color: var(--theme-secondary-color, $medium-gray); } .chatmessage:hover .message__actions { @@ -1287,7 +1288,6 @@ border: 2px solid; background: var(--theme-background, #f5f6f7); color: var(--theme-color, $black); - border-radius: 3px; } .modal__content h3 { @@ -1306,7 +1306,6 @@ padding: 5px 20px; cursor: pointer; user-select: none; - border-radius: 3px; } .message__delete__modal__hide { @@ -1316,4 +1315,34 @@ .message__delete__button { background: #ff0000; color: white; -} \ No newline at end of file +} + +.messageToBeEdited { + position: absolute; + display: grid; + grid-template-columns: 1fr 40px; + width: calc(100% - 14px); + top: -53px; + background: white; + padding: 0px 5px; + border: 1px solid var(--theme-top-bar-background, #dbdbdb); + border-left: 3px solid #4e57ef; + height: 50px; + overflow: hidden; +} + +.closeEdit { + text-align: right; + user-select: none; + cursor: pointer; + padding: 2px 5px; + color: #4e57ef; + font-weight: bold; +} + +.editHead { + position: absolute; + color: #4e57ef; + font-size: 14px; + font-weight: bold; +} diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 5771fe511..4421b7b47 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -1,5 +1,5 @@ class MessagesController < ApplicationController - before_action :set_message, only: %i[destroy] + before_action :set_message, only: %i[destroy update] before_action :authenticate_user!, only: %i[create] def create @@ -50,6 +50,31 @@ class MessagesController < ApplicationController end end + def update + authorize @message + + if @message.update(permitted_attributes(@message).merge(edited_at: Time.zone.now)) + if @message.valid? + begin + message_json = create_pusher_payload(@message, "") + Pusher.trigger(@message.chat_channel.pusher_channels, "message-edited", message_json) + rescue Pusher::Error => e + logger.info "PUSHER ERROR: #{e.message}" + end + end + render json: { status: "success", message: "Message was edited" } + else + render json: { + status: "error", + message: { + chat_channel_id: @message.chat_channel_id, + message: @message.errors.full_messages, + type: "error" + } + }, status: :unauthorized + end + end + private def create_pusher_payload(new_message, temp_id) @@ -62,6 +87,8 @@ class MessagesController < ApplicationController username: new_message.user.username, profile_image_url: ProfileImage.new(new_message.user).get(90), message: new_message.message_html, + markdown: new_message.message_markdown, + edited_at: new_message.edited_at, timestamp: Time.current, color: new_message.preferred_user_color, reception_method: "pushed" diff --git a/app/javascript/chat/__tests__/__snapshots__/chat.test.jsx.snap b/app/javascript/chat/__tests__/__snapshots__/chat.test.jsx.snap index 22ee18eec..3ee97f2fa 100644 --- a/app/javascript/chat/__tests__/__snapshots__/chat.test.jsx.snap +++ b/app/javascript/chat/__tests__/__snapshots__/chat.test.jsx.snap @@ -244,23 +244,25 @@ exports[` should load chat 1`] = `
-
-