Code Monkey home page Code Monkey logo

Comments (6)

antoine92190 avatar antoine92190 commented on May 26, 2024 1

Indeed, the chat is not working properly without managing the loading pattern of rooms and messages.
loadingRooms and messagesLoaded need to be initialised properly, and then reassigned. Please try snippet below:

<template>
  <chat-window
    :currentUserId="1234"
    :rooms="rooms"
    :loadingRooms="loadingRooms"
    :messages="messages"
    :messagesLoaded="messagesLoaded"
  >
  </chat-window>
</template>

<script>
import ChatWindow from 'vue-advanced-chat'
import 'vue-advanced-chat/dist/vue-advanced-chat.css'

export default {
  components: {
    ChatWindow
  },

  data() {
    return {
      rooms: [],
      loadingRooms: true,
      messages: [],
      messagesLoaded: false
    }
  },

  mounted() {
    this.rooms = [
      {
        roomId: 1,
        roomName: 'Room 1',
        unreadCount: 4,
        lastMessage: {
          content: 'Last message received',
          sender_id: 1234,
          username: 'John Doe',
          timestamp: '10:20',
          date: 123242424,
          seen: false,
          new: true
        },
        users: [
          {
            _id: 1234,
            username: 'John Doe',
            status: {
              state: 'online',
              last_changed: 'today, 14:30'
            }
          },
          {
            _id: 4321,
            username: 'John Snow',
            status: {
              state: 'offline',
              last_changed: '14 July, 20:00'
            }
          }
        ],
        typingUsers: [4321]
      }
    ]

    this.messages = [
      {
        _id: 12345,
        roomId: 1,
        content: 'Heeeey',
        sender_id: 4321,
        username: 'Tu',
        date: '13 November',
        timestamp: '10:20',
        seen: true,
        disable_actions: false,
        disable_reactions: true
      }
    ]

    this.loadingRooms = false
    this.messagesLoaded = true
  }
}
</script>

from vue-advanced-chat.

antoine92190 avatar antoine92190 commented on May 26, 2024 1

Issue should be fixed in 1509e5e
There is no need to follow the loading pattern described above anymore.

from vue-advanced-chat.

antoine92190 avatar antoine92190 commented on May 26, 2024

The below component works fine for me. Can you try and let me know if it works on you side. If not is there any error in the console?

<template>
  <chat-window
    :currentUserId="1234"
    :rooms="[
      {
        roomId: 1,
        roomName: 'Tu',
        unreadCount: 4,
        lastMessage: {
          content: 'Heeeeyooooo!!',
          sender_id: 4321,
          username: 'John snow',
          timestamp: '10:20',
          date: 123242424,
          seen: false,
          new: true
        },
        users: [
          {
            _id: 1234,
            username: 'John snow',
            status: {
              state: 'online',
              last_changed: 'today, 14:30'
            }
          },
          {
            _id: 4321,
            username: 'Ingrid',
            status: {
              state: 'offline',
              last_changed: '14 July, 20:00'
            }
          }
        ]
      }
    ]"
    :messages="[
      {
        _id: 12345,
        roomId: 1,
        content: 'Heeeey',
        sender_id: 4321,
        username: 'Tu',
        date: '13 November',
        timestamp: '10:20',
        seen: true,
        disable_actions: false,
        disable_reactions: true
      }
    ]"
    :messagesLoaded="true"
  >
  </chat-window>
</template>

<script>
import ChatWindow from 'vue-advanced-chat'
import 'vue-advanced-chat/dist/vue-advanced-chat.css'

export default {
  components: {
    ChatWindow
  }
}
</script>

from vue-advanced-chat.

SergioBarbero avatar SergioBarbero commented on May 26, 2024

Hi, I just tried, and the message appears outside the room
image

When I click in the room I get this
image

No errors in the console

from vue-advanced-chat.

SergioBarbero avatar SergioBarbero commented on May 26, 2024

Thank you so much :)

I think it would be interesting to add this information in the readme

from vue-advanced-chat.

antoine92190 avatar antoine92190 commented on May 26, 2024

Yes definitely, I'll leave this issue open until then.

from vue-advanced-chat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.