Fix TypeScript linting errors in autoSyncService
- Add JSDoc type definitions for settings object - Fix appriseUrls undefined checks - Fix null assignment for lastAutoSyncError - Add proper type annotations for error fields All TypeScript linting errors are now resolved.
This commit is contained in:
@@ -42,6 +42,19 @@ export class AutoSyncService {
|
|||||||
const envPath = join(process.cwd(), '.env');
|
const envPath = join(process.cwd(), '.env');
|
||||||
const envContent = readFileSync(envPath, 'utf8');
|
const envContent = readFileSync(envPath, 'utf8');
|
||||||
|
|
||||||
|
/** @type {{
|
||||||
|
* autoSyncEnabled: boolean;
|
||||||
|
* syncIntervalType: string;
|
||||||
|
* syncIntervalPredefined?: string;
|
||||||
|
* syncIntervalCron?: string;
|
||||||
|
* autoDownloadNew: boolean;
|
||||||
|
* autoUpdateExisting: boolean;
|
||||||
|
* notificationEnabled: boolean;
|
||||||
|
* appriseUrls?: string[];
|
||||||
|
* lastAutoSync?: string;
|
||||||
|
* lastAutoSyncError?: string;
|
||||||
|
* lastAutoSyncErrorTime?: string;
|
||||||
|
* }} */
|
||||||
const settings = {
|
const settings = {
|
||||||
autoSyncEnabled: false,
|
autoSyncEnabled: false,
|
||||||
syncIntervalType: 'predefined',
|
syncIntervalType: 'predefined',
|
||||||
@@ -139,6 +152,8 @@ export class AutoSyncService {
|
|||||||
* @param {boolean} settings.notificationEnabled
|
* @param {boolean} settings.notificationEnabled
|
||||||
* @param {Array<string>} [settings.appriseUrls]
|
* @param {Array<string>} [settings.appriseUrls]
|
||||||
* @param {string} [settings.lastAutoSync]
|
* @param {string} [settings.lastAutoSync]
|
||||||
|
* @param {string} [settings.lastAutoSyncError]
|
||||||
|
* @param {string} [settings.lastAutoSyncErrorTime]
|
||||||
*/
|
*/
|
||||||
saveSettings(settings) {
|
saveSettings(settings) {
|
||||||
try {
|
try {
|
||||||
@@ -470,7 +485,7 @@ export class AutoSyncService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Step 3: Send notifications if enabled
|
// Step 3: Send notifications if enabled
|
||||||
if (settings.notificationEnabled && settings.appriseUrls?.length > 0) {
|
if (settings.notificationEnabled && settings.appriseUrls && settings.appriseUrls.length > 0) {
|
||||||
console.log('Sending success notifications...');
|
console.log('Sending success notifications...');
|
||||||
await this.sendSyncNotification(results);
|
await this.sendSyncNotification(results);
|
||||||
console.log('Success notifications sent');
|
console.log('Success notifications sent');
|
||||||
@@ -481,7 +496,7 @@ export class AutoSyncService {
|
|||||||
const updatedSettings = {
|
const updatedSettings = {
|
||||||
...settings,
|
...settings,
|
||||||
lastAutoSync: lastSyncTime,
|
lastAutoSync: lastSyncTime,
|
||||||
lastAutoSyncError: null // Clear any previous errors on successful sync
|
lastAutoSyncError: '' // Clear any previous errors on successful sync
|
||||||
};
|
};
|
||||||
this.saveSettings(updatedSettings);
|
this.saveSettings(updatedSettings);
|
||||||
|
|
||||||
@@ -504,7 +519,7 @@ export class AutoSyncService {
|
|||||||
|
|
||||||
// Send error notification if enabled
|
// Send error notification if enabled
|
||||||
const settings = this.loadSettings();
|
const settings = this.loadSettings();
|
||||||
if (settings.notificationEnabled && settings.appriseUrls?.length > 0) {
|
if (settings.notificationEnabled && settings.appriseUrls && settings.appriseUrls.length > 0) {
|
||||||
try {
|
try {
|
||||||
const notificationTitle = isRateLimitError ? 'Auto-Sync Rate Limited' : 'Auto-Sync Failed';
|
const notificationTitle = isRateLimitError ? 'Auto-Sync Rate Limited' : 'Auto-Sync Failed';
|
||||||
const notificationMessage = isRateLimitError
|
const notificationMessage = isRateLimitError
|
||||||
@@ -514,7 +529,7 @@ export class AutoSyncService {
|
|||||||
await appriseService.sendNotification(
|
await appriseService.sendNotification(
|
||||||
notificationTitle,
|
notificationTitle,
|
||||||
notificationMessage,
|
notificationMessage,
|
||||||
settings.appriseUrls
|
settings.appriseUrls || []
|
||||||
);
|
);
|
||||||
} catch (notifError) {
|
} catch (notifError) {
|
||||||
console.error('Failed to send error notification:', notifError);
|
console.error('Failed to send error notification:', notifError);
|
||||||
|
|||||||
Reference in New Issue
Block a user