Skip to content

Commit e583913

Browse files
committed
Removal of changes
1 parent 393355a commit e583913

File tree

12 files changed

+73
-386
lines changed

12 files changed

+73
-386
lines changed

CHANGELOG.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
- Added visual indicators showing whether Slack webhook is configured
2424
- Added visual indicators showing whether Email notifications are configured
2525
- Improved user experience with clear configuration status
26-
- Server-side storage for user settings:
27-
- Added user_settings table to store user-specific settings
28-
- Created API endpoints for retrieving and updating user settings
29-
- Implemented server-side storage for session timeout settings
30-
- Ensured settings persistence across different browsers and devices
3126

3227
### Fixed
3328
- Fixed automatic logout not working correctly on mobile devices:
@@ -37,12 +32,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3732
- Added localStorage-based timestamp tracking for more reliable inactivity detection
3833
- Improved logging for better debugging of activity detection
3934
- Updated tests to cover new mobile-specific functionality
40-
- Fixed settings not being saved properly across different browsers and devices:
41-
- Implemented server-side storage for session timeout settings
42-
- Improved synchronization logic for notification settings
43-
- Added explicit save functionality to ensure settings are properly persisted
44-
- Prioritized server settings over localStorage settings
45-
- Enhanced error handling for failed server requests
4635

4736
### Improved
4837
- Enhanced documentation organization:
@@ -53,10 +42,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5342
- Added dedicated tab for application information
5443
- Improved navigation with clear tab labels and icons
5544
- Added status badges to notification settings for better visibility
56-
- Improved settings synchronization:
57-
- Better handling of settings loading from server
58-
- More reliable saving of settings to server
59-
- Clearer feedback when settings are saved successfully
6045

6146
## [1.8.2] - 2025-02-28
6247

client/src/components/notifications/NotificationSettings.jsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from 'react';
2+
import axios from 'axios';
23
import { FiBell, FiSave, FiChevronDown, FiChevronRight } from 'react-icons/fi';
34
import { useSettings } from '../../context/SettingsContext';
45
import DiscordNotificationSettings from './DiscordNotificationSettings';
@@ -15,7 +16,7 @@ import NotificationHistory from './NotificationHistory';
1516
* sections to reduce visual clutter and improve user experience.
1617
*/
1718
const NotificationSettings = ({ setError, setSuccess }) => {
18-
const { settings, updateSetting, saveNotificationSettings } = useSettings();
19+
const { settings, updateSetting } = useSettings();
1920
const [isSaving, setIsSaving] = useState(false);
2021
const [expandedSections, setExpandedSections] = useState({
2122
discord: false,
@@ -37,14 +38,27 @@ const NotificationSettings = ({ setError, setSuccess }) => {
3738
const handleSaveSettings = async () => {
3839
setIsSaving(true);
3940
try {
40-
// Use the context function to save settings to server
41-
await saveNotificationSettings();
41+
// Convert client settings format to server format
42+
const serverSettings = {
43+
discord_webhook_url: settings.discordWebhookUrl,
44+
slack_webhook_url: settings.slackWebhookUrl,
45+
notifications_enabled: settings.notifications,
46+
battery_notifications: settings.batteryNotifications,
47+
low_battery_notifications: settings.lowBatteryNotifications,
48+
email_notifications: settings.emailNotifications,
49+
email_recipients: settings.emailRecipients
50+
};
51+
52+
// Send settings to server
53+
const response = await axios.post('/api/notifications/settings', serverSettings);
4254

4355
setSuccess('Notification settings saved successfully');
4456
setTimeout(() => setSuccess(null), 3000);
57+
console.log('Saved notification settings to server:', response.data);
4558
} catch (err) {
4659
setError(err.response?.data?.message || 'Failed to save notification settings');
4760
setTimeout(() => setError(null), 5000);
61+
console.error('Error saving settings to server:', err);
4862
} finally {
4963
setIsSaving(false);
5064
}

client/src/components/settings/PollingSettings.jsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
1-
import React, { useState } from 'react';
1+
import React from 'react';
22
import { FiSave, FiClock } from 'react-icons/fi';
33
import { useSettings } from '../../context/SettingsContext';
44

55
const PollingSettings = ({ pollInterval, setPollInterval, setSuccess }) => {
6-
const { settings, updateSetting, saveUserSettings } = useSettings();
7-
const [isSaving, setIsSaving] = useState(false);
6+
const { settings, updateSetting } = useSettings();
87

9-
const savePollInterval = async () => {
10-
setIsSaving(true);
11-
try {
12-
// Update local setting
13-
updateSetting('pollInterval', pollInterval);
14-
15-
// Save to server
16-
await saveUserSettings();
17-
18-
setSuccess('Poll interval updated successfully and saved to server');
19-
setTimeout(() => setSuccess(null), 3000);
20-
} catch (error) {
21-
console.error('Error saving poll interval to server:', error);
22-
} finally {
23-
setIsSaving(false);
24-
}
8+
const savePollInterval = () => {
9+
updateSetting('pollInterval', pollInterval);
10+
setSuccess('Poll interval updated successfully');
11+
setTimeout(() => setSuccess(null), 3000);
2512
};
2613

2714
return (
@@ -52,11 +39,10 @@ const PollingSettings = ({ pollInterval, setPollInterval, setSuccess }) => {
5239
<span className="text-sm font-medium text-gray-900 dark:text-white">{pollInterval}s</span>
5340
<button
5441
onClick={savePollInterval}
55-
disabled={isSaving}
56-
className="inline-flex items-center px-3 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed"
42+
className="inline-flex items-center px-3 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500"
5743
>
5844
<FiSave className="mr-2 -ml-1 h-4 w-4" />
59-
{isSaving ? 'Saving...' : 'Save'}
45+
Save
6046
</button>
6147
</div>
6248
</div>

client/src/components/settings/ResetSettings.jsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
import React, { useState } from 'react';
1+
import React from 'react';
22
import { FiRefreshCw } from 'react-icons/fi';
33
import { useSettings } from '../../context/SettingsContext';
44

55
const ResetSettings = ({ setPollInterval, setSuccess }) => {
6-
const { resetSettings, saveAllSettings } = useSettings();
7-
const [isResetting, setIsResetting] = useState(false);
6+
const { resetSettings } = useSettings();
87

9-
const handleResetSettings = async () => {
10-
setIsResetting(true);
11-
try {
12-
// Reset local settings
13-
resetSettings();
14-
setPollInterval(30); // Default value
15-
16-
// Save reset settings to server
17-
await saveAllSettings();
18-
19-
setSuccess('Settings reset to defaults and saved to server');
20-
setTimeout(() => setSuccess(null), 3000);
21-
} catch (error) {
22-
console.error('Error saving reset settings to server:', error);
23-
} finally {
24-
setIsResetting(false);
25-
}
8+
const handleResetSettings = () => {
9+
resetSettings();
10+
setPollInterval(30); // Default value
11+
setSuccess('Settings reset to defaults');
12+
setTimeout(() => setSuccess(null), 3000);
2613
};
2714

2815
return (
@@ -34,11 +21,10 @@ const ResetSettings = ({ setPollInterval, setSuccess }) => {
3421
<div className="mt-2">
3522
<button
3623
onClick={handleResetSettings}
37-
disabled={isResetting}
38-
className="inline-flex items-center px-3 py-2 border border-gray-300 dark:border-gray-600 shadow-sm text-sm font-medium rounded-md text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed"
24+
className="inline-flex items-center px-3 py-2 border border-gray-300 dark:border-gray-600 shadow-sm text-sm font-medium rounded-md text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500"
3925
>
4026
<FiRefreshCw className="mr-2 -ml-1 h-4 w-4" />
41-
{isResetting ? 'Resetting...' : 'Reset to Defaults'}
27+
Reset to Defaults
4228
</button>
4329
</div>
4430
</div>

client/src/context/AuthContext.jsx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { createContext, useContext, useState, useEffect, useCallback } from 'react';
22
import useInactivityTimer from '../hooks/useInactivityTimer';
3-
import { authAPI, userSettingsAPI } from '../services/api';
3+
import { authAPI } from '../services/api';
44
import axios from 'axios'; // Still needed for setting default headers
55

66
const AuthContext = createContext();
@@ -11,7 +11,7 @@ export const AuthProvider = ({ children }) => {
1111
const [user, setUser] = useState(null);
1212
const [loading, setLoading] = useState(true);
1313
const [error, setError] = useState(null);
14-
const [inactivityTimeout, setInactivityTimeout] = useState(30); // Default 30 minutes, will be updated from server
14+
const [inactivityTimeout, setInactivityTimeout] = useState(30); // Default 30 minutes
1515

1616
// Logout user
1717
const logout = useCallback(() => {
@@ -29,17 +29,6 @@ export const AuthProvider = ({ children }) => {
2929
if (storedUser && token) {
3030
setUser(JSON.parse(storedUser));
3131
axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
32-
33-
// Load user settings from server
34-
userSettingsAPI.getSettings()
35-
.then(response => {
36-
if (response.data && response.data.inactivity_timeout) {
37-
setInactivityTimeout(response.data.inactivity_timeout);
38-
}
39-
})
40-
.catch(error => {
41-
console.error('Error loading user settings:', error);
42-
});
4332
}
4433

4534
setLoading(false);
@@ -55,15 +44,6 @@ export const AuthProvider = ({ children }) => {
5544
// Update inactivity timeout
5645
const updateInactivityTimeout = useCallback((minutes) => {
5746
setInactivityTimeout(minutes);
58-
59-
// Save to server
60-
userSettingsAPI.updateSettings({ inactivity_timeout: minutes })
61-
.then(response => {
62-
console.log('Inactivity timeout saved to server:', response.data);
63-
})
64-
.catch(error => {
65-
console.error('Error saving inactivity timeout to server:', error);
66-
});
6747
}, []);
6848

6949
// Check if this is the first time setup

0 commit comments

Comments
 (0)