feat: Enhance editor functionality with autocorrect handling and text replacement
feat: Implement confirmation dialog for room sharing in ShareRoomPicker fix: Improve server input synchronization and blur handling in ServerPicker feat: Integrate UnifiedPush for background sync in Android, including pusher management refactor: Streamline Android share handling and file upload processes fix: Update notification handling to use Capacitor's local notifications API
This commit is contained in:
@@ -119,48 +119,6 @@ let notificationTapCallback: ((path: string) => void) | null = null;
|
||||
const ANDROID_NOTIFICATION_SMALL_ICON = 'ic_stat_paarrot';
|
||||
const ANDROID_NOTIFICATION_ICON_COLOR = '#FF8A00';
|
||||
|
||||
type CapacitorPermissionResult = {
|
||||
display: string;
|
||||
};
|
||||
|
||||
type CapacitorLocalNotificationChannel = {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
importance: number;
|
||||
sound: string;
|
||||
visibility: number;
|
||||
vibration: boolean;
|
||||
lights: boolean;
|
||||
};
|
||||
|
||||
type CapacitorLocalNotificationItem = {
|
||||
id: number;
|
||||
title: string;
|
||||
body: string;
|
||||
channelId?: string;
|
||||
smallIcon?: string;
|
||||
iconColor?: string;
|
||||
extra?: { path: string };
|
||||
};
|
||||
|
||||
type CapacitorLocalNotificationsApi = {
|
||||
addListener: (
|
||||
eventName: string,
|
||||
listenerFunc: (event: any) => void | Promise<void>
|
||||
) => Promise<unknown>;
|
||||
createChannel: (channel: CapacitorLocalNotificationChannel) => Promise<void>;
|
||||
checkPermissions: () => Promise<CapacitorPermissionResult>;
|
||||
requestPermissions: () => Promise<CapacitorPermissionResult>;
|
||||
schedule: (options: { notifications: CapacitorLocalNotificationItem[] }) => Promise<void>;
|
||||
};
|
||||
|
||||
const importCapacitorLocalNotifications = async (): Promise<CapacitorLocalNotificationsApi> => {
|
||||
const pkg = '@capacitor' + '/local-notifications';
|
||||
const mod = (await import(pkg)) as { LocalNotifications: CapacitorLocalNotificationsApi };
|
||||
return mod.LocalNotifications;
|
||||
};
|
||||
|
||||
/**
|
||||
* Bring the Tauri window to the front and focus it
|
||||
*/
|
||||
@@ -238,7 +196,7 @@ export const setupNotificationTapListener = async (onTap: (path: string) => void
|
||||
|
||||
if (isCapacitorNative()) {
|
||||
try {
|
||||
const LocalNotifications = await importCapacitorLocalNotifications();
|
||||
const { LocalNotifications } = await import('@capacitor/local-notifications');
|
||||
await LocalNotifications.addListener('localNotificationActionPerformed', async (event: any) => {
|
||||
await focusWindow();
|
||||
const path = event?.notification?.extra?.path;
|
||||
@@ -378,7 +336,7 @@ const ensureCapacitorNotificationChannel = async (): Promise<void> => {
|
||||
if (notificationChannelCreated || !isAndroid()) return;
|
||||
|
||||
try {
|
||||
const LocalNotifications = await importCapacitorLocalNotifications();
|
||||
const { LocalNotifications } = await import('@capacitor/local-notifications');
|
||||
await LocalNotifications.createChannel({
|
||||
id: 'messages',
|
||||
name: 'Messages',
|
||||
@@ -407,7 +365,7 @@ export const requestSystemNotificationPermission = async (): Promise<boolean> =>
|
||||
|
||||
if (isCapacitorNative()) {
|
||||
try {
|
||||
const LocalNotifications = await importCapacitorLocalNotifications();
|
||||
const { LocalNotifications } = await import('@capacitor/local-notifications');
|
||||
let perm = await LocalNotifications.checkPermissions();
|
||||
if (perm.display !== 'granted') {
|
||||
perm = await LocalNotifications.requestPermissions();
|
||||
@@ -427,7 +385,7 @@ export const requestSystemNotificationPermission = async (): Promise<boolean> =>
|
||||
export const getSystemNotificationPermissionState = async (): Promise<PermissionState> => {
|
||||
if (isCapacitorNative()) {
|
||||
try {
|
||||
const LocalNotifications = await importCapacitorLocalNotifications();
|
||||
const { LocalNotifications } = await import('@capacitor/local-notifications');
|
||||
const perm = await LocalNotifications.checkPermissions();
|
||||
return perm.display === 'granted' ? 'granted' : 'prompt';
|
||||
} catch (err) {
|
||||
@@ -513,7 +471,7 @@ export const sendNotification = async (options: {
|
||||
|
||||
if (isCapacitorNative()) {
|
||||
try {
|
||||
const LocalNotifications = await importCapacitorLocalNotifications();
|
||||
const { LocalNotifications } = await import('@capacitor/local-notifications');
|
||||
let perm = await LocalNotifications.checkPermissions();
|
||||
if (perm.display !== 'granted') {
|
||||
perm = await LocalNotifications.requestPermissions();
|
||||
|
||||
Reference in New Issue
Block a user