({ children }: { children: ReactNode })
| 126 | ); |
| 127 | |
| 128 | export const AppProvider = ({ children }: { children: ReactNode }) => { |
| 129 | const existingState = loadState(); |
| 130 | |
| 131 | const [auth, setAuth] = useState<AuthState>( |
| 132 | existingState.auth |
| 133 | ? { ...defaultAuth, ...existingState.auth } |
| 134 | : defaultAuth, |
| 135 | ); |
| 136 | |
| 137 | const [settings, setSettings] = useState<SettingsState>( |
| 138 | existingState.settings |
| 139 | ? { ...defaultSettings, ...existingState.settings } |
| 140 | : defaultSettings, |
| 141 | ); |
| 142 | |
| 143 | const lastAppliedOpenGitifyShortcutRef = useRef(settings.openGitifyShortcut); |
| 144 | const [shortcutRegistrationError, setShortcutRegistrationError] = useState< |
| 145 | string | null |
| 146 | >(null); |
| 147 | |
| 148 | const clearShortcutRegistrationError = useCallback(() => { |
| 149 | setShortcutRegistrationError(null); |
| 150 | }, []); |
| 151 | |
| 152 | const { setColorMode, setDayScheme, setNightScheme } = useTheme(); |
| 153 | |
| 154 | const { |
| 155 | status, |
| 156 | globalError, |
| 157 | |
| 158 | notifications, |
| 159 | notificationCount, |
| 160 | unreadNotificationCount, |
| 161 | hasNotifications, |
| 162 | hasUnreadNotifications, |
| 163 | |
| 164 | fetchNotifications, |
| 165 | removeAccountNotifications, |
| 166 | |
| 167 | markNotificationsAsRead, |
| 168 | markNotificationsAsDone, |
| 169 | unsubscribeNotification, |
| 170 | } = useNotifications(); |
| 171 | |
| 172 | const includeSearchTokens = useFiltersStore((s) => s.includeSearchTokens); |
| 173 | const excludeSearchTokens = useFiltersStore((s) => s.excludeSearchTokens); |
| 174 | const userTypes = useFiltersStore((s) => s.userTypes); |
| 175 | const subjectTypes = useFiltersStore((s) => s.subjectTypes); |
| 176 | const states = useFiltersStore((s) => s.states); |
| 177 | const reasons = useFiltersStore((s) => s.reasons); |
| 178 | |
| 179 | const persistAuth = useCallback( |
| 180 | (nextAuth: AuthState) => { |
| 181 | setAuth(nextAuth); |
| 182 | saveState({ auth: nextAuth, settings }); |
| 183 | }, |
| 184 | [settings], |
| 185 | ); |
nothing calls this directly
no test coverage detected