added profile pictures to messages and improved chat page layout
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "chatapp",
|
"productName": "chatapp",
|
||||||
"version": "1.0.0",
|
"version": "1.0.3",
|
||||||
"identifier": "com.strawberries.chatapp",
|
"identifier": "com.strawberries.chatapp",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "yarn dev",
|
"beforeDevCommand": "yarn dev",
|
||||||
|
|||||||
BIN
src/assets/default-avatar.png
Normal file
BIN
src/assets/default-avatar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
@@ -19,6 +19,7 @@ body,
|
|||||||
:root {
|
:root {
|
||||||
--bg: #0f1116;
|
--bg: #0f1116;
|
||||||
--panel: #171922;
|
--panel: #171922;
|
||||||
|
--panel-accent: #12141B;
|
||||||
--text: #e6e6eb;
|
--text: #e6e6eb;
|
||||||
--muted: #9aa0aa;
|
--muted: #9aa0aa;
|
||||||
--accent: #f27aa3;
|
--accent: #f27aa3;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else class="chat-container">
|
<div v-else class="chat-container">
|
||||||
<!-- <h2 class="room-name">{{ currentRoom?.name }}</h2> -->
|
<h2 class="room-name">{{ currentRoom?.name }}</h2>
|
||||||
|
|
||||||
<div class="messages-container" ref="messageListRef" @scroll="handleScroll">
|
<div class="messages-container" ref="messageListRef" @scroll="handleScroll">
|
||||||
<MessageList :messages="messages" />
|
<MessageList :messages="messages" />
|
||||||
@@ -72,6 +72,8 @@ async function initializeRoom() {
|
|||||||
getAuthData()
|
getAuthData()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
console.log("First message payload:", msgs[0]);
|
||||||
|
|
||||||
messages.value = msgs;
|
messages.value = msgs;
|
||||||
currentRoom.value = roomInfo;
|
currentRoom.value = roomInfo;
|
||||||
currentUser.value = auth.user;
|
currentUser.value = auth.user;
|
||||||
@@ -220,10 +222,10 @@ onUnmounted(async () => {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* .room-name { */
|
.room-name {
|
||||||
/* margin: 15px 0; */
|
margin: 15px 0;
|
||||||
/* text-align: center; */
|
text-align: center;
|
||||||
/* } */
|
}
|
||||||
|
|
||||||
.loading-more {
|
.loading-more {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -1,45 +1,121 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import type { Message } from '../types'
|
|
||||||
defineProps<{ messages: Message[] }>()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="(m, i) in messages" :key="i" class="message">
|
<li v-for="(m, i) in messages" :key="i" class="message" :class="{ 'is-me': m.sender_uuid === currentUserUuid }">
|
||||||
<div class="sender">{{ m.sender }} <span class="timestamp">{{ m.sent_at }}</span></div>
|
<div class="sender-info">
|
||||||
|
<img :src="getAvatar(m.sender_uuid)" @error="handleAvatarError" class="sender-avatar" />
|
||||||
|
<div class="sender">{{ m.sender }}</div>
|
||||||
|
<span class="timestamp">{{ m.sent_at }}</span>
|
||||||
|
</div>
|
||||||
<div class="message-content">{{ m.content }}</div>
|
<div class="message-content">{{ m.content }}</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import type { Message } from '../types'
|
||||||
|
import { getAvatar } from '../api/account.ts'
|
||||||
|
import defaultAvatar from '../assets/default-avatar.png'
|
||||||
|
import { getAuthData } from '../authStore';
|
||||||
|
|
||||||
|
defineProps<{ messages: Message[] }>()
|
||||||
|
|
||||||
|
const currentUserUuid = ref<string | null>(null)
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const auth = await getAuthData()
|
||||||
|
if (auth.user) {
|
||||||
|
currentUserUuid.value = auth.user.uuid
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleAvatarError = (event: Event) => {
|
||||||
|
const img = event.target as HTMLImageElement;
|
||||||
|
img.src = defaultAvatar;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
ul {
|
ul {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.75rem;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message {
|
.message {
|
||||||
margin-bottom: 0.5rem;
|
display: flex;
|
||||||
background-color: rgba(0, 0, 0, 0.2);
|
flex-direction: column;
|
||||||
padding: 10px;
|
align-items: flex-start;
|
||||||
|
justify-content: center;
|
||||||
|
/* gap: 0.5rem; */
|
||||||
|
background: var(--panel-accent);
|
||||||
|
padding: 0;
|
||||||
|
max-width: 80%;
|
||||||
|
width: fit-content;
|
||||||
|
align-self: flex-start;
|
||||||
|
/* border: 1px solid var(--border); */
|
||||||
border-radius: var(--radius);
|
border-radius: var(--radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sender-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.7rem;
|
||||||
|
/* border: 1px solid var(--border); */
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
/* border-radius: var(--radius) var(--radius) 0 0; */
|
||||||
|
/* background-color: rgba(255, 255, 255, 0.02); */
|
||||||
|
width: 100%;
|
||||||
|
padding: 5px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sender-avatar {
|
||||||
|
width: 35px;
|
||||||
|
height: 35px;
|
||||||
|
border-radius: 50%;
|
||||||
|
object-fit: cover;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message.is-me {
|
||||||
|
align-self: flex-end;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message.is-me .sender-info {
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message.is-me .message-content {
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 1rem;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.sender {
|
.sender {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
margin-bottom: 0.25rem;
|
/* flex: 1; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.sender .timestamp {
|
.timestamp {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
font-size: 0.85rem;
|
font-size: 0.7rem;
|
||||||
margin-left: 0.5rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-content {
|
.message-content {
|
||||||
|
padding: 10px;
|
||||||
padding-left: 1rem;
|
padding-left: 1rem;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.rooms-header {
|
.rooms-header {
|
||||||
padding: 1.5rem;
|
padding: 15px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -59,9 +59,9 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.rooms-header h2 {
|
.rooms-header h2 {
|
||||||
font-size: 1.1rem;
|
/* font-size: 1rem; */
|
||||||
margin: 0;
|
margin: 0;
|
||||||
margin-left: 38px;
|
margin-left: 45px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scroll-area {
|
.scroll-area {
|
||||||
@@ -86,12 +86,13 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.room-item.active {
|
.room-item.active {
|
||||||
background: var(--accent);
|
/* border: 1px solid var(--border); */
|
||||||
color: rgba(0, 0, 0, 0.8);
|
background: var(--panel-accent);
|
||||||
|
color: var(--accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.room-item.active .room-owner {
|
.room-item.active .room-owner {
|
||||||
color: rgba(0, 0, 0, 1);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.room-info {
|
.room-info {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="chat-layout">
|
<div class="chat-layout">
|
||||||
<button class="menu-toggle" :class="{ 'sidebar-closed': !isSidebarOpen }" @click="isSidebarOpen = !isSidebarOpen">
|
<button class="menu-toggle" :class="{ 'sidebar-closed': !isSidebarOpen }"
|
||||||
|
@click="isSidebarOpen = !isSidebarOpen">
|
||||||
<i class="fa-solid fa-bars"></i>
|
<i class="fa-solid fa-bars"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ const handleRoomSelection = () => {
|
|||||||
|
|
||||||
.chat-window-container {
|
.chat-window-container {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding-left: 38px;
|
/* padding-left: 38px; */
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
@@ -78,7 +79,7 @@ const handleRoomSelection = () => {
|
|||||||
|
|
||||||
.menu-toggle {
|
.menu-toggle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 24px;
|
top: 15px;
|
||||||
left: 15px;
|
left: 15px;
|
||||||
z-index: 30;
|
z-index: 30;
|
||||||
background: var(--panel);
|
background: var(--panel);
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
<div class="settings-page">
|
<div class="settings-page">
|
||||||
<h1>{{ $t('settings-title') }}</h1>
|
<h1>{{ $t('settings-title') }}</h1>
|
||||||
|
|
||||||
<UpdateAccountModal v-if="showUpdateModal" :user="user" @close="showUpdateModal = false" @updated="fetchUserData" />
|
<UpdateAccountModal v-if="showUpdateModal" :user="user" @close="showUpdateModal = false"
|
||||||
|
@updated="fetchUserData" />
|
||||||
<UploadAvatarModal v-if="showAvatarModal" @close="showAvatarModal = false" @updated="fetchUserData" />
|
<UploadAvatarModal v-if="showAvatarModal" @close="showAvatarModal = false" @updated="fetchUserData" />
|
||||||
|
|
||||||
<h2>{{ $t('settings-account') }}</h2>
|
<h2>{{ $t('settings-account') }}</h2>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export interface Room {
|
|||||||
export interface Message {
|
export interface Message {
|
||||||
uuid: string
|
uuid: string
|
||||||
sender: string
|
sender: string
|
||||||
|
sender_uuid: string
|
||||||
message_type: 'text'
|
message_type: 'text'
|
||||||
content: string
|
content: string
|
||||||
sent_at: string
|
sent_at: string
|
||||||
|
|||||||
Reference in New Issue
Block a user