@umituz/react-native-settings 4.23.73 → 4.23.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-settings",
3
- "version": "4.23.73",
3
+ "version": "4.23.74",
4
4
  "description": "Complete settings hub for React Native apps - consolidated package with settings, localization, about, legal, appearance, feedback, FAQs, rating, and gamification",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -2,6 +2,7 @@
2
2
  * Simple notification settings hook
3
3
  */
4
4
 
5
+ import { useEffect } from 'react';
5
6
  import { createStore } from '@umituz/react-native-design-system';
6
7
 
7
8
  interface NotificationSettingsState {
@@ -11,6 +12,8 @@ interface NotificationSettingsState {
11
12
 
12
13
  interface NotificationSettingsActions {
13
14
  setNotificationsEnabled: (value: boolean) => void;
15
+ setLoading: (value: boolean) => void;
16
+ initialize: () => void;
14
17
  }
15
18
 
16
19
  const useNotificationSettingsStore = createStore<NotificationSettingsState, NotificationSettingsActions>({
@@ -22,12 +25,19 @@ const useNotificationSettingsStore = createStore<NotificationSettingsState, Noti
22
25
  persist: true,
23
26
  actions: (set) => ({
24
27
  setNotificationsEnabled: (value: boolean) => set({ notificationsEnabled: value }),
28
+ setLoading: (value: boolean) => set({ isLoading: value }),
29
+ initialize: () => set({ isLoading: false }),
25
30
  }),
26
31
  });
27
32
 
28
33
  export const useNotificationSettings = () => {
29
34
  const store = useNotificationSettingsStore();
30
- const { notificationsEnabled, isLoading, setNotificationsEnabled } = store;
35
+ const { notificationsEnabled, isLoading, setNotificationsEnabled, initialize } = store;
36
+
37
+ // Initialize on first mount
38
+ useEffect(() => {
39
+ initialize();
40
+ }, [initialize]);
31
41
 
32
42
  return {
33
43
  notificationsEnabled,
@@ -16,16 +16,23 @@ export * from './types';
16
16
  * Provides simple access to notification manager
17
17
  */
18
18
  export class NotificationService {
19
- private static instance: NotificationService;
19
+ private static instance: NotificationService | null = null;
20
+ private isConfigured = false;
20
21
 
21
22
  readonly notifications = new NotificationManager();
22
23
 
23
24
  private constructor() {
24
- // Configure notification handler on initialization
25
- try {
26
- NotificationManager.configure();
27
- } catch (error) {
28
- console.error('[NotificationService] Failed to configure notification handler:', error);
25
+ // Configuration deferred to first use
26
+ }
27
+
28
+ private ensureConfigured() {
29
+ if (!this.isConfigured) {
30
+ try {
31
+ NotificationManager.configure();
32
+ this.isConfigured = true;
33
+ } catch (error) {
34
+ console.error('[NotificationService] Failed to configure notification handler:', error);
35
+ }
29
36
  }
30
37
  }
31
38
 
@@ -40,6 +47,7 @@ export class NotificationService {
40
47
  * Request notification permissions
41
48
  */
42
49
  async requestPermissions(): Promise<boolean> {
50
+ this.ensureConfigured();
43
51
  return await this.notifications.requestPermissions();
44
52
  }
45
53
 
@@ -47,8 +55,10 @@ export class NotificationService {
47
55
  * Check if permissions are granted
48
56
  */
49
57
  async hasPermissions(): Promise<boolean> {
58
+ this.ensureConfigured();
50
59
  return await this.notifications.hasPermissions();
51
60
  }
52
61
  }
53
62
 
63
+ // Lazy initialization - don't create on module load
54
64
  export const notificationService = NotificationService.getInstance();
@@ -3,18 +3,19 @@
3
3
  * Handles reminder CRUD operations with notification scheduling
4
4
  */
5
5
 
6
- import { useCallback } from 'react';
6
+ import { useCallback, useMemo } from 'react';
7
7
  import { useRemindersStore } from '../storage/RemindersStore';
8
8
  import { NotificationScheduler } from '../../../infrastructure/services/NotificationScheduler';
9
9
  import { generateReminderId } from '../../../infrastructure/utils/idGenerator';
10
10
  import { buildTrigger } from '../../../infrastructure/utils/triggerBuilder';
11
11
  import type { Reminder, CreateReminderInput, UpdateReminderInput } from '../../../infrastructure/services/types';
12
12
 
13
- const scheduler = new NotificationScheduler();
14
-
15
13
  export const useReminderActions = () => {
16
14
  const { addReminder, updateReminder, deleteReminder, toggleReminder: _toggleReminder } = useRemindersStore();
17
15
 
16
+ // Lazy initialization of scheduler
17
+ const scheduler = useMemo(() => new NotificationScheduler(), []);
18
+
18
19
  const createReminder = useCallback(async (input: CreateReminderInput): Promise<Reminder> => {
19
20
  const now = new Date().toISOString();
20
21
  const reminder: Reminder = {