Skip to content

A self-hosted media server and file management system

types

aminnausin6eccb17fc359
diff --git a/app/Events/TaskEnded.php b/app/Events/TaskEnded.php
index 9641aab8..4134a0bd 100644
--- a/app/Events/TaskEnded.php
+++ b/app/Events/TaskEnded.php
@@ -4,7 +4,6 @@ namespace App\Events;
use App\Http\Resources\TasksResource;
use App\Models\Task;
-use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
// use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
@@ -17,6 +16,7 @@ class TaskEnded implements ShouldBroadcast {
use Dispatchable, InteractsWithSockets, SerializesModels;
public TasksResource $resource;
+
/**
* Create a new event instance.
*/
@@ -32,6 +32,7 @@ class TaskEnded implements ShouldBroadcast {
public function broadcastOn(): array {
try {
$this->resource = new TasksResource($this->task);
+
// code...
return [
new PrivateChannel("tasks.{$this->task->user_id}"),
diff --git a/resources/js/layouts/LayoutBase.vue b/resources/js/layouts/LayoutBase.vue
index a332265a..0c3d3300 100755
--- a/resources/js/layouts/LayoutBase.vue
+++ b/resources/js/layouts/LayoutBase.vue
@@ -2,24 +2,25 @@
import { useAppStore } from '@/stores/AppStore';
import { storeToRefs } from 'pinia';
import { toast } from '@/service/toaster/toastService';
-import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
+import { onBeforeUnmount, onMounted, ref, watch, type Ref } from 'vue';
import NavBar from '@/components/panels/NavBar.vue';
import { useAuthStore } from '@/stores/AuthStore';
+import type { UserResource } from '@/types/resources';
const appStore = useAppStore();
const authStore = useAuthStore();
-const { userData } = storeToRefs(authStore);
+const { userData } = storeToRefs(authStore) as { userData: Ref<UserResource> };
const { selectedSideBar, sideBarTarget, scrollLock } = storeToRefs(appStore);
const scrollBody = ref(null);
const userInit = ref(false);
function handleEvent() {
- // @ts-ignore
if (!userData.value?.id || userInit.value) return;
+
userInit.value = true;
- // @ts-ignore
+
window.Echo.private(`tasks.${userData.value.id}`).listen('TaskEnded', (event: any) => {
console.log(event);
diff --git a/resources/js/stores/AuthStore.ts b/resources/js/stores/AuthStore.ts
index 523f763a..fb14ab42 100644
--- a/resources/js/stores/AuthStore.ts
+++ b/resources/js/stores/AuthStore.ts
@@ -1,12 +1,13 @@
+import type { UserResource } from '@/types/resources';
+
import { authenticate } from '@/service/authAPI';
import { defineStore } from 'pinia';
import { AxiosError } from 'axios';
-import { ref } from 'vue';
import { toast } from '@/service/toaster/toastService';
+import { ref } from 'vue';
export const useAuthStore = defineStore('Auth', () => {
- const userData = ref(null);
- const user = ref(null);
+ const userData = ref<null | UserResource>(null);
const auth = async () => {
/*
@@ -49,7 +50,6 @@ export const useAuthStore = defineStore('Auth', () => {
};
return {
- user,
userData,
auth,
clearAuthState,
diff --git a/routes/channels.php b/routes/channels.php
index 5c240c2f..d44f6a3b 100644
--- a/routes/channels.php
+++ b/routes/channels.php
@@ -6,5 +6,4 @@ Broadcast::channel('tasks.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
-Broadcast::channel('dashboard', function () {
-});
+Broadcast::channel('dashboard', function () {});