refactor: more TS code

This commit is contained in:
Tristan Yang
2022-07-08 19:13:49 +08:00
parent 678b8515ca
commit 9f1b115c73
55 changed files with 421 additions and 338 deletions
@@ -2,9 +2,8 @@ import { useState } from "react";
import { initializeApp } from "firebase/app";
import { getToken, getMessaging } from "firebase/messaging";
import { firebaseConfig } from "../../../app/config";
const useDeviceToken = (vapidKey) => {
const [token, setToken] = useState(null);
const useDeviceToken = (vapidKey: string) => {
const [token, setToken] = useState<string | null>(null);
// https only
if (navigator.serviceWorker) {
const messaging = getMessaging(initializeApp(firebaseConfig));
@@ -17,7 +16,7 @@ const useDeviceToken = (vapidKey) => {
console.log("current token for client: ", currentToken);
setToken(currentToken);
// updateDeviceToken(currentToken)
// Perform any other neccessary action with the token
// Perform any other necessary action with the token
} else {
// Show permission request UI
console.log("No registration token available. Request permission to generate one.");