From 1bd1bccb7a75074ee77371525c1c998871bb0fc0 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Wed, 15 May 2024 12:56:28 +0800 Subject: [PATCH] added ability to add custom component in layout section components, added scroll handle when sending message from chat window --- addon/components/chat-window.js | 8 ++-- addon/components/layout/section/footer.hbs | 3 ++ addon/components/layout/section/header.hbs | 54 +++++++++++++--------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/addon/components/chat-window.js b/addon/components/chat-window.js index bf60b4f..f0cce28 100644 --- a/addon/components/chat-window.js +++ b/addon/components/chat-window.js @@ -50,15 +50,15 @@ export default class ChatWindowComponent extends Component { this.sender = this.getSenderFromParticipants(channel); // if not participant close window if (!this.sender) { - later( + return later( this, () => { this.chat.closeChannel(channel); }, 300 ); - return; } + this.listenChatChannel(channel); this.loadAvailableUsers.perform(); this.chat.on('chat.closed', this.handleChatClosed.bind(this)); @@ -73,6 +73,7 @@ export default class ChatWindowComponent extends Component { async listenChatChannel(chatChannelRecord) { this.socket.listen(`chat.${chatChannelRecord.public_id}`, (socketEvent) => { const { event, data } = socketEvent; + console.log(event); switch (event) { case 'chat.added_participant': case 'chat.removed_participant': @@ -140,6 +141,7 @@ export default class ChatWindowComponent extends Component { yield this.chat.sendMessage(this.channel, this.sender, this.pendingMessageContent, attachments); this.pendingMessageContent = ''; this.pendingAttachmentFiles = []; + this.handleChatFeedScroll(); } @action handleKeyPress(event) { @@ -233,7 +235,7 @@ export default class ChatWindowComponent extends Component { () => { this.channelFeedContainerElement.scrollTop = this.channelFeedContainerElement.scrollHeight; }, - 800 + 300 ); } } diff --git a/addon/components/layout/section/footer.hbs b/addon/components/layout/section/footer.hbs index 3c38857..f6c17de 100644 --- a/addon/components/layout/section/footer.hbs +++ b/addon/components/layout/section/footer.hbs @@ -1,3 +1,6 @@ \ No newline at end of file diff --git a/addon/components/layout/section/header.hbs b/addon/components/layout/section/header.hbs index 09dd0fe..f8c671b 100644 --- a/addon/components/layout/section/header.hbs +++ b/addon/components/layout/section/header.hbs @@ -1,28 +1,36 @@
-
-
- {{#if @badge}} - - - - {{/if}} - {{#if @icon}} - - {{/if}} -

{{@title}}

- {{#if @subtitle}} -
- {{@subtitle}} + {{#if @headerComponent}} + {{component @headerComponent}} + {{else}} +
+ {{#if @headerTitleComponent}} + {{component @headerTitleComponent}} + {{else}} +
+ {{#if @badge}} + + + + {{/if}} + {{#if @icon}} + + {{/if}} +

{{@title}}

+ {{#if @subtitle}} +
+ {{@subtitle}} +
+ {{/if}}
{{/if}} + {{#if @onSearch}} + + {{/if}}
- {{#if @onSearch}} - - {{/if}} -
- {{#unless @hideActions}} -
- {{yield}} -
- {{/unless}} + {{#unless @hideActions}} +
+ {{yield}} +
+ {{/unless}} + {{/if}}
\ No newline at end of file