Skip to content

Commit

Permalink
fix: lazy sync watch state
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Mar 3, 2024
1 parent 29f5691 commit 11e8c10
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Shokofin/Configuration/UserConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class UserConfiguration
/// when a user miss clicked on a video.
/// </summary>
[Range(0, 200)]
public byte SyncUserDataInitialSkipEventCount { get; set; } = 2;
public byte SyncUserDataInitialSkipEventCount { get; set; } = 0;

/// <summary>
/// Number of ticks to skip (1 tick is 10 seconds) before scrobbling to
Expand Down
5 changes: 4 additions & 1 deletion Shokofin/Configuration/configController.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async function loadUserConfig(form, userId, config) {
form.querySelector("#SyncUserDataAfterPlayback").checked = userConfig.SyncUserDataAfterPlayback || false;
form.querySelector("#SyncUserDataUnderPlayback").checked = userConfig.SyncUserDataUnderPlayback || false;
form.querySelector("#SyncUserDataUnderPlaybackLive").checked = userConfig.SyncUserDataUnderPlaybackLive || false;
form.querySelector("#SyncUserDataInitialSkipEventCount").checked = userConfig.SyncUserDataInitialSkipEventCount === 2;
form.querySelector("#SyncRestrictedVideos").checked = userConfig.SyncRestrictedVideos || false;
form.querySelector("#UserUsername").value = userConfig.Username || "";
// Synchronization settings
Expand Down Expand Up @@ -204,7 +205,7 @@ async function defaultSubmit(form) {
userConfig.SyncUserDataAfterPlayback = form.querySelector("#SyncUserDataAfterPlayback").checked;
userConfig.SyncUserDataUnderPlayback = form.querySelector("#SyncUserDataUnderPlayback").checked;
userConfig.SyncUserDataUnderPlaybackLive = form.querySelector("#SyncUserDataUnderPlaybackLive").checked;
userConfig.SyncUserDataInitialSkipEventCount = 2;
userConfig.SyncUserDataInitialSkipEventCount = form.querySelector("#SyncUserDataInitialSkipEventCount").checked ? 2 : 0;
userConfig.SyncUserDataUnderPlaybackAtEveryXTicks = 6;
userConfig.SyncUserDataUnderPlaybackLiveThreshold = 125000000; // 12.5s
userConfig.SyncRestrictedVideos = form.querySelector("#SyncRestrictedVideos").checked;
Expand Down Expand Up @@ -407,6 +408,7 @@ async function syncUserSettings(form) {
userConfig.SyncUserDataAfterPlayback = form.querySelector("#SyncUserDataAfterPlayback").checked;
userConfig.SyncUserDataUnderPlayback = form.querySelector("#SyncUserDataUnderPlayback").checked;
userConfig.SyncUserDataUnderPlaybackLive = form.querySelector("#SyncUserDataUnderPlaybackLive").checked;
userConfig.SyncUserDataInitialSkipEventCount = form.querySelector("#SyncUserDataInitialSkipEventCount").checked ? 2 : 0;
userConfig.SyncUserDataUnderPlaybackAtEveryXTicks = 6;
userConfig.SyncUserDataUnderPlaybackLiveThreshold = 125000000; // 12.5s
userConfig.SyncRestrictedVideos = form.querySelector("#SyncRestrictedVideos").checked;
Expand Down Expand Up @@ -504,6 +506,7 @@ export default function (page) {
form.querySelector("#SyncUserDataAfterPlayback").disabled = disabled;
form.querySelector("#SyncUserDataUnderPlayback").disabled = disabled;
form.querySelector("#SyncUserDataUnderPlaybackLive").disabled = disabled;
form.querySelector("#SyncUserDataInitialSkipEventCount").disabled = disabled;
});

page.addEventListener("viewshow", async function () {
Expand Down
7 changes: 7 additions & 0 deletions Shokofin/Configuration/configPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ <h3>User Settings</h3>
</label>
<div class="fieldDescription checkboxFieldDescription">Enabling this setting will sync-back the watch-state to Shoko live during playback.</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input is="emby-checkbox" type="checkbox" id="SyncUserDataInitialSkipEventCount" />
<span>Lazy sync watch-state events with shoko</span>
</label>
<div class="fieldDescription checkboxFieldDescription">Enabling this setting will add a safe buffer of 10 seconds of playback before the plugin will start the sync-back to shoko. This will prevent accidential clicks and/or previews from marking the file as watched in shoko, and will also keep them more in sync with jellyfin, since it's closer to how Jellyfin handles the watch-state internally.</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input is="emby-checkbox" type="checkbox" id="SyncRestrictedVideos" />
Expand Down

0 comments on commit 11e8c10

Please sign in to comment.