vue-advanced-chat icon indicating copy to clipboard operation
vue-advanced-chat copied to clipboard

room-id prop - is it working?

Open TimurZur opened this issue 3 years ago • 6 comments

I didn't quite understand from the documentation how the room-id prop should work. If I write some room-id on mounted to load messages only for this room, I get an error.

If this is not a bug, then please tell me how to use the room-id correctly to show (fetch) messages for a specific room.

For example, I want to show messages for room 13 using the link: mychat.com/?chatId=13

Here's what's in the template (Removed unnecessary props just to show):

        <vue-advanced-chat
            :room-id="currentRoomId"
        />

Data (Removed unnecessary):

    data() {
        return {
            currentRoomId: null,
        }
    },

Here's what's on mounted

mounted() {
        this.loadingRooms = true;
        this.messagesLoaded = false;
        Nova.request().get(API_PREFIX + 'user')
            .then(data => {
             ...
            })
            .then(() => {
                const urlSearchParams = new URLSearchParams(window.location.search);
                const params = Object.fromEntries(urlSearchParams.entries());
                if (params['chatId']) {
                    this.currentRoomId = parseInt(params['chatId']);
                }
            })
    },

And here is the error: image

TimurZur avatar Sep 22 '22 13:09 TimurZur

All prop ids should be strings, have you tried to convert it as a string? Which vue version are you using? Which chat version are you using?

antoine92190 avatar Sep 22 '22 14:09 antoine92190

All prop ids should be strings, have you tried to convert it as a string? Which vue version are you using? Which chat version are you using?

Yes, I tried to convert it as a string, same result.

"vue-advanced-chat": "^2.0.3" Vue: 3.2.38

TimurZur avatar Sep 22 '22 14:09 TimurZur

room-id is working fine on my side. Could you give me access to your repo, or reproduce a minimal example so I can reproduce?

antoine92190 avatar Sep 22 '22 16:09 antoine92190

room-id is working fine on my side. Could you give me access to your repo, or reproduce a minimal example so I can reproduce?

Okay, I'll put together a project and send it tomorrow (laravel + nova + vue-advanced-chat).

TimurZur avatar Sep 22 '22 16:09 TimurZur

Maybe you can work with mock data, you can use this repo as a sandbox so you don't need to setup a whole project: https://github.com/antoine92190/vue-advanced-chat-sandbox

antoine92190 avatar Sep 22 '22 16:09 antoine92190

Maybe you can work with mock data, you can use this repo as a sandbox so you don't need to setup a whole project: https://github.com/antoine92190/vue-advanced-chat-sandbox

Maybe it has something to do exactly with laravel nova. Okay, thanks, I`ll check the sandbox)

TimurZur avatar Sep 22 '22 16:09 TimurZur

@TimurZur Did you have time to create a project or find a solution?

antoine92190 avatar Sep 30 '22 13:09 antoine92190

Closing this until I can reproduce the issue

antoine92190 avatar Oct 11 '22 11:10 antoine92190

I just wasted 2 hours dealing with this issue. The problem is not that room-id itself has to be a string, but rather that roomId inside your rooms needs to be a string!! Ridiculous...

vesper8 avatar Oct 12 '23 15:10 vesper8