new announcements page, adding searchbar and message input.
This commit is contained in:
31
src/index.js
31
src/index.js
@@ -1,3 +1,6 @@
|
||||
import { PushNotifications } from '@capacitor/push-notifications';
|
||||
|
||||
import server from './_/code/bridge/server.js'
|
||||
import Socket from "/_/code/ws/Socket.js"
|
||||
import "./Home/Home.js"
|
||||
import "./Home/AuthPage/AuthPage.js"
|
||||
@@ -12,7 +15,7 @@ let Global = class {
|
||||
|
||||
currentApp() {
|
||||
const pathname = window.location.pathname;
|
||||
const segments = pathname.split('/').filter(Boolean);
|
||||
const segments = pathname.split('/').filter(Boolean)
|
||||
const secondSegment = segments[1] || ""
|
||||
const capitalized = secondSegment.charAt(0).toUpperCase() + secondSegment.slice(1);
|
||||
return capitalized
|
||||
@@ -154,7 +157,33 @@ let Global = class {
|
||||
location.reload()
|
||||
}
|
||||
|
||||
async setupPushNotifications() {
|
||||
const permission = await PushNotifications.requestPermissions();
|
||||
|
||||
if (permission.receive === 'granted') {
|
||||
await PushNotifications.register();
|
||||
}
|
||||
|
||||
PushNotifications.addListener('registration', async (token) => {
|
||||
console.log('Device token:', token.value)
|
||||
const stored = localStorage.getItem('deviceToken')
|
||||
if (stored === token.value) return;
|
||||
|
||||
await server.updatePushToken(token.value)
|
||||
localStorage.setItem('deviceToken', token.value)
|
||||
});
|
||||
|
||||
PushNotifications.addListener('registrationError', (error) => {
|
||||
console.error('Registration error:', error)
|
||||
});
|
||||
|
||||
PushNotifications.addListener('pushNotificationReceived', (notification) => {
|
||||
console.log('Notification received:', notification)
|
||||
});
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.setupPushNotifications()
|
||||
window.addEventListener("navigate", this.onNavigate)
|
||||
|
||||
this.getProfile().then(async (status) => {
|
||||
|
||||
Reference in New Issue
Block a user