aboutsummaryrefslogtreecommitdiff
path: root/src/components/chat/chat.vue
blob: 0d44c920651cb56dd910069bb92ec5a1c6bd9960 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<template>
  <div class="chat-view">
    <div class="chat-view-inner">
      <div
        id="nav"
        ref="inner"
        class="panel-default panel chat-view-body"
      >
        <div
          ref="header"
          class="panel-heading chat-view-heading mobile-hidden"
        >
          <a
            class="go-back-button"
            @click="goBack"
          >
            <i class="button-icon icon-left-open" />
          </a>
          <div class="title text-center">
            <ChatTitle
              :user="recipient"
              :with-avatar="true"
            />
          </div>
        </div>
        <template>
          <div
            ref="scrollable"
            class="scrollable-message-list"
            :style="{ height: scrollableContainerHeight }"
            @scroll="handleScroll"
          >
            <template v-if="!errorLoadingChat">
              <ChatMessage
                v-for="chatViewItem in chatViewItems"
                :key="chatViewItem.id"
                :author="recipient"
                :chat-view-item="chatViewItem"
                :hovered-message-chain="chatViewItem.messageChainId === hoveredMessageChainId"
                @hover="onMessageHover"
              />
            </template>
            <div
              v-else
              class="chat-loading-error"
            >
              <div class="alert error">
                {{ $t('chats.error_loading_chat') }}
              </div>
            </div>
          </div>
          <div
            ref="footer"
            class="panel-body footer"
          >
            <div
              class="jump-to-bottom-button"
              :class="{ 'visible': jumpToBottomButtonVisible }"
              @click="scrollDown({ behavior: 'smooth' })"
            >
              <span>
                <FAIcon icon="chevron-down" />
                <div
                  v-if="newMessageCount"
                  class="badge badge-notification unread-chat-count unread-message-count"
                >
                  {{ newMessageCount }}
                </div>
              </span>
            </div>
            <PostStatusForm
              :disable-subject="true"
              :disable-scope-selector="true"
              :disable-notice="true"
              :disable-lock-warning="true"
              :disable-polls="true"
              :disable-sensitivity-checkbox="true"
              :disable-submit="errorLoadingChat || !currentChat"
              :disable-preview="true"
              :post-handler="sendMessage"
              :submit-on-enter="!mobileLayout"
              :preserve-focus="!mobileLayout"
              :auto-focus="!mobileLayout"
              :placeholder="formPlaceholder"
              :file-limit="1"
              max-height="160"
              emoji-picker-placement="top"
              @resize="handleResize"
            />
          </div>
        </template>
      </div>
    </div>
  </div>
</template>

<script src="./chat.js"></script>
<style lang="scss">
@import '../../_variables.scss';
@import './chat.scss';
</style>