diff --git a/resources/js/Layouts/MainLayout.vue b/resources/js/Layouts/MainLayout.vue
index 53484b0..e72fb9e 100644
--- a/resources/js/Layouts/MainLayout.vue
+++ b/resources/js/Layouts/MainLayout.vue
@@ -4,11 +4,14 @@ import MainFooter from "@/Components/FlightsGoneBy/MainFooter.vue";
import Radar from "@/Components/FlightsGoneBy/Radar.vue";
import StatusNotifications from "@/Components/FlightsGoneBy/StatusNotifications.vue";
import ToastNotifications from "@/Components/FlightsGoneBy/ToastNotifications.vue";
-import { router } from "@inertiajs/vue3";
+import {router, usePage} from "@inertiajs/vue3";
import { ref } from "vue";
-
+import NotificationListener from "@/Components/FlightsGoneBy/NotificationListener.vue";
+import {SharedProps} from "@/Types/types";
const transitionKey = ref(0);
+const page = usePage().props
+
router.on('success', () => {
transitionKey.value++;
});
@@ -25,6 +28,7 @@ router.on('success', () => {
+
diff --git a/resources/js/Types/echo.d.ts b/resources/js/Types/echo.d.ts
new file mode 100644
index 0000000..26a792a
--- /dev/null
+++ b/resources/js/Types/echo.d.ts
@@ -0,0 +1,8 @@
+import Echo from 'laravel-echo';
+
+declare global {
+ interface Window {
+ Echo: Echo<'reverb'>;
+ Pusher: unknown;
+ }
+}
diff --git a/resources/js/app.ts b/resources/js/app.ts
index 7045432..d6766c3 100644
--- a/resources/js/app.ts
+++ b/resources/js/app.ts
@@ -6,9 +6,15 @@ import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { ZiggyVue } from '../../vendor/tightenco/ziggy';
import { createApp, h, DefineComponent } from 'vue';
import vuetify from './plugins/vuetify';
+import { configureEcho } from '@laravel/echo-vue';
+const pinia = createPinia();
+configureEcho({
+ broadcaster: 'reverb',
+});
import '@mdi/font/css/materialdesignicons.css'
import 'flag-icons/css/flag-icons.min.css'
import VueApexCharts from 'vue3-apexcharts'
+import {createPinia} from "pinia";
const appName = document.querySelector('meta[name="app-name"]')?.getAttribute('content') || 'Laravel';
@@ -25,6 +31,7 @@ createInertiaApp({
.use(plugin)
.use(ZiggyVue)
.use(vuetify)
+ .use(pinia)
.use(VueApexCharts)
.mount(el);
},
diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js
index 5f1390b..7397d90 100644
--- a/resources/js/bootstrap.js
+++ b/resources/js/bootstrap.js
@@ -2,3 +2,17 @@ import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
+import Echo from 'laravel-echo';
+import Pusher from 'pusher-js';
+
+window.Pusher = Pusher;
+
+window.Echo = new Echo({
+ broadcaster: 'reverb',
+ key: import.meta.env.VITE_REVERB_APP_KEY,
+ wsHost: import.meta.env.VITE_REVERB_HOST,
+ wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
+ wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
+ forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
+ enabledTransports: ['ws', 'wss'],
+});
diff --git a/resources/js/stores/notificationStore.ts b/resources/js/stores/notificationStore.ts
new file mode 100644
index 0000000..f6dcdd6
--- /dev/null
+++ b/resources/js/stores/notificationStore.ts
@@ -0,0 +1,33 @@
+import { defineStore } from 'pinia';
+import { ref } from 'vue';
+import { Notification } from '@/Types/types';
+import axios from 'axios';
+
+export const useNotificationStore = defineStore('notifications', () => {
+ const toasts = ref([]);
+ const unreadCount = ref(0);
+ const latestNotification = ref(null);
+ const achievementSound = new Audio('/sounds/seatBelt.wav');
+
+ function push(notification: Notification) {
+ toasts.value.push(notification);
+ latestNotification.value = notification;
+ unreadCount.value++;
+
+ if (notification.is_achievement) {
+ achievementSound.play().catch(() => {});
+ }
+ }
+
+ async function dismiss(notification: Notification) {
+ toasts.value = toasts.value.filter(n => n.id !== notification.id);
+ await axios.patch(`/notifications/${notification.id}/read`);
+ unreadCount.value = Math.max(0, unreadCount.value - 1);
+ }
+
+ function setInitialUnreadCount(count: number) {
+ unreadCount.value = count;
+ }
+
+ return { toasts, unreadCount, latestNotification, push, dismiss, setInitialUnreadCount};
+});
diff --git a/routes/channels.php b/routes/channels.php
new file mode 100644
index 0000000..df2ad28
--- /dev/null
+++ b/routes/channels.php
@@ -0,0 +1,7 @@
+id === (int) $id;
+});
diff --git a/routes/console.php b/routes/console.php
index eed92cd..3855bd1 100644
--- a/routes/console.php
+++ b/routes/console.php
@@ -4,5 +4,6 @@ use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
Schedule::command('app:update-alliances')->dailyAt('09:00')->runInBackground();
-Schedule::command('app:update-departed-flights')->hourly()->runInBackground();
+Schedule::command('app:update-arrived-flights')->hourly()->runInBackground();
+Schedule::command('app:update-departed-flights')->everyMinute()->runInBackground();
Schedule::command('app:flight-feed-update')->everyMinute()->runInBackground();