Skip to content

Commit

Permalink
prettier code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ro0t-set committed Sep 21, 2023
1 parent de2ca2d commit 51dfe06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ const showChat = computed(() => {
*/
watch(
() => userStore.selectedDirect,
(newVal, oldVal) => {
console.log('New direct: ' + newVal)
if (newVal != oldVal) {
messageStore.getMessagesFromDirect({
username: newVal.toString(),
from: 0,
limit: intitialLoadedMessages
})
}
() => {
console.log('New direct: ' + userStore.selectedDirect)
intitialLoadedMessages = 15
messageStore.getMessagesFromDirect({
username: userStore.selectedDirect,
from: 0,
limit: intitialLoadedMessages
})
}
)
Expand All @@ -48,6 +47,7 @@ watch(
() => userStore.selectedChannel,
() => {
console.log('New channel: ' + userStore.selectedChannel)
intitialLoadedMessages = 15
messageStore.getMessagesFromChannel({
serverId: userStore.selectedChannel[0],
channelId: userStore.selectedChannel[1],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import { useMessageStore } from '@/stores/messages'
import { ContentArea, useUserStore } from '@/stores/user'
const messageStore = useMessageStore()
const userStore = useUserStore()
const message = ref('')
let intitialLoadedMessages = 15
/**
* Checks if the user is in a valid content area (direct or channel)
*/
const shown = computed(() => {
if (
userStore.inContentArea == ContentArea.Direct ||
Expand All @@ -26,7 +27,6 @@ const shown = computed(() => {
* then refreshes the messages
*/
async function sendMessage() {
let intitialLoadedMessages = 15
if (userStore.inContentArea == ContentArea.Direct) {
await messageStore.sendMessageOnDirect(
{
Expand Down Expand Up @@ -69,7 +69,7 @@ function deleteMessage() {
</script>

<template>
<q-footer>
<q-footer v-if="shown">
<q-input padding filled v-model="message" label="Write..." @keydown.enter.prevent="sendMessage">
<template v-slot:append>
<q-icon v-if="message !== ''" name="close" @click="deleteMessage" class="cursor-pointer" />
Expand Down

0 comments on commit 51dfe06

Please sign in to comment.