cherrypicks
This commit is contained in:
@ -70,18 +70,6 @@ function PwaManager() {
|
||||
}
|
||||
};
|
||||
|
||||
// Utility function for converting base64 string to Uint8Array
|
||||
const base64ToUint8Array = base64 => {
|
||||
const padding = '='.repeat((4 - (base64.length % 4)) % 4);
|
||||
const b64 = (base64 + padding).replace(/-/g, '+').replace(/_/g, '/');
|
||||
const rawData = window.atob(b64);
|
||||
const outputArray = new Uint8Array(rawData.length);
|
||||
for (let i = 0; i < rawData.length; ++i) {
|
||||
outputArray[i] = rawData.charCodeAt(i);
|
||||
}
|
||||
return outputArray;
|
||||
};
|
||||
|
||||
const subscribeToNotifications = async (e) => {
|
||||
|
||||
try {
|
||||
@ -108,7 +96,7 @@ function PwaManager() {
|
||||
}
|
||||
const sub = await registration.pushManager.subscribe({
|
||||
userVisibleOnly: true,
|
||||
applicationServerKey: base64ToUint8Array(vapidPublicKey)
|
||||
applicationServerKey: common.base64ToUint8Array(vapidPublicKey)
|
||||
});
|
||||
// Call your API to save subscription data on server
|
||||
if (session.user?.id != null) {
|
||||
|
@ -912,6 +912,17 @@ function adjustDateForDST(date, timezone) {
|
||||
}
|
||||
exports.adjustDateForDST = adjustDateForDST;
|
||||
|
||||
|
||||
export function base64ToUint8Array(base64) {
|
||||
const padding = '='.repeat((4 - (base64.length % 4)) % 4);
|
||||
const b64 = (base64 + padding).replace(/-/g, '+').replace(/_/g, '/');
|
||||
const rawData = window.atob(b64);
|
||||
const outputArray = new Uint8Array(rawData.length);
|
||||
for (let i = 0; i < rawData.length; ++i) {
|
||||
outputArray[i] = rawData.charCodeAt(i);
|
||||
}
|
||||
return outputArray;
|
||||
}
|
||||
// exports.getInitials = function (names) {
|
||||
// const parts = names.split(' '); // Split the full name into parts
|
||||
// if (parts.length === 0) {
|
||||
|
Reference in New Issue
Block a user