X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Fvideojs-components%2Fp2p-info-button.ts;h=6424787b286513740d363544fae2fdcc3267f773;hb=28f3d1b36a70426795240c9370e47b6c4ba847f8;hp=03a5d29f0b7dacbe4d9be759da7ed088a09d1cd2;hpb=2adfc7ea9a1f858db874df9fe322e7ae833db77c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/videojs-components/p2p-info-button.ts b/client/src/assets/player/videojs-components/p2p-info-button.ts index 03a5d29f0..6424787b2 100644 --- a/client/src/assets/player/videojs-components/p2p-info-button.ts +++ b/client/src/assets/player/videojs-components/p2p-info-button.ts @@ -1,4 +1,4 @@ -import { VideoJSComponentInterface, videojsUntyped } from '../peertube-videojs-typings' +import { PlayerNetworkInfo, VideoJSComponentInterface, videojsUntyped } from '../peertube-videojs-typings' import { bytes } from '../utils' const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') @@ -65,7 +65,7 @@ class P2pInfoButton extends Button { subDivHttp.appendChild(subDivHttpText) div.appendChild(subDivHttp) - this.player_.on('p2pInfo', (event: any, data: any) => { + this.player_.on('p2pInfo', (event: any, data: PlayerNetworkInfo) => { // We are in HTTP fallback if (!data) { subDivHttp.className = 'vjs-peertube-displayed' @@ -74,11 +74,14 @@ class P2pInfoButton extends Button { return } - const downloadSpeed = bytes(data.downloadSpeed) - const uploadSpeed = bytes(data.uploadSpeed) - const totalDownloaded = bytes(data.downloaded) - const totalUploaded = bytes(data.uploaded) - const numPeers = data.numPeers + const p2pStats = data.p2p + const httpStats = data.http + + const downloadSpeed = bytes(p2pStats.downloadSpeed + httpStats.downloadSpeed) + const uploadSpeed = bytes(p2pStats.uploadSpeed + httpStats.uploadSpeed) + const totalDownloaded = bytes(p2pStats.downloaded + httpStats.downloaded) + const totalUploaded = bytes(p2pStats.uploaded + httpStats.uploaded) + const numPeers = p2pStats.numPeers subDivWebtorrent.title = this.player_.localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n' + this.player_.localize('Total uploaded: ' + totalUploaded.join(' ')) @@ -90,7 +93,7 @@ class P2pInfoButton extends Button { uploadSpeedUnit.textContent = ' ' + uploadSpeed[ 1 ] peersNumber.textContent = numPeers - peersText.textContent = ' ' + this.player_.localize('peers') + peersText.textContent = ' ' + (numPeers > 1 ? this.player_.localize('peers') : this.player_.localize('peer')) subDivHttp.className = 'vjs-peertube-hidden' subDivWebtorrent.className = 'vjs-peertube-displayed'