Skip to content

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

Fix lint

Chocobozzz84140e81d7ed
diff --git a/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.ts b/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.ts
index 5857e1a5d3..3bb811c5c8 100644
--- a/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.ts
+++ b/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.ts
@@ -23,6 +23,6 @@ export class VideoPublishResolver {
listUserChannelsForSelect(this.authService, { includeCollaborations: true }),
this.userService.getMyVideoQuotaUsed(),
this.serverService.getVideoPrivacies()
- ]).pipe(map(([ videoChannels, userQuota, privacies ]) => ({ videoChannels, userQuota, privacies } as VideoPublishResolverData)))
+ ]).pipe(map(([ videoChannels, userQuota, privacies ]) => ({ videoChannels, userQuota, privacies } satisfies VideoPublishResolverData)))
}
}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.ts b/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.ts
index 27babd8135..d42c37be4b 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.ts
@@ -94,7 +94,7 @@ export class VideoCaptionsComponent implements OnInit {
Object.assign(existingCaption, caption)
} else {
captionsEdit.push(
- Object.assign(caption, { action: 'CREATE' as 'CREATE' })
+ Object.assign(caption, { action: 'CREATE' })
)
}
@@ -116,7 +116,7 @@ export class VideoCaptionsComponent implements OnInit {
return
}
- caption.action = 'REMOVE' as 'REMOVE'
+ caption.action = 'REMOVE'
debugLogger('Caption deleted', caption)
}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.ts b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.ts
index 116f3fc390..a9c9f7ba13 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.ts
@@ -37,6 +37,19 @@ type ActiveGraphId = VideoStatsTimeserieMetric | 'retention' | BarGraphs
type GeoData = { name: string, viewers: number }[]
type ChartIngestData = VideoStatsTimeserie | VideoStatsRetention | GeoData | VideoStatsUserAgent
+
+type GraphDataById = {
+ clients: VideoStatsUserAgent
+ devices: VideoStatsUserAgent
+ operatingSystems: VideoStatsUserAgent
+ retention: VideoStatsRetention
+ aggregateWatchTime: VideoStatsTimeserie
+ viewers: VideoStatsTimeserie
+ downloads: VideoStatsTimeserie
+ countries: GeoData
+ regions: GeoData
+}
+
type ChartBuilderResult = {
type: 'line' | 'bar'
@@ -431,10 +444,8 @@ export class VideoStatsComponent implements OnInit {
})
}
- private buildChartOptions (graphId: ActiveGraphId): ChartConfiguration<'line' | 'bar'> {
- const dataBuilders: {
- [id in ActiveGraphId]: (rawData: ChartIngestData) => ChartBuilderResult
- } = {
+ private buildChartOptions<K extends ActiveGraphId> (graphId: K): ChartConfiguration<'line' | 'bar'> {
+ const dataBuilders: { [P in ActiveGraphId]: (rawData: GraphDataById[P]) => ChartBuilderResult } = {
clients: (rawData: VideoStatsUserAgent) => this.buildUserAgentChartOptions(rawData, 'clients'),
devices: (rawData: VideoStatsUserAgent) => this.buildUserAgentChartOptions(rawData, 'devices'),
operatingSystems: (rawData: VideoStatsUserAgent) => this.buildUserAgentChartOptions(rawData, 'operatingSystems'),
@@ -446,7 +457,8 @@ export class VideoStatsComponent implements OnInit {
regions: (rawData: GeoData) => this.buildGeoChartOptions(rawData)
}
- const { type, data, displayLegend, plugins, options } = dataBuilders[graphId](this.chartIngestData[graphId])
+ const rawData = this.chartIngestData[graphId] as GraphDataById[K]
+ const { type, data, displayLegend, plugins, options } = dataBuilders[graphId](rawData)
const self = this
@@ -516,7 +528,7 @@ export class VideoStatsComponent implements OnInit {
}
return {
- type: 'line' as 'line',
+ type: 'line',
displayLegend: false,
@@ -546,7 +558,7 @@ export class VideoStatsComponent implements OnInit {
}
return {
- type: 'line' as 'line',
+ type: 'line',
displayLegend: false,
@@ -606,7 +618,7 @@ export class VideoStatsComponent implements OnInit {
}
return {
- type: 'bar' as 'bar',
+ type: 'bar',
options: {
indexAxis: 'y'
@@ -642,7 +654,7 @@ export class VideoStatsComponent implements OnInit {
}
return {
- type: 'bar' as 'bar',
+ type: 'bar',
options: {
indexAxis: 'y'
diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.ts
index 52a3144cf7..14f490ada9 100644
--- a/client/src/app/core/theme/theme.service.ts
+++ b/client/src/app/core/theme/theme.service.ts
@@ -111,7 +111,7 @@ export class ThemeService {
if (instanceTheme !== 'default') return instanceTheme
// Default to dark theme if available and wanted by the user
- if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
+ if (window.matchMedia?.('(prefers-color-scheme: dark)').matches) {
return 'peertube-core-dark-brown' satisfies ServerConfig['theme']['builtIn'][0]['name']
}
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index a317eb4cf1..bae137b6e6 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -124,7 +124,7 @@ export class MenuComponent implements OnInit, OnDestroy {
{
path: this.redirectService.getDefaultRoute(),
query: this.redirectService.getDefaultRouteQuery(),
- icon: 'home' as GlobalIconName,
+ icon: 'home',
label: $localize`Home`
}
]
@@ -133,7 +133,7 @@ export class MenuComponent implements OnInit, OnDestroy {
if (this.loggedIn) {
base.links.push({
path: '/videos/subscriptions',
- icon: 'subscriptions' as GlobalIconName,
+ icon: 'subscriptions',
label: $localize`Subscriptions`
})
}
@@ -148,12 +148,12 @@ export class MenuComponent implements OnInit, OnDestroy {
links = links.concat([
{
path: '/my-library/video-playlists',
- icon: 'playlists' as GlobalIconName,
+ icon: 'playlists',
label: $localize`Playlists`
},
{
path: '/my-library/history/videos',
- icon: 'history' as GlobalIconName,
+ icon: 'history',
label: $localize`History`
}
])
@@ -173,20 +173,20 @@ export class MenuComponent implements OnInit, OnDestroy {
links = links.concat([
{
path: '/my-library/video-channels',
- icon: 'channel' as GlobalIconName,
+ icon: 'channel',
iconClass: 'channel-icon',
label: $localize`Channels`
},
{
path: '/my-library/videos',
- icon: 'videos' as GlobalIconName,
+ icon: 'videos',
label: $localize`Videos`
},
{
path: '/videos/publish',
- icon: 'upload' as GlobalIconName,
+ icon: 'upload',
label: $localize`Publish`,
isPrimaryButton: true,
ngClass: 'publish-button'
@@ -208,7 +208,7 @@ export class MenuComponent implements OnInit, OnDestroy {
if (this.user.hasRight(UserRight.SEE_ALL_VIDEOS)) {
links.push({
path: '/admin/overview',
- icon: 'overview' as GlobalIconName,
+ icon: 'overview',
label: $localize`Overview`
})
}
@@ -216,7 +216,7 @@ export class MenuComponent implements OnInit, OnDestroy {
if (this.user.hasRight(UserRight.MANAGE_ABUSES)) {
links.push({
path: '/admin/moderation',
- icon: 'moderation' as GlobalIconName,
+ icon: 'moderation',
label: $localize`Moderation`
})
}
@@ -224,7 +224,7 @@ export class MenuComponent implements OnInit, OnDestroy {
if (this.user.hasRight(UserRight.MANAGE_CONFIGURATION)) {
links.push({
path: '/admin/settings',
- icon: 'config' as GlobalIconName,
+ icon: 'config',
label: $localize`Settings`
})
}
diff --git a/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-edit-info.component.ts b/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-edit-info.component.ts
index be5165a969..d6b4ceb819 100644
--- a/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-edit-info.component.ts
+++ b/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-edit-info.component.ts
@@ -106,7 +106,7 @@ export class AdminConfigWizardEditInfoComponent implements OnInit {
return {
platformName: config.instance.name,
shortDescription: config.instance.shortDescription,
- avatar: undefined as Blob,
+ avatar: undefined,
primaryColor
}
}
diff --git a/client/src/app/shared/shared-main/video-caption/video-caption.service.ts b/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
index ddd61b9d62..85e1fb341e 100644
--- a/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
+++ b/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
@@ -107,7 +107,7 @@ export class VideoCaptionService {
return this.authHttp.post(`${VideoService.BASE_VIDEO_URL}/${video.id}/captions/generate`, body)
.pipe(
- map(() => 'success' as 'success'),
+ map(() => 'success' as const),
catchError(err => {
const error: PeerTubeProblemDocument = err.error
diff --git a/client/src/app/shared/shared-main/video/video-chapter.service.ts b/client/src/app/shared/shared-main/video/video-chapter.service.ts
index 38c5408c20..f82f83eafd 100644
--- a/client/src/app/shared/shared-main/video/video-chapter.service.ts
+++ b/client/src/app/shared/shared-main/video/video-chapter.service.ts
@@ -20,7 +20,7 @@ export class VideoChapterService {
}
updateChapters (videoId: string, chaptersEdit: VideoChaptersEdit) {
- const body = { chapters: chaptersEdit.getChaptersForUpdate() } as VideoChapterUpdate
+ const body = { chapters: chaptersEdit.getChaptersForUpdate() } satisfies VideoChapterUpdate
return this.authHttp.put(`${VideoService.BASE_VIDEO_URL}/${videoId}/chapters`, body)
.pipe(catchError(err => this.restExtractor.handleError(err)))
diff --git a/client/src/standalone/player/src/shared/context-menu/context-menu-plugin.ts b/client/src/standalone/player/src/shared/context-menu/context-menu-plugin.ts
index 5f5051454f..ca98871922 100644
--- a/client/src/standalone/player/src/shared/context-menu/context-menu-plugin.ts
+++ b/client/src/standalone/player/src/shared/context-menu/context-menu-plugin.ts
@@ -57,7 +57,7 @@ class ContextMenuPlugin extends Plugin {
this.menu.on('dispose', () => {
for (const event of [ 'click', 'tap' ]) {
- videojs.off(documentEl as Element, event, this.menu.dispose)
+ videojs.off(documentEl, event, this.menu.dispose)
}
this.player.removeChild(this.menu)
@@ -83,7 +83,7 @@ class ContextMenuPlugin extends Plugin {
}
for (const event of [ 'click', 'tap' ]) {
- videojs.on(documentEl as Element, event, this.menu.dispose)
+ videojs.on(documentEl, event, this.menu.dispose)
}
}
}
diff --git a/client/src/standalone/player/src/shared/p2p-media-loader/p2p-media-loader-plugin.ts b/client/src/standalone/player/src/shared/p2p-media-loader/p2p-media-loader-plugin.ts
index 486e0e7ed2..88856a331c 100644
--- a/client/src/standalone/player/src/shared/p2p-media-loader/p2p-media-loader-plugin.ts
+++ b/client/src/standalone/player/src/shared/p2p-media-loader/p2p-media-loader-plugin.ts
@@ -263,24 +263,27 @@ class P2pMediaLoaderPlugin extends Plugin {
this.statsP2PBytes.pendingUpload = []
this.statsHTTPBytes.pendingDownload = []
- return player.trigger('network-info', {
- source: 'p2p-media-loader',
- bandwidthEstimate: (hlsjs as any).bandwidthEstimate / 8,
- http: {
- downloadSpeed: httpDownloadSpeed,
- downloaded: this.statsHTTPBytes.totalDownload
- },
- p2p: this.options.p2pEnabled
- ? {
- downloadSpeed: p2pDownloadSpeed,
- uploadSpeed: p2pUploadSpeed,
- peersWithWebSeed: this.statsP2PBytes.peersWithWebSeed,
- peersP2POnly: this.statsP2PBytes.peersP2POnly,
- downloaded: this.statsP2PBytes.totalDownload,
- uploaded: this.statsP2PBytes.totalUpload
- }
- : undefined
- } as PlayerNetworkInfo)
+ return player.trigger(
+ 'network-info',
+ {
+ source: 'p2p-media-loader',
+ bandwidthEstimate: (hlsjs as any).bandwidthEstimate / 8,
+ http: {
+ downloadSpeed: httpDownloadSpeed,
+ downloaded: this.statsHTTPBytes.totalDownload
+ },
+ p2p: this.options.p2pEnabled
+ ? {
+ downloadSpeed: p2pDownloadSpeed,
+ uploadSpeed: p2pUploadSpeed,
+ peersWithWebSeed: this.statsP2PBytes.peersWithWebSeed,
+ peersP2POnly: this.statsP2PBytes.peersP2POnly,
+ downloaded: this.statsP2PBytes.totalDownload,
+ uploaded: this.statsP2PBytes.totalUpload
+ }
+ : undefined
+ } satisfies PlayerNetworkInfo
+ )
}, 1000)
}
diff --git a/client/src/standalone/player/src/shared/web-video/web-video-plugin.ts b/client/src/standalone/player/src/shared/web-video/web-video-plugin.ts
index d8fa5adc8a..ac17dd3284 100644
--- a/client/src/standalone/player/src/shared/web-video/web-video-plugin.ts
+++ b/client/src/standalone/player/src/shared/web-video/web-video-plugin.ts
@@ -199,12 +199,15 @@ class WebVideoPlugin extends Plugin {
if (!player) return
- return player.trigger('network-info', {
- source: 'web-video',
- http: {
- downloaded: player.bufferedPercent() * this.currentVideoFile?.size
- }
- } as PlayerNetworkInfo)
+ return player.trigger(
+ 'network-info',
+ {
+ source: 'web-video',
+ http: {
+ downloaded: player.bufferedPercent() * this.currentVideoFile?.size
+ }
+ } satisfies PlayerNetworkInfo
+ )
}, 1000)
}
}
diff --git a/client/src/standalone/videos/shared/peertube-theme.ts b/client/src/standalone/videos/shared/peertube-theme.ts
index 318f5e32ff..eebc3d73f4 100644
--- a/client/src/standalone/videos/shared/peertube-theme.ts
+++ b/client/src/standalone/videos/shared/peertube-theme.ts
@@ -45,7 +45,7 @@ export class PeerTubeTheme {
if (instanceTheme !== 'default') return instanceTheme
// Default to dark theme if available and wanted by the user
- if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
+ if (window.matchMedia?.('(prefers-color-scheme: dark)').matches) {
return 'peertube-core-dark-brown' satisfies ServerConfig['theme']['builtIn'][0]['name']
}