Skip to content

Commit

Permalink
Merge pull request #207 from determaer/main
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
antirek authored Jan 29, 2025
2 parents 0295879 + b1ccf16 commit ce08a5a
Show file tree
Hide file tree
Showing 12 changed files with 533 additions and 147 deletions.
20 changes: 10 additions & 10 deletions src/BaseAdaptiveExtendedChatApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
filter-enabled
@select="selectChat"
@action="chatAction"
@load-more-chats="loadMoreChats"
>
<template #sidebar>
<SideBar
Expand Down Expand Up @@ -124,35 +125,32 @@
@force-scroll-to-bottom="forceScrollToBottom"
/>
<ChatInput
:focus-on-input-area="inputFocus"
@send="addMessage">
:focus-on-input-area="inputFocus"
@send="addMessage"
>
<template #buttons>
<FileUploader
:filebump-url="filebumpUrl"
:state="'disabled'"
/>
<ButtonEmojiPicker
:mode="'hover'"
:state="'disabled'"
/>
<ButtonTemplateSelector
:templates="templates"
:group-templates="groupTemplates"
:mode="'click'"
:state="'disabled'"
:elevated-window="false"
/>
<ButtonWabaTemplateSelector
:waba-templates="wabaTemplates"
:group-templates="groupTemplates"
:mode="'click'"
:state="'disabled'"
:filebump-url="filebumpUrl"
@send-waba-values="sendWabaValues"
/>
<ChannelSelector
:channels="channels"
:mode="'hover'"
:state="'disabled'"
@select-channel="onSelectChannel"
/>
</template>
Expand Down Expand Up @@ -310,6 +308,10 @@ const selectItem = (item) => {
console.log("selected sidebar item", item);
};
const loadMoreChats = () => {
console.log('load more chats')
}
const chatAction = async (data) => {
console.log("chat action", data);
if (data.action === "add") {
Expand Down Expand Up @@ -373,6 +375,7 @@ const messageVisible = (message) => {
}
const searchMessages = (string) => {
foundMessages.value = []
if (string && string.length > 0){
isShowFeedWhileSearch.value = false
foundMessages.value = transformToFeed(props.dataProvider.getMessagesBySearch(selectedChat.value.chatId, string))
Expand All @@ -391,9 +394,6 @@ const searchMessages = (string) => {
foundMessages.value = t
}
}
else {
foundMessages.value = []
}
}
const getFeedObjects = () => {
Expand Down
5 changes: 4 additions & 1 deletion src/data/chats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const chats = [
chatId: 1, name: "Василий ВасилийВасилийВасилий Василий",
avatar: 'https://img.freepik.com/free-photo/smiley-man-relaxing-outdoors_23-2148739334.jpg',
countUnread: 102,
lastMessage: 'test',
lastMessage: 'Длинное сообщение сомнительного характера в контексте размещения на малой строке',
'lastActivity.time': 'час назад', // читаемый формат - для пользователей
'lastActivity.timestamp': '1727001759', // для сортировки
isFixedBottom: false,
Expand All @@ -19,6 +19,9 @@ export const chats = [
},
{
chatId: 2, name: "Мария",
colorUnread: 'green',
lastMessage: 'Длинное сообщение сомнительного характера в контексте размещения на малой строке',

countUnread: 0, isFixedTop: true,
'lastActivity.time': 'час назад',
'lastActivity.timestamp': '1727027359',
Expand Down
31 changes: 31 additions & 0 deletions src/helpers/useSearchModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ref } from 'vue';

interface SearchModel {
id: string
text: string
}

const searchModels = ref<SearchModel[]>([])

export const useSearchModel = (outId : string) => {

const index = ref<number>(0)

let foundModel = searchModels.value.find(({id}) => id == outId)
if (foundModel != undefined){
index.value = searchModels.value.indexOf(foundModel)
}
else {
searchModels.value.push({
id: outId,
text: '',
})
index.value = searchModels.value.length - 1
}

const getModel = () => {
return searchModels.value[index.value]
}

return {getModel}
}
5 changes: 5 additions & 0 deletions src/library/components/ButtonTemplateSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<TemplateSelector
:templates="templates"
:group-templates="groupTemplates"
:elevated-window="elevatedWindow"
@close-template-window="close"
/>
</div>
Expand Down Expand Up @@ -47,6 +48,10 @@ const props = defineProps({
type: String,
default: 'active',
},
elevatedWindow: {
type: Boolean,
required: false,
}
})
const templateButton = ref(null)
Expand Down
15 changes: 11 additions & 4 deletions src/library/components/ChatItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@
</div>

<div class="chat-item__info-container">
<div class="chat-item__name">
<Tooltip :text="chat.name" position="bottom">
<div class="chat-item__name">
{{ chat.name }}
</div>

<div
</Tooltip>

<Tooltip :text="chat.lastMessage" position="bottom">
<div
v-if="chat.lastMessage || chat.typing"
class="chat-item__last-message"
>
{{ showText }}
</div>
</Tooltip>

</div>

<div class="chat-item__details-container">
Expand All @@ -46,6 +51,7 @@
<div
v-if="chat.countUnread > 0"
class="chat-item__unread"
:style="{backgroundColor: chat.colorUnread ? chat.colorUnread : null}"
>
{{ chat.countUnread > 99 ? '99+' : chat.countUnread }}
</div>
Expand Down Expand Up @@ -98,6 +104,7 @@ import { ref, computed, watch } from 'vue'
import { ContextMenu } from '.'
import { getStatus, statuses } from "../../helpers";
import { t } from '../../locale/useLocale'
import Tooltip from './Tooltip.vue';
const props = defineProps({
chat: {
Expand Down Expand Up @@ -246,7 +253,7 @@ watch(
flex-grow: 1;
align-self: flex-start;
margin-right: 15px;
overflow-x: hidden;
overflow: hidden;
}
&__name {
Expand Down
36 changes: 25 additions & 11 deletions src/library/components/ChatList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@
@update="getFilter"
/>

<div class="chat-list__items">
<div
class="chat-list__items"
ref="refChatList"
@scroll="scrollCheck"
>
<div class="chat-list__fixed-items-top">
<ChatItem
v-for="chat in getSortedAndFilteredChats().filter(c => c.isFixedTop)"
Expand Down Expand Up @@ -82,17 +86,10 @@
</template>

<script setup>
import { ref } from 'vue';
import {ChatItem, ChatFilter, ContextMenu} from "./";
import { ref, unref } from 'vue';
import { ChatItem, ChatFilter, ContextMenu } from "./";
import { t } from '../../locale/useLocale';
const filter = ref('');
const isOpenMenu = ref(false)
const hideMenu = () => {
isOpenMenu.value = false
}
// Define props
const props = defineProps({
chats: {
Expand All @@ -111,7 +108,24 @@ const props = defineProps({
});
// Define emits
const emit = defineEmits(['select', 'action']);
const emit = defineEmits(['select', 'action', 'loadMoreChats']);
const filter = ref('');
const isOpenMenu = ref(false)
const refChatList = ref()
const hideMenu = () => {
isOpenMenu.value = false
}
const scrollCheck = () => {
const element = unref(refChatList);
const scrollBottom = element.scrollHeight - element.scrollTop - element.clientHeight;
if (scrollBottom <= 0){
emit('loadMoreChats')
}
};
// Define method
const selectChat = (chat) => {
Expand Down
17 changes: 12 additions & 5 deletions src/library/components/FeedSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class="feed-search__input"
type="text"
:placeholder="t('component.FeedSearch.SearchPlaceholder')"
v-model="search"
v-model="getModel().text"
>
<i
class="pi pi-times"
Expand All @@ -25,10 +25,14 @@
</template>

<script setup lang="ts">
import { ref, unref, onMounted, watch, computed } from 'vue';
import { ref, unref, onMounted, watch, computed, inject } from 'vue';
import { t } from '../../locale/useLocale';
import { useSearchModel } from '../../helpers/useSearchModel';
import useDelayDebouncedRef from '../../helpers/useDelayDebouncedRef';
const chatAppId = inject('chatAppId')
const { getModel } = useSearchModel(chatAppId as string)
const emit = defineEmits(['search', 'cancel', 'switch'])
const props = defineProps({
Expand All @@ -47,23 +51,26 @@ const resetLoc = computed(() => {
})
watch(
() => search.value,
() => [getModel().text, search.value],
() => {
emit('search', search.value);
if (search.value == getModel().text)
emit('search', getModel().text);
else
search.value = getModel().text
}
)
const clearInput = () => {
const el = unref(refInput);
if (el)
el.value = ''
getModel().text = ''
emit('cancel')
}
onMounted(() => {
const el = unref(refInput);
el?.focus()
emit('search', el?.value);
})
</script>
Expand Down
Loading

0 comments on commit ce08a5a

Please sign in to comment.