浏览代码

Small tweak, flooring startDuration for ActivityWatch extension since it isn't very accurate

Kristian Vos 4 年之前
父节点
当前提交
5e9abcf93e
共有 2 个文件被更改,包括 9 次插入13 次删除
  1. 5 12
      frontend/src/components/modals/EditSong.vue
  2. 4 1
      frontend/src/pages/Station/index.vue

+ 5 - 12
frontend/src/components/modals/EditSong.vue

@@ -1414,24 +1414,17 @@ export default {
 			if (!this.video.paused) {
 				if (this.activityWatchVideoLastStatus !== "playing") {
 					this.activityWatchVideoLastStatus = "playing";
-					console.log(
-						this.song.skipDuration,
-						parseFloat(this.youtubeVideoCurrentTime),
-						typeof this.song.skipDuration,
-						typeof this.youtubeVideoCurrentTime,
-						this.song.skipDuration > 0,
-						parseFloat(this.youtubeVideoCurrentTime) === 0
-					);
 					if (
 						this.song.skipDuration > 0 &&
 						parseFloat(this.youtubeVideoCurrentTime) === 0
 					) {
-						this.activityWatchVideoLastStartDuration =
+						this.activityWatchVideoLastStartDuration = Math.floor(
 							this.song.skipDuration +
-							parseFloat(this.youtubeVideoCurrentTime);
+								parseFloat(this.youtubeVideoCurrentTime)
+						);
 					} else {
-						this.activityWatchVideoLastStartDuration = parseFloat(
-							this.youtubeVideoCurrentTime
+						this.activityWatchVideoLastStartDuration = Math.floor(
+							parseFloat(this.youtubeVideoCurrentTime)
 						);
 					}
 				}

+ 4 - 1
frontend/src/pages/Station/index.vue

@@ -1904,7 +1904,10 @@ export default {
 					startedDuration:
 						this.activityWatchVideoLastStartDuration <= 0
 							? 0
-							: this.activityWatchVideoLastStartDuration / 1000,
+							: Math.floor(
+									this.activityWatchVideoLastStartDuration /
+										1000
+							  ),
 					source: `station#${this.station.name}`,
 					hostname: window.location.hostname
 				};