Browse Source

fix adding channel with no watermark (#265)

pull/266/head
Jason Dove 4 years ago committed by GitHub
parent
commit
57aa14b764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 16
      ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs

4
CHANGELOG.md

@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixed
- Fix ui crash adding a channel without a watermark
## [0.0.46-prealpha] - 2021-06-14
### Added
@ -18,7 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -18,7 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- This allows easy watermark reuse across channels
### Fixed
- Fix crash adding or editing schedule items due to Artist with no name
- Fix ui crash adding or editing schedule items due to Artist with no name
- Fix many potential sources of inconsistent data in UI
## [0.0.45-prealpha] - 2021-06-12

16
ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs

@ -38,7 +38,7 @@ namespace ErsatzTV.Application.Channels.Commands @@ -38,7 +38,7 @@ namespace ErsatzTV.Application.Channels.Commands
return new CreateChannelResult(channel.Id);
}
private async Task<Validation<BaseError, Channel>> Validate(TvContext dbContext, CreateChannel request) =>
private static async Task<Validation<BaseError, Channel>> Validate(TvContext dbContext, CreateChannel request) =>
(ValidateName(request), await ValidateNumber(dbContext, request),
await FFmpegProfileMustExist(dbContext, request),
ValidatePreferredLanguage(request),
@ -66,10 +66,14 @@ namespace ErsatzTV.Application.Channels.Commands @@ -66,10 +66,14 @@ namespace ErsatzTV.Application.Channels.Commands
FFmpegProfileId = ffmpegProfileId,
StreamingMode = request.StreamingMode,
Artwork = artwork,
PreferredLanguageCode = preferredLanguageCode,
WatermarkId = watermarkId
PreferredLanguageCode = preferredLanguageCode
};
foreach (int id in watermarkId)
{
channel.WatermarkId = id;
}
return channel;
});
@ -111,20 +115,20 @@ namespace ErsatzTV.Application.Channels.Commands @@ -111,20 +115,20 @@ namespace ErsatzTV.Application.Channels.Commands
.MapT(_ => createChannel.FFmpegProfileId)
.Map(o => o.ToValidation<BaseError>($"FFmpegProfile {createChannel.FFmpegProfileId} does not exist."));
private static async Task<Validation<BaseError, int?>> WatermarkMustExist(
private static async Task<Validation<BaseError, Option<int>>> WatermarkMustExist(
TvContext dbContext,
CreateChannel createChannel)
{
if (createChannel.WatermarkId is null)
{
return createChannel.WatermarkId;
return Option<int>.None;
}
return await dbContext.ChannelWatermarks
.CountAsync(w => w.Id == createChannel.WatermarkId)
.Map(Optional)
.Filter(c => c > 0)
.MapT(_ => createChannel.WatermarkId)
.MapT(_ => Optional(createChannel.WatermarkId))
.Map(o => o.ToValidation<BaseError>($"Watermark {createChannel.WatermarkId} does not exist."));
}
}

Loading…
Cancel
Save