Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Do not display loading bar on module preloading

Chocobozzz64887b7f30df
diff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts
index ceeb290081..1f655892d6 100644
--- a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts
+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts
@@ -130,7 +130,7 @@ export class VideoImportTorrentComponent implements OnInit, AfterViewInit, CanCo
this.manageController.setConfig({ manageType: 'import-torrent', serverConfig: this.serverService.getHTMLConfig() })
this.manageController.setVideoEdit(videoEdit)
- this.loadingBar.useRef().start()
+ this.loadingBar.useRef('import-video').start()
this.videoImportService.importVideo(videoEdit.toVideoImportCreate(this.highestPrivacy()))
.pipe(switchMap(({ video }) => {
@@ -143,7 +143,7 @@ export class VideoImportTorrentComponent implements OnInit, AfterViewInit, CanCo
next: async ([ video, playerSettings ]) => {
await videoEdit.loadFromAPI({ video, playerSettings, loadPrivacy: false })
- this.loadingBar.useRef().complete()
+ this.loadingBar.useRef('import-video').complete()
debugLogger(`Torrent/magnet import created`)
@@ -157,7 +157,7 @@ export class VideoImportTorrentComponent implements OnInit, AfterViewInit, CanCo
error: err => {
this.isImportingVideo = false
- this.loadingBar.useRef().complete()
+ this.loadingBar.useRef('import-video').complete()
this.firstStepError.emit()
const error = err.body as PeerTubeProblemDocument
diff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts
index 2eb0d800e8..8152b0efc9 100644
--- a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts
+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts
@@ -118,7 +118,7 @@ export class VideoImportUrlComponent implements OnInit, AfterViewInit, CanCompon
this.manageController.setConfig({ manageType: 'import-url', serverConfig: this.serverService.getHTMLConfig() })
this.manageController.setVideoEdit(videoEdit)
- this.loadingBar.useRef().start()
+ this.loadingBar.useRef('import-video').start()
this.videoImportService.importVideo(videoEdit.toVideoImportCreate(this.highestPrivacy()))
.pipe(
@@ -135,7 +135,7 @@ export class VideoImportUrlComponent implements OnInit, AfterViewInit, CanCompon
next: async ({ video, playerSettings, captions, chapters }) => {
await videoEdit.loadFromAPI({ video, captions, playerSettings, chapters, loadPrivacy: false })
- this.loadingBar.useRef().complete()
+ this.loadingBar.useRef('import-video').complete()
debugLogger(`URL import created`)
@@ -147,7 +147,7 @@ export class VideoImportUrlComponent implements OnInit, AfterViewInit, CanCompon
},
error: err => {
- this.loadingBar.useRef().complete()
+ this.loadingBar.useRef('import-video').complete()
this.isImportingVideo = false
this.firstStepError.emit()
this.notifier.handleError(err)
diff --git a/client/src/app/+videos-publish-manage/shared-manage/video-manage-controller.service.ts b/client/src/app/+videos-publish-manage/shared-manage/video-manage-controller.service.ts
index 075576b3a1..79f4e32966 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/video-manage-controller.service.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/video-manage-controller.service.ts
@@ -224,7 +224,7 @@ export class VideoManageController implements OnDestroy {
this.cancelUploadIfNeeded()
- this.loadingBar.useRef().start()
+ this.loadingBar.useRef('update-video').start()
this.isUpdatingVideo = true
const videoAttributes = this.videoEdit.getVideoAttributes()
@@ -315,7 +315,7 @@ export class VideoManageController implements OnDestroy {
debugLogger('Update complete')
this.videoEdit.onSave()
- this.loadingBar.useRef().complete()
+ this.loadingBar.useRef('update-video').complete()
this.isUpdatingVideo = false
this.updatedSubject.next()
this.embedVersion++
@@ -359,7 +359,7 @@ export class VideoManageController implements OnDestroy {
this.videoUploadedSubject = new Subject<void>()
this.pendingUpdateObs = undefined
- this.loadingBar.useRef().complete()
+ this.loadingBar.useRef('update-video').complete()
this.resetUploadState()
}
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index 7c5af5c075..e6f15f54f9 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -225,14 +225,27 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
filter(() => this.screenService.isInSmallView() || this.screenService.isInTouchScreen())
).subscribe(() => this.menu.setMenuCollapsed(true)) // User clicked on a link in the menu, change the page
+ // ---------------------------------------------------------------------------
// Handle lazy loaded module
+ // ---------------------------------------------------------------------------
eventsObs.pipe(
filter((e: Event): e is RouteConfigLoadStart => e instanceof RouteConfigLoadStart)
- ).subscribe(() => this.loadingBar.useRef().start())
+ ).subscribe(e => {
+ if (e.route.data?.preloaded) return // This route is preloaded, don't display the loading indicator
+
+ this.loadingBar.useRef('router-' + e.route.path).start()
+ })
eventsObs.pipe(
filter((e: Event): e is RouteConfigLoadEnd => e instanceof RouteConfigLoadEnd)
- ).subscribe(() => this.loadingBar.useRef().complete())
+ ).subscribe(e => {
+ console.log(e)
+ if (e.route.data?.preloaded) return // This route is preloaded, don't display the loading indicator
+
+ this.loadingBar.useRef('router-' + e.route.path).complete()
+ })
+
+ // ---------------------------------------------------------------------------
// We need this to prevent circular dependency between the router and the custom reuse strategy
eventsObs.pipe(
diff --git a/client/src/app/core/routing/preload-selected-modules-list.ts b/client/src/app/core/routing/preload-selected-modules-list.ts
index 1abcdb0151..e4e8eb49f3 100644
--- a/client/src/app/core/routing/preload-selected-modules-list.ts
+++ b/client/src/app/core/routing/preload-selected-modules-list.ts
@@ -5,12 +5,17 @@ import { PreloadingStrategy, Route } from '@angular/router'
@Injectable()
export class PreloadSelectedModulesList implements PreloadingStrategy {
-
preload (route: Route, load: () => Observable<any>): Observable<any> {
if (!route.data?.preload) return ofObservable(null)
if (typeof route.data.preload === 'number') {
- return observableTimer(route.data.preload).pipe(switchMap(() => load()))
+ return observableTimer(route.data.preload)
+ .pipe(switchMap(() => {
+ // Not proud of this, but it allows to mark the route as preloaded so we don't display the loading indicator
+ route.data.preloaded = true
+
+ return load()
+ }))
}
return load()
diff --git a/client/src/main.ts b/client/src/main.ts
index 6bdedb6e59..2a8325e35a 100644
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -17,7 +17,6 @@ import localeOc from '@app/helpers/locales/oc'
import { getFormProviders } from '@app/shared/shared-forms/shared-form-providers'
import { languageInterceptor } from '@app/shared/shared-main/http/language-interceptor.service'
import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap'
-import { LoadingBarModule } from '@ngx-loading-bar/core'
import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client'
import { providePrimeNG } from 'primeng/config'
import { ToastModule } from 'primeng/toast'
@@ -83,7 +82,6 @@ const bootstrap = () =>
importProvidersFrom(
LoadingBarHttpClientModule,
- LoadingBarModule,
ToastModule,
NgbModalModule
),