Fix daily notification plugin integration and bundling
- Change from dynamic to static imports for @timesafari/daily-notification-plugin - Remove plugin from external dependencies in vite.config.capacitor.mts to ensure proper bundling - Add debug logging to DailyNotificationSection for troubleshooting - Update package-lock.json with latest dependencies
This commit is contained in:
2
package-lock.json
generated
2
package-lock.json
generated
@@ -152,7 +152,7 @@
|
|||||||
},
|
},
|
||||||
"../daily-notification-plugin": {
|
"../daily-notification-plugin": {
|
||||||
"name": "@timesafari/daily-notification-plugin",
|
"name": "@timesafari/daily-notification-plugin",
|
||||||
"version": "1.0.1",
|
"version": "1.0.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|||||||
@@ -357,6 +357,10 @@ export default class DailyNotificationSection extends Vue {
|
|||||||
this.loading = true;
|
this.loading = true;
|
||||||
const platformService = PlatformServiceFactory.getInstance();
|
const platformService = PlatformServiceFactory.getInstance();
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
"[DailyNotificationSection] Checking notification support...",
|
||||||
|
);
|
||||||
|
|
||||||
// Check if notifications are supported on this platform
|
// Check if notifications are supported on this platform
|
||||||
// This also verifies plugin availability (returns null if plugin unavailable)
|
// This also verifies plugin availability (returns null if plugin unavailable)
|
||||||
const status = await platformService.getDailyNotificationStatus();
|
const status = await platformService.getDailyNotificationStatus();
|
||||||
@@ -364,11 +368,16 @@ export default class DailyNotificationSection extends Vue {
|
|||||||
// Notifications not supported or plugin unavailable - don't initialize
|
// Notifications not supported or plugin unavailable - don't initialize
|
||||||
this.notificationsSupported = false;
|
this.notificationsSupported = false;
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"[DailyNotificationSection] Notifications not supported or plugin unavailable",
|
"[DailyNotificationSection] Notifications not supported or plugin unavailable - section will be hidden",
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
"[DailyNotificationSection] Notifications supported, status:",
|
||||||
|
status,
|
||||||
|
);
|
||||||
|
|
||||||
this.notificationsSupported = true;
|
this.notificationsSupported = true;
|
||||||
this.notificationStatus = status;
|
this.notificationStatus = status;
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
CapacitorSQLite,
|
CapacitorSQLite,
|
||||||
DBSQLiteValues,
|
DBSQLiteValues,
|
||||||
} from "@capacitor-community/sqlite";
|
} from "@capacitor-community/sqlite";
|
||||||
|
import { DailyNotification } from "@timesafari/daily-notification-plugin";
|
||||||
|
|
||||||
import { runMigrations } from "@/db-sql/migration";
|
import { runMigrations } from "@/db-sql/migration";
|
||||||
import { QueryExecResult } from "@/interfaces/database";
|
import { QueryExecResult } from "@/interfaces/database";
|
||||||
@@ -1421,9 +1422,8 @@ export class CapacitorPlatformService
|
|||||||
*/
|
*/
|
||||||
async getDailyNotificationStatus(): Promise<NotificationStatus | null> {
|
async getDailyNotificationStatus(): Promise<NotificationStatus | null> {
|
||||||
try {
|
try {
|
||||||
// Dynamic import to avoid build issues if plugin unavailable
|
logger.debug(
|
||||||
const { DailyNotification } = await import(
|
"[CapacitorPlatformService] Getting daily notification status...",
|
||||||
"@timesafari/daily-notification-plugin"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const pluginStatus = await DailyNotification.getNotificationStatus();
|
const pluginStatus = await DailyNotification.getNotificationStatus();
|
||||||
@@ -1463,10 +1463,16 @@ export class CapacitorPlatformService
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const errorMessage =
|
||||||
|
error instanceof Error ? error.message : String(error);
|
||||||
logger.error(
|
logger.error(
|
||||||
"[CapacitorPlatformService] Failed to get notification status:",
|
"[CapacitorPlatformService] Failed to get notification status:",
|
||||||
|
errorMessage,
|
||||||
error,
|
error,
|
||||||
);
|
);
|
||||||
|
logger.warn(
|
||||||
|
"[CapacitorPlatformService] Daily notification section will be hidden - plugin may not be installed or available",
|
||||||
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1477,10 +1483,6 @@ export class CapacitorPlatformService
|
|||||||
*/
|
*/
|
||||||
async checkNotificationPermissions(): Promise<PermissionStatus | null> {
|
async checkNotificationPermissions(): Promise<PermissionStatus | null> {
|
||||||
try {
|
try {
|
||||||
const { DailyNotification } = await import(
|
|
||||||
"@timesafari/daily-notification-plugin"
|
|
||||||
);
|
|
||||||
|
|
||||||
const permissions = await DailyNotification.checkPermissions();
|
const permissions = await DailyNotification.checkPermissions();
|
||||||
|
|
||||||
// Log the raw permission state for debugging
|
// Log the raw permission state for debugging
|
||||||
@@ -1530,10 +1532,6 @@ export class CapacitorPlatformService
|
|||||||
*/
|
*/
|
||||||
async requestNotificationPermissions(): Promise<PermissionResult | null> {
|
async requestNotificationPermissions(): Promise<PermissionResult | null> {
|
||||||
try {
|
try {
|
||||||
const { DailyNotification } = await import(
|
|
||||||
"@timesafari/daily-notification-plugin"
|
|
||||||
);
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
`[CapacitorPlatformService] Requesting notification permissions...`,
|
`[CapacitorPlatformService] Requesting notification permissions...`,
|
||||||
);
|
);
|
||||||
@@ -1571,10 +1569,6 @@ export class CapacitorPlatformService
|
|||||||
*/
|
*/
|
||||||
async scheduleDailyNotification(options: ScheduleOptions): Promise<void> {
|
async scheduleDailyNotification(options: ScheduleOptions): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const { DailyNotification } = await import(
|
|
||||||
"@timesafari/daily-notification-plugin"
|
|
||||||
);
|
|
||||||
|
|
||||||
await DailyNotification.scheduleDailyNotification({
|
await DailyNotification.scheduleDailyNotification({
|
||||||
time: options.time,
|
time: options.time,
|
||||||
title: options.title,
|
title: options.title,
|
||||||
@@ -1601,10 +1595,6 @@ export class CapacitorPlatformService
|
|||||||
*/
|
*/
|
||||||
async cancelDailyNotification(): Promise<void> {
|
async cancelDailyNotification(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const { DailyNotification } = await import(
|
|
||||||
"@timesafari/daily-notification-plugin"
|
|
||||||
);
|
|
||||||
|
|
||||||
await DailyNotification.cancelAllNotifications();
|
await DailyNotification.cancelAllNotifications();
|
||||||
|
|
||||||
logger.info("[CapacitorPlatformService] Cancelled daily notification");
|
logger.info("[CapacitorPlatformService] Cancelled daily notification");
|
||||||
@@ -1670,10 +1660,6 @@ export class CapacitorPlatformService
|
|||||||
config: NativeFetcherConfig,
|
config: NativeFetcherConfig,
|
||||||
): Promise<void | null> {
|
): Promise<void | null> {
|
||||||
try {
|
try {
|
||||||
const { DailyNotification } = await import(
|
|
||||||
"@timesafari/daily-notification-plugin"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 1: Get activeDid from database (single source of truth)
|
// Step 1: Get activeDid from database (single source of truth)
|
||||||
// This ensures we're using the correct user identity for authentication
|
// This ensures we're using the correct user identity for authentication
|
||||||
const activeIdentity = await this.getActiveIdentity();
|
const activeIdentity = await this.getActiveIdentity();
|
||||||
@@ -1740,10 +1726,6 @@ export class CapacitorPlatformService
|
|||||||
*/
|
*/
|
||||||
async updateStarredPlans(plans: { planIds: string[] }): Promise<void | null> {
|
async updateStarredPlans(plans: { planIds: string[] }): Promise<void | null> {
|
||||||
try {
|
try {
|
||||||
const { DailyNotification } = await import(
|
|
||||||
"@timesafari/daily-notification-plugin"
|
|
||||||
);
|
|
||||||
|
|
||||||
await DailyNotification.updateStarredPlans({
|
await DailyNotification.updateStarredPlans({
|
||||||
planIds: plans.planIds,
|
planIds: plans.planIds,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,10 +10,8 @@ export default defineConfig(async () => {
|
|||||||
...baseConfig.build,
|
...baseConfig.build,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
...baseConfig.build?.rollupOptions,
|
...baseConfig.build?.rollupOptions,
|
||||||
// Externalize Capacitor plugins that are bundled natively
|
// Note: @timesafari/daily-notification-plugin is NOT externalized
|
||||||
external: [
|
// because it needs to be bundled for dynamic imports to work in Capacitor WebView
|
||||||
"@timesafari/daily-notification-plugin"
|
|
||||||
],
|
|
||||||
output: {
|
output: {
|
||||||
...baseConfig.build?.rollupOptions?.output,
|
...baseConfig.build?.rollupOptions?.output,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user