use non-deprecated observer .subscribe call signature

https://rxjs.dev/deprecations/subscribe-arguments
This commit is contained in:
Cucumberrbob 2025-06-07 17:21:24 +01:00
parent 2b95b8d714
commit 2e7c97d023
No known key found for this signature in database
GPG key ID: 2B935C47401C3614
8 changed files with 115 additions and 137 deletions

View file

@ -149,25 +149,21 @@ export class AddNewTorrentComponent implements OnInit {
torrent.downloadClient = this.downloadClient;
if (this.magnetLink) {
this.torrentService.uploadMagnet(this.magnetLink, torrent).subscribe(
() => {
this.router.navigate(['/']);
},
(err) => {
this.torrentService.uploadMagnet(this.magnetLink, torrent).subscribe({
next: () => this.router.navigate(['/']),
error: (err) => {
this.error = err.error;
this.saving = false;
},
);
});
} else if (this.selectedFile) {
this.torrentService.uploadFile(this.selectedFile, torrent).subscribe(
() => {
this.router.navigate(['/']);
},
(err) => {
this.torrentService.uploadFile(this.selectedFile, torrent).subscribe({
next: () => this.router.navigate(['/']),
error: (err) => {
this.error = err.error;
this.saving = false;
},
);
});
} else {
this.error = 'No magnet or file uploaded';
this.saving = false;
@ -192,8 +188,8 @@ export class AddNewTorrentComponent implements OnInit {
this.allSelected = true;
if (this.magnetLink) {
this.torrentService.checkFilesMagnet(this.magnetLink).subscribe(
(result) => {
this.torrentService.checkFilesMagnet(this.magnetLink).subscribe({
next: (result) => {
this.saving = false;
this.availableFiles = result;
this.currentTorrentFile = this.magnetLink;
@ -201,25 +197,25 @@ export class AddNewTorrentComponent implements OnInit {
this.downloadFiles[file.filename] = true;
});
},
(err) => {
error: (err) => {
this.error = err.error;
this.saving = false;
},
);
});
} else if (this.selectedFile) {
this.torrentService.checkFiles(this.selectedFile).subscribe(
(result) => {
this.torrentService.checkFiles(this.selectedFile).subscribe({
next: (result) => {
this.saving = false;
this.availableFiles = result;
result.forEach((file) => {
this.downloadFiles[file.filename] = true;
});
},
(err) => {
error: (err) => {
this.error = err.error;
this.saving = false;
},
);
});
} else {
this.saving = false;
}

View file

@ -5,10 +5,10 @@ import { FormsModule } from '@angular/forms';
import { NgClass } from '@angular/common';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'],
imports: [FormsModule, NgClass],
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'],
imports: [FormsModule, NgClass],
})
export class LoginComponent {
public userName: string;
@ -32,14 +32,12 @@ export class LoginComponent {
public login(): void {
this.error = null;
this.loggingIn = true;
this.authService.login(this.userName, this.password).subscribe(
() => {
this.router.navigate(['/']);
},
(err) => {
this.authService.login(this.userName, this.password).subscribe({
next: () => this.router.navigate(['/']),
error: (err) => {
this.loggingIn = false;
this.error = err.error;
},
);
});
}
}

View file

@ -6,14 +6,10 @@ import { SettingsService } from '../settings.service';
import { NgClass, DatePipe } from '@angular/common';
@Component({
selector: 'app-navbar',
templateUrl: './navbar.component.html',
styleUrls: ['./navbar.component.scss'],
imports: [
RouterLink,
NgClass,
DatePipe,
],
selector: 'app-navbar',
templateUrl: './navbar.component.html',
styleUrls: ['./navbar.component.scss'],
imports: [RouterLink, NgClass, DatePipe],
})
export class NavbarComponent implements OnInit {
public showMobileMenu = false;
@ -63,11 +59,6 @@ export class NavbarComponent implements OnInit {
}
public logout(): void {
this.authService.logout().subscribe(
() => {
this.router.navigate(['/login']);
},
(err) => {},
);
this.authService.logout().subscribe({ next: () => this.router.navigate(['/login']), error: console.error });
}
}

View file

@ -4,10 +4,10 @@ import { FormsModule } from '@angular/forms';
import { NgClass } from '@angular/common';
@Component({
selector: 'app-profile',
templateUrl: './profile.component.html',
styleUrls: ['./profile.component.scss'],
imports: [FormsModule, NgClass],
selector: 'app-profile',
templateUrl: './profile.component.html',
styleUrls: ['./profile.component.scss'],
imports: [FormsModule, NgClass],
})
export class ProfileComponent {
constructor(private authService: AuthService) {}
@ -24,16 +24,16 @@ export class ProfileComponent {
this.error = null;
this.saving = true;
this.authService.update(this.username, this.password).subscribe(
() => {
this.authService.update(this.username, this.password).subscribe({
next: () => {
this.success = true;
this.saving = false;
},
(err) => {
error: (err) => {
this.error = err.error;
this.success = false;
this.saving = false;
},
);
});
}
}

View file

@ -7,16 +7,10 @@ import { Nl2BrPipe } from '../nl2br.pipe';
import { FileSizePipe } from '../filesize.pipe';
@Component({
selector: 'app-settings',
templateUrl: './settings.component.html',
styleUrls: ['./settings.component.scss'],
imports: [
NgClass,
FormsModule,
KeyValuePipe,
Nl2BrPipe,
FileSizePipe,
],
selector: 'app-settings',
templateUrl: './settings.component.html',
styleUrls: ['./settings.component.scss'],
imports: [NgClass, FormsModule, KeyValuePipe, Nl2BrPipe, FileSizePipe],
})
export class SettingsComponent implements OnInit {
public activeTab = 0;
@ -62,17 +56,16 @@ export class SettingsComponent implements OnInit {
const settingsToSave = this.tabs.flatMap((m) => m.settings).filter((m) => m.type !== 'Object');
this.settingsService.update(settingsToSave).subscribe(
() => {
this.settingsService.update(settingsToSave).subscribe({
next: () =>
setTimeout(() => {
this.saving = false;
}, 1000);
},
(err) => {
}, 1000),
error: (err) => {
this.saving = false;
this.error = err;
},
);
});
}
public testDownloadPath(): void {
@ -84,16 +77,16 @@ export class SettingsComponent implements OnInit {
this.testPathError = null;
this.testPathSuccess = false;
this.settingsService.testPath(settingDownloadPath).subscribe(
() => {
this.settingsService.testPath(settingDownloadPath).subscribe({
next: () => {
this.saving = false;
this.testPathSuccess = true;
},
(err) => {
error: (err) => {
this.testPathError = err.error;
this.saving = false;
},
);
});
}
public testDownloadSpeed(): void {
@ -101,32 +94,32 @@ export class SettingsComponent implements OnInit {
this.testDownloadSpeedError = null;
this.testDownloadSpeedSuccess = 0;
this.settingsService.testDownloadSpeed().subscribe(
(result) => {
this.settingsService.testDownloadSpeed().subscribe({
next: (result) => {
this.saving = false;
this.testDownloadSpeedSuccess = result;
},
(err) => {
error: (err) => {
this.testDownloadSpeedError = err.error;
this.saving = false;
},
);
});
}
public testWriteSpeed(): void {
this.saving = true;
this.testWriteSpeedError = null;
this.testWriteSpeedSuccess = 0;
this.settingsService.testWriteSpeed().subscribe(
(result) => {
this.settingsService.testWriteSpeed().subscribe({
next: (result) => {
this.saving = false;
this.testWriteSpeedSuccess = result;
},
(err) => {
error: (err) => {
this.testWriteSpeedError = err.error;
this.saving = false;
},
);
});
}
public testAria2cConnection(): void {
@ -141,22 +134,24 @@ export class SettingsComponent implements OnInit {
this.testAria2cConnectionError = null;
this.testAria2cConnectionSuccess = null;
this.settingsService.testAria2cConnection(settingAria2cUrl, settingAria2cSecret).subscribe(
(result) => {
this.settingsService.testAria2cConnection(settingAria2cUrl, settingAria2cSecret).subscribe({
next: (result) => {
this.saving = false;
this.testAria2cConnectionSuccess = result.version;
},
(err) => {
error: (err) => {
this.testAria2cConnectionError = err.error;
this.saving = false;
},
);
});
}
public registerMagnetHandler(): void {
try {
navigator.registerProtocolHandler('magnet', `${window.location.origin}/add?magnet=%s`);
alert('Success! Your browser will now prompt you to confirm and add the client as the default handler for magnet links.');
alert(
'Success! Your browser will now prompt you to confirm and add the client as the default handler for magnet links.',
);
} catch (error) {
alert('Magnet link registration failed.');
}

View file

@ -1,14 +1,14 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '../auth.service';
import { FormsModule } from '@angular/forms';
import { NgClass } from '@angular/common';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'app-setup',
templateUrl: './setup.component.html',
styleUrls: ['./setup.component.scss'],
imports: [FormsModule, NgClass],
selector: 'app-setup',
templateUrl: './setup.component.html',
styleUrls: ['./setup.component.scss'],
imports: [FormsModule, NgClass],
})
export class SetupComponent {
public userName: string;
@ -30,29 +30,29 @@ export class SetupComponent {
this.error = null;
this.working = true;
this.authService.create(this.userName, this.password).subscribe(
() => {
this.authService.create(this.userName, this.password).subscribe({
next: () => {
this.step = 2;
this.working = false;
},
(err) => {
error: (err) => {
this.working = false;
this.error = err.error;
},
);
});
}
public setToken(): void {
this.authService.setupProvider(this.provider, this.token).subscribe(
() => {
this.authService.setupProvider(this.provider, this.token).subscribe({
next: () => {
this.step = 3;
this.working = false;
},
(err: any) => {
error: (err: any) => {
this.working = false;
this.error = err.error;
},
);
});
}
public close(): void {

View file

@ -61,18 +61,18 @@ export class TorrentTableComponent implements OnInit {
) {}
ngOnInit(): void {
this.torrentService.getList().subscribe(
(result) => {
this.torrentService.getList().subscribe({
next: (result) => {
this.torrents = result;
this.torrentService.update$.subscribe((result2) => {
this.torrents = result2;
});
},
(err) => {
error: (err) => {
this.error = err.error;
},
);
});
}
public sort(property: string): void {

View file

@ -12,19 +12,19 @@ import { DecodeURIPipe } from '../decode-uri.pipe';
import { FileSizePipe } from '../filesize.pipe';
@Component({
selector: 'app-torrent',
templateUrl: './torrent.component.html',
styleUrls: ['./torrent.component.scss'],
imports: [
NgClass,
CdkCopyToClipboard,
FormsModule,
DatePipe,
TorrentStatusPipe,
DownloadStatusPipe,
DecodeURIPipe,
FileSizePipe,
],
selector: 'app-torrent',
templateUrl: './torrent.component.html',
styleUrls: ['./torrent.component.scss'],
imports: [
NgClass,
CdkCopyToClipboard,
FormsModule,
DatePipe,
TorrentStatusPipe,
DownloadStatusPipe,
DecodeURIPipe,
FileSizePipe,
],
})
export class TorrentComponent implements OnInit {
public torrent: Torrent;
@ -75,18 +75,16 @@ export class TorrentComponent implements OnInit {
this.activatedRoute.params.subscribe((params) => {
const torrentId = params['id'];
this.torrentService.get(torrentId).subscribe(
(torrent) => {
this.torrentService.get(torrentId).subscribe({
next: (torrent) => {
this.torrent = torrent;
this.torrentService.update$.subscribe((result) => {
this.update(result);
});
},
() => {
this.router.navigate(['/']);
},
);
error: () => this.router.navigate(['/']),
});
});
}
@ -132,18 +130,18 @@ export class TorrentComponent implements OnInit {
this.torrentService
.delete(this.torrent.torrentId, this.deleteData, this.deleteRdTorrent, this.deleteLocalFiles)
.subscribe(
() => {
.subscribe({
next: () => {
this.isDeleteModalActive = false;
this.deleting = false;
this.router.navigate(['/']);
},
(err) => {
error: (err) => {
this.deleteError = err.error;
this.deleting = false;
},
);
});
}
public showRetryModal(): void {
@ -159,18 +157,18 @@ export class TorrentComponent implements OnInit {
public retryOk(): void {
this.retrying = true;
this.torrentService.retry(this.torrent.torrentId).subscribe(
() => {
this.torrentService.retry(this.torrent.torrentId).subscribe({
next: () => {
this.isRetryModalActive = false;
this.retrying = false;
this.router.navigate(['/']);
},
(err) => {
error: (err) => {
this.retryError = err.error;
this.retrying = false;
},
);
});
}
public showDownloadRetryModal(downloadId: string): void {
@ -187,16 +185,16 @@ export class TorrentComponent implements OnInit {
public downloadRetryOk(): void {
this.downloadRetrying = true;
this.torrentService.retryDownload(this.downloadRetryId).subscribe(
() => {
this.torrentService.retryDownload(this.downloadRetryId).subscribe({
next: () => {
this.isDownloadRetryModalActive = false;
this.downloadRetrying = false;
},
(err) => {
error: (err) => {
this.downloadRetryError = err.error;
this.downloadRetrying = false;
},
);
});
}
public showUpdateSettingsModal(): void {
@ -228,16 +226,16 @@ export class TorrentComponent implements OnInit {
this.torrent.deleteOnError = this.updateSettingsDeleteOnError;
this.torrent.lifetime = this.updateSettingsTorrentLifetime;
this.torrentService.update(this.torrent).subscribe(
() => {
this.torrentService.update(this.torrent).subscribe({
next: () => {
this.isUpdateSettingsModalActive = false;
this.updating = false;
},
() => {
error: () => {
this.isUpdateSettingsModalActive = false;
this.updating = false;
},
);
});
}
toggleDeleteSelectAllOptions() {
this.deleteData = this.deleteSelectAll;