Skip to content

Commit

Permalink
Update: Separate Vue Chat from Global JS.
Browse files Browse the repository at this point in the history
  • Loading branch information
clandestine8 committed Feb 10, 2024
1 parent fc92660 commit ebcb022
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
15 changes: 0 additions & 15 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ if (token) {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
import Vue from 'vue';
import chatbox from './components/chat/Chatbox';

if (document.getElementById('vue')) {
new Vue({
el: '#vue',
components: { chatbox: chatbox },
});
}

/*
* NPM Packages
*/
Expand Down
1 change: 1 addition & 0 deletions resources/js/components/chat/Chatbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ import ChatMessages from './ChatMessages';
import ChatForm from './ChatForm';
import ChatUserList from './ChatUserList';
import ChatstatusesDropdown from "./ChatstatusesDropdown.vue";
import axios from "axios"
export default {
props: {
Expand Down
8 changes: 8 additions & 0 deletions resources/js/unit3d/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* allows your team to easily build robust real-time web applications.
*/
import Echo from 'laravel-echo';
import Vue from 'vue';
import chatbox from '../components/chat/Chatbox';

window.io = require('socket.io-client');

Expand All @@ -15,3 +17,9 @@ window.Echo = new Echo({
transports: ['websocket'],
enabledTransports: ['wss'],
});

new Vue({
el: '#vue',
components: { chatbox: chatbox },
});

4 changes: 1 addition & 3 deletions resources/views/home/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

@section('main')
@include('blocks.news')

@if (! auth()->user()->chat_hidden)
<div id="vue">
<script src="{{ mix('js/chat.js') }}" crossorigin="anonymous"></script>
@include('blocks.chat')
</div>
<script src="{{ mix('js/chat.js') }}" crossorigin="anonymous"></script>
@endif

@include('blocks.featured')
@livewire('random-media')
@include('blocks.poll')
Expand Down

0 comments on commit ebcb022

Please sign in to comment.