Kavita/API/SignalR/MessageFactory.cs
Joseph Milazzo ce2f4b6a9f
Polishing and Bugfixes (#613)
* Added a new field to Library for showing Last Scan time for a library.

Manage library page now shows last scan for each library. Tweaked the websocket code to make scan progress a bit more reliable.

* Updated docnet to provide ARM support from our recent PR. Pi users can now have a version for PDF support out of the box.

* Parser is now culture invariant to hopefully fix an issue on Italian systems not detecting . correctly

* Added the ability for the collection detail page to update when a new series is added.

* Fixed an issue where multiple chapters stacked in a volume and reading in incognito, wouldn't sort the chapters and would open the wrong one.

* Code smell
2021-10-01 08:13:55 -07:00

114 lines
3.1 KiB
C#

using System.Threading;
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 ScanLibraryEvent(int libraryId, string stage)
{
return new SignalRMessage()
{
Name = SignalREvents.ScanLibrary,
Body = new
{
LibraryId = libraryId,
Stage = stage
}
};
}
public static SignalRMessage ScanLibraryProgressEvent(int libraryId, float progress, string seriesName)
{
return new SignalRMessage()
{
Name = SignalREvents.ScanLibrary,
Body = new
{
LibraryId = libraryId,
Progress = progress,
SeriesName = seriesName
}
};
}
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
}
};
}
}
}