mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
* Updated some signatures to avoid a ToArray() within a loop. * Use UpdateSeries directly when adding new series, rather than a modified version for new series only. * Refactored some messages for scanner loop to reduce duplicate code and write messages more clear. Hooked in a RefreshMetadataProgress event (no UI changes). * Fixed a bug on docker where backup service was using different logic than non-docker, which isn't needed after config change last release. * Allow user to make more than 1 backup per day * Implemented a select all checkbox for library access modal
127 lines
3.5 KiB
C#
127 lines
3.5 KiB
C#
using System;
|
|
using API.DTOs.Update;
|
|
|
|
namespace API.SignalR
|
|
{
|
|
public static class MessageFactory
|
|
{
|
|
public static SignalRMessage ScanSeriesEvent(int seriesId, string seriesName)
|
|
{
|
|
return new SignalRMessage()
|
|
{
|
|
Name = SignalREvents.ScanSeries,
|
|
Body = new
|
|
{
|
|
SeriesId = seriesId,
|
|
SeriesName = seriesName
|
|
}
|
|
};
|
|
}
|
|
|
|
public static SignalRMessage SeriesAddedEvent(int seriesId, string seriesName, int libraryId)
|
|
{
|
|
return new SignalRMessage()
|
|
{
|
|
Name = SignalREvents.SeriesAdded,
|
|
Body = new
|
|
{
|
|
SeriesId = seriesId,
|
|
SeriesName = seriesName,
|
|
LibraryId = libraryId
|
|
}
|
|
};
|
|
}
|
|
|
|
public static SignalRMessage SeriesRemovedEvent(int seriesId, string seriesName, int libraryId)
|
|
{
|
|
return new SignalRMessage()
|
|
{
|
|
Name = SignalREvents.SeriesRemoved,
|
|
Body = new
|
|
{
|
|
SeriesId = seriesId,
|
|
SeriesName = seriesName,
|
|
LibraryId = libraryId
|
|
}
|
|
};
|
|
}
|
|
|
|
public static SignalRMessage ScanLibraryProgressEvent(int libraryId, float progress)
|
|
{
|
|
return new SignalRMessage()
|
|
{
|
|
Name = SignalREvents.ScanLibrary,
|
|
Body = new
|
|
{
|
|
LibraryId = libraryId,
|
|
Progress = progress,
|
|
EventTime = DateTime.Now
|
|
}
|
|
};
|
|
}
|
|
|
|
public static SignalRMessage RefreshMetadataProgressEvent(int libraryId, float progress)
|
|
{
|
|
return new SignalRMessage()
|
|
{
|
|
Name = SignalREvents.RefreshMetadataProgress,
|
|
Body = new
|
|
{
|
|
LibraryId = libraryId,
|
|
Progress = progress,
|
|
EventTime = DateTime.Now
|
|
}
|
|
};
|
|
}
|
|
|
|
|
|
|
|
public static SignalRMessage RefreshMetadataEvent(int libraryId, int seriesId)
|
|
{
|
|
return new SignalRMessage()
|
|
{
|
|
Name = SignalREvents.RefreshMetadata,
|
|
Body = new
|
|
{
|
|
SeriesId = seriesId,
|
|
LibraryId = libraryId
|
|
}
|
|
};
|
|
}
|
|
|
|
public static SignalRMessage UpdateVersionEvent(UpdateNotificationDto update)
|
|
{
|
|
return new SignalRMessage
|
|
{
|
|
Name = SignalREvents.UpdateVersion,
|
|
Body = update
|
|
};
|
|
}
|
|
|
|
public static SignalRMessage SeriesAddedToCollection(int tagId, int seriesId)
|
|
{
|
|
return new SignalRMessage
|
|
{
|
|
Name = SignalREvents.UpdateVersion,
|
|
Body = new
|
|
{
|
|
TagId = tagId,
|
|
SeriesId = seriesId
|
|
}
|
|
};
|
|
}
|
|
|
|
public static SignalRMessage ScanLibraryError(int libraryId)
|
|
{
|
|
return new SignalRMessage
|
|
{
|
|
Name = SignalREvents.ScanLibraryError,
|
|
Body = new
|
|
{
|
|
LibraryId = libraryId,
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|