-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Отправка сообщений #22
Conversation
src/Components/Chat/Chat.hbs
Outdated
@@ -14,7 +14,7 @@ | |||
placeholder='Сообщение...' | |||
value='{{inputMessageValue}}' | |||
/> | |||
<button class='input_send chat-input' disabled>-></button> | |||
<button class='input_send chat-input'>-></button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
→
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
спасибо
@@ -1,3 +1,3 @@ | |||
<div class="message"> | |||
<div class="{{message_owner}}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот тут нет ошибки?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Там теперь логика такая, что если id пользователя совпадает с id отправителя сообщения, то используется класс my_message, для которого уже заготовлены стили
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
так это можно прямо в шаблоне проверить типа через class="{{isCurrentUserOwner ? 'owner' : 'noOwner'}}"
src/Pages/ChatPage.js
Outdated
@@ -73,6 +77,7 @@ export default class ChatPage { | |||
throw new Error('Пришел не 200 статус'); | |||
} | |||
const profile = response.body.user; | |||
this.UserId = profile.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему с большой?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправил на маленькую
src/Pages/ChatPage.js
Outdated
@@ -84,6 +89,20 @@ export default class ChatPage { | |||
this.#messageDrafts[this.#currentChatId] = event.target.value; | |||
}; | |||
|
|||
messageSendHandler = () => { | |||
const inputMessage = this.#parent.querySelector('#input_message').value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.trim еще бы добавить и возможно удалить xss уже на этом этапе
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сделал
src/Pages/ChatPage.js
Outdated
// Проверяем, что есть сообщение и ID чата | ||
websocketManager.sendMessage(chatId, inputMessage); | ||
setTimeout(() => { | ||
goToPage('/chat?id=' + chatId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А зачем тут переход?
export let baseUrl = 'localhost:8080'; | ||
|
||
if (protocol === 'https') { | ||
baseUrl = 'chatme.site/api/v1'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не согласен, почему от протокола зависит адрес?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это для деплоя, там ngnix ругался
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тогда нужно сделать какой-то параметр, который будет определять, мы в тестовом окружении или в проде. условно, тут же переменная ENV_TYPE, которая в ветке master будет равна PROD, а в остальных - DEV
src/utils/router.js
Outdated
@@ -13,10 +13,7 @@ function handleRouting() { | |||
|
|||
export function goToPage(path) { | |||
window.history.pushState({}, '', path); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему эту правку убрали?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
некорректно работали стрелочки и некоторые переходы
src/Pages/ChatPage.js
Outdated
const chatId = this.#currentChatId; // Получаем ID текущего чата | ||
function escapeHTML(html) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это должно быть методом класса, а еще лучше - функцией модуля utils, но точно не локальной функцией
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправил
… в другой чат, а также всплытие чата наверх при получении нового сообщения
(chat) => chat.id === message.chat_id, | ||
); | ||
if (chatIndex !== -1) { | ||
const chat = this.#chats.splice(chatIndex, 1)[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
проще сделать сортировку через css (свойство order)
Отправка сообщений с помощью вебсокетов