Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ export class FileRedirectComponent {
private readonly filesService = inject(FilesService);

readonly fileId = this.route.snapshot.paramMap.get('fileId') ?? '';
readonly provider = this.route.snapshot.paramMap.get('provider') ?? '';
constructor() {
if (this.fileId) {
this.filesService
.getFileGuid(this.fileId)
.getFileGuid(this.fileId, this.provider)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((file) => {
this.router.navigate([file.guid]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class FilesTreeComponent implements OnDestroy, AfterViewInit {
if (file.guid) {
this.entryFileClicked.emit(file);
} else {
this.filesService.getFileGuid(file.id).subscribe((file) => {
this.filesService.getFileGuid(file.id, file.provider).subscribe((file) => {
this.entryFileClicked.emit(file);
});
}
Expand Down
10 changes: 6 additions & 4 deletions src/app/shared/services/files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,16 @@ export class FilesService {
.pipe(map((response) => MapFile(response.data)));
}

getFileGuid(id: string): Observable<OsfFile> {
getFileGuid(id: string, storageId?: string): Observable<OsfFile> {
const params = {
create_guid: 'true',
};
let url = `${this.apiUrl}/files/${id}/`;
if (storageId) {
url = `${this.apiUrl}/files/${storageId}/${id}/`;
}

return this.jsonApiService
.get<GetFileResponse>(`${this.apiUrl}/files/${id}/`, params)
.pipe(map((response) => MapFile(response.data)));
return this.jsonApiService.get<GetFileResponse>(url, params).pipe(map((response) => MapFile(response.data)));
}

getFileById(fileGuid: string): Observable<OsfFile> {
Expand Down
Loading