mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-02 22:30:40 +00:00
Prevent dup history broadcasts
This commit is contained in:
parent
14b699485a
commit
192df0a3b8
5 changed files with 18 additions and 15 deletions
|
@ -59,6 +59,7 @@ class StateHistory {
|
||||||
return getHistoryPosition(url) > duration * 0.7;
|
return getHistoryPosition(url) > duration * 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var _lastHistoryBroadcast = "";
|
||||||
fun updateHistoryPosition(liveObj: IPlatformVideo, index: DBHistory.Index, updateExisting: Boolean, position: Long = -1L, date: OffsetDateTime? = null, isUserAction: Boolean = false): Long {
|
fun updateHistoryPosition(liveObj: IPlatformVideo, index: DBHistory.Index, updateExisting: Boolean, position: Long = -1L, date: OffsetDateTime? = null, isUserAction: Boolean = false): Long {
|
||||||
val pos = if(position < 0) 0 else position;
|
val pos = if(position < 0) 0 else position;
|
||||||
val historyVideo = index.obj;
|
val historyVideo = index.obj;
|
||||||
|
@ -82,19 +83,21 @@ class StateHistory {
|
||||||
historyVideo.date = date ?: OffsetDateTime.now();
|
historyVideo.date = date ?: OffsetDateTime.now();
|
||||||
_historyDBStore.update(index.id!!, historyVideo);
|
_historyDBStore.update(index.id!!, historyVideo);
|
||||||
onHistoricVideoChanged.emit(liveObj, pos);
|
onHistoricVideoChanged.emit(liveObj, pos);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(isUserAction) {
|
val historyBroadcastSig = "${historyVideo.position}${historyVideo.video.id.value ?: historyVideo.video.url}"
|
||||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
if(isUserAction && _lastHistoryBroadcast != historyBroadcastSig) {
|
||||||
if(StateSync.instance.hasAtLeastOneOnlineDevice()) {
|
_lastHistoryBroadcast = historyBroadcastSig;
|
||||||
Logger.i(TAG, "SyncHistory playback broadcasted (${liveObj.name}: ${position})");
|
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
||||||
StateSync.instance.broadcastJsonData(
|
if(StateSync.instance.hasAtLeastOneOnlineDevice()) {
|
||||||
GJSyncOpcodes.syncHistory,
|
Logger.i(TAG, "SyncHistory playback broadcasted (${liveObj.name}: ${position})");
|
||||||
listOf(historyVideo)
|
StateSync.instance.broadcastJsonData(
|
||||||
);
|
GJSyncOpcodes.syncHistory,
|
||||||
}
|
listOf(historyVideo)
|
||||||
};
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return positionBefore;
|
return positionBefore;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 946bc835e18d62a584de7150a05cebea7c832b51
|
Subproject commit 62e19e2e61ac55ee0d6d836dc1953c5e2b6751b3
|
|
@ -1 +1 @@
|
||||||
Subproject commit e2d896ac45357e85b88a8d1f0a1fc5f4b72bfcfa
|
Subproject commit f018ca772da6bfc287fa4ef767a4f13c601b52c4
|
|
@ -1 +1 @@
|
||||||
Subproject commit 946bc835e18d62a584de7150a05cebea7c832b51
|
Subproject commit 62e19e2e61ac55ee0d6d836dc1953c5e2b6751b3
|
|
@ -1 +1 @@
|
||||||
Subproject commit e2d896ac45357e85b88a8d1f0a1fc5f4b72bfcfa
|
Subproject commit f018ca772da6bfc287fa4ef767a4f13c601b52c4
|
Loading…
Add table
Add a link
Reference in a new issue