@umituz/react-native-notifications 1.3.3 → 1.3.4

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-notifications",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Offline-first local notifications system for React Native apps using expo-notifications",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -25,6 +25,7 @@ interface RemindersState {
25
25
  }
26
26
 
27
27
  interface RemindersActions {
28
+ initialize: () => Promise<void>;
28
29
  loadReminders: () => Promise<void>;
29
30
  addReminder: (reminder: Reminder) => Promise<void>;
30
31
  updateReminder: (id: string, updates: Partial<Reminder>) => Promise<void>;
@@ -44,8 +45,8 @@ type RemindersStore = RemindersState & RemindersActions;
44
45
 
45
46
  const DEFAULT_PREFERENCES: NotificationPreferences = {
46
47
  enabled: false,
47
- sound: false,
48
- vibration: false,
48
+ sound: true,
49
+ vibration: true,
49
50
  quietHours: {
50
51
  enabled: false,
51
52
  startHour: 22,
@@ -65,13 +66,34 @@ export const useRemindersStore = create<RemindersStore>((set, get) => ({
65
66
  isLoading: true,
66
67
  isInitialized: false,
67
68
 
69
+ initialize: async () => {
70
+ try {
71
+ const [remindersData, preferencesData] = await Promise.all([
72
+ AsyncStorage.getItem(STORAGE_KEYS.REMINDERS),
73
+ AsyncStorage.getItem(STORAGE_KEYS.PREFERENCES)
74
+ ]);
75
+
76
+ const reminders = remindersData ? JSON.parse(remindersData) : [];
77
+ let preferences = DEFAULT_PREFERENCES;
78
+
79
+ if (preferencesData) {
80
+ const parsed = JSON.parse(preferencesData);
81
+ preferences = { ...DEFAULT_PREFERENCES, ...parsed };
82
+ }
83
+
84
+ set({ reminders, preferences, isLoading: false, isInitialized: true });
85
+ } catch {
86
+ set({ reminders: [], preferences: DEFAULT_PREFERENCES, isLoading: false, isInitialized: true });
87
+ }
88
+ },
89
+
68
90
  loadReminders: async () => {
69
91
  try {
70
92
  const data = await AsyncStorage.getItem(STORAGE_KEYS.REMINDERS);
71
93
  const reminders = data ? JSON.parse(data) : [];
72
- set({ reminders, isLoading: false, isInitialized: true });
94
+ set({ reminders });
73
95
  } catch {
74
- set({ reminders: [], isLoading: false, isInitialized: true });
96
+ set({ reminders: [] });
75
97
  }
76
98
  },
77
99
 
@@ -34,11 +34,11 @@ export const NotificationSettingsScreen: React.FC<NotificationSettingsScreenProp
34
34
  const preferences = useNotificationPreferences();
35
35
  const quietHours = useQuietHours();
36
36
  const reminders = useReminders();
37
- const { loadPreferences, updatePreferences, updateQuietHours, isLoading } = useRemindersStore();
37
+ const { initialize, updatePreferences, updateQuietHours, isLoading } = useRemindersStore();
38
38
 
39
39
  useEffect(() => {
40
- loadPreferences();
41
- }, [loadPreferences]);
40
+ initialize();
41
+ }, [initialize]);
42
42
 
43
43
  const handleMasterToggle = useCallback(async (value: boolean) => {
44
44
  if (value) {
@@ -11,7 +11,7 @@ import { AtomicIcon, AtomicCard, AtomicText, ScreenLayout, STATIC_TOKENS } from
11
11
  import { Switch } from 'react-native';
12
12
  import { useAppDesignTokens } from '@umituz/react-native-design-system-theme';
13
13
  import { useNotificationSettings } from '../../infrastructure/hooks/useNotificationSettings';
14
- import type { DesignTokens, IconColor } from '@umituz/react-native-design-system';
14
+ import type { DesignTokens } from '@umituz/react-native-design-system';
15
15
 
16
16
  export interface NotificationsScreenProps {
17
17
  translations: {
@@ -20,7 +20,7 @@ export interface NotificationsScreenProps {
20
20
  loadingText?: string;
21
21
  };
22
22
  iconName?: string;
23
- iconColor?: IconColor;
23
+ iconColor?: string;
24
24
  testID?: string;
25
25
  }
26
26
 
@@ -39,8 +39,8 @@ export const NotificationsScreen: React.FC<NotificationsScreenProps> = ({
39
39
  <ScreenLayout testID={testID}>
40
40
  <View style={styles.loadingContainer}>
41
41
  <ActivityIndicator size="large" color={tokens.colors.primary} />
42
- <AtomicText
43
- type="bodyMedium"
42
+ <AtomicText
43
+ type="bodyMedium"
44
44
  style={{ color: tokens.colors.textSecondary, marginTop: STATIC_TOKENS.spacing.md }}
45
45
  >
46
46
  {translations.loadingText || 'Loading...'}