Added config parameter Don't remove items from trakt (#196)

This commit is contained in:
addamanth 2023-02-11 02:19:57 +03:00 committed by GitHub
parent 8d3c1a5727
commit b32f33a7af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 2 deletions

View File

@ -73,7 +73,7 @@ internal class LibraryManagerEventsHelper : IDisposable
{
// Add to queue.
// Sync will be processed when the next timer elapsed event fires.
if (user.SynchronizeCollections)
if (user.SynchronizeCollections && (!user.DontRemoveItemFromTrakt || eventType != EventType.Remove))
{
_queuedEvents.Add(new LibraryEvent { Item = item, TraktUser = user, EventType = eventType });
}

View File

@ -30,6 +30,7 @@ public class TraktUser
Scrobble = true;
LocationsExcluded = null;
AccessTokenExpiration = DateTime.MinValue;
DontRemoveItemFromTrakt = true;
}
/// <summary>
@ -111,4 +112,9 @@ public class TraktUser
/// Gets or sets the access token expiration.
/// </summary>
public DateTime AccessTokenExpiration { get; set; }
/// <summary>
/// Gets or sets a value indicating whether item should be removed from trakt.tv.
/// </summary>
public bool DontRemoveItemFromTrakt { get; set; }
}

View File

@ -136,6 +136,15 @@
Scrobble to trakt.tv.
</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input is="emby-checkbox" type="checkbox" id="chkDontRemoveItemFromTrakt" name="chkDontRemoveItemFromTrakt" />
<span>Don't remove item from trakt.tv colection</span>
</label>
<div class="fieldDescription checkboxFieldDescription">
When checked, the item removed from local collection will NOT be removed from trakt.tv collection.
</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input is="emby-checkbox" type="checkbox" id="chkExtraLogging" name="chkExtraLogging" />

View File

@ -20,7 +20,8 @@ const TraktConfigurationPage = {
ExtraLogging: false,
ExportMediaInfo: false,
SynchronizeCollections: true,
Scrobble: true
Scrobble: true,
DontRemoveItemFromTrakt: true
};
}
// Default this to an empty array so the rendering code doesn't have to worry about it
@ -36,6 +37,7 @@ const TraktConfigurationPage = {
page.querySelector('#chkExportMediaInfo').checked = currentUserConfig.ExportMediaInfo;
page.querySelector('#chkSyncCollections').checked = currentUserConfig.SynchronizeCollections;
page.querySelector('#chkScrobble').checked = currentUserConfig.Scrobble;
page.querySelector('#chkDontRemoveItemFromTrakt').checked = currentUserConfig.DontRemoveItemFromTrakt;
// List the folders the user can access
ApiClient.getVirtualFolders(userId).then(function (result) {
TraktConfigurationPage.loadFolders(currentUserConfig, result);
@ -120,6 +122,7 @@ function save(page) {
currentUserConfig.ExportMediaInfo = page.querySelector('#chkExportMediaInfo').checked;
currentUserConfig.SynchronizeCollections = page.querySelector('#chkSyncCollections').checked;
currentUserConfig.Scrobble = page.querySelector('#chkScrobble').checked;
currentUserConfig.DontRemoveItemFromTrakt = page.querySelector('#chkDontRemoveItemFromTrakt').checked;
currentUserConfig.LinkedMbUserId = currentUserId;
currentUserConfig.LocationsExcluded = Array.prototype.map.call(page.querySelectorAll('.chkTraktLocation:checked'), elem => {
return elem.getAttribute('data-location');