[backend/core] Revert Task.ContinueWithResult naming
This commit is contained in:
parent
a762a9201e
commit
51e4846635
8 changed files with 39 additions and 35 deletions
|
@ -8,8 +8,11 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace Iceshrimp.Backend.Controllers.Mastodon.Renderers;
|
||||
|
||||
public class NotificationRenderer(DatabaseContext db, NoteRenderer noteRenderer, UserRenderer userRenderer)
|
||||
: IScopedService
|
||||
public class NotificationRenderer(
|
||||
DatabaseContext db,
|
||||
NoteRenderer noteRenderer,
|
||||
UserRenderer userRenderer
|
||||
) : IScopedService
|
||||
{
|
||||
public async Task<NotificationEntity> RenderAsync(
|
||||
Notification notification, User user, bool isPleroma, List<AccountEntity>? accounts = null,
|
||||
|
@ -107,7 +110,7 @@ public class NotificationRenderer(DatabaseContext db, NoteRenderer noteRenderer,
|
|||
Url = e.PublicUrl
|
||||
})
|
||||
.ToArrayAsync()
|
||||
.ContinueWithResultAsync(res => res.DistinctBy(e => e.Name)
|
||||
.ContinueWithResult(res => res.DistinctBy(e => e.Name)
|
||||
.ToDictionary(e => e.Name, e => e.Url));
|
||||
|
||||
return await notificationList
|
||||
|
|
|
@ -120,7 +120,7 @@ public sealed class WebSocketConnection(
|
|||
.Select(p => p.UserId)
|
||||
.Distinct()
|
||||
.ToArrayAsync()
|
||||
.ContinueWithResultAsync(p => p.ToHashSet());
|
||||
.ContinueWithResult(p => p.ToHashSet());
|
||||
}
|
||||
|
||||
public async Task HandleSocketMessageAsync(string payload)
|
||||
|
@ -350,7 +350,7 @@ public sealed class WebSocketConnection(
|
|||
.Where(p => p.UserList.UserId == Token.User.Id && p.UserList.HideFromHomeTl)
|
||||
.Select(p => p.UserId)
|
||||
.ToArrayAsync()
|
||||
.ContinueWithResultAsync(p => p.ToHashSet());
|
||||
.ContinueWithResult(p => p.ToHashSet());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -263,7 +263,7 @@ public class AdminController(
|
|||
{
|
||||
return await db.Relays
|
||||
.ToArrayAsync()
|
||||
.ContinueWithResultAsync(res => res.Select(p => new RelaySchemas.RelayResponse
|
||||
.ContinueWithResult(res => res.Select(p => new RelaySchemas.RelayResponse
|
||||
{
|
||||
Id = p.Id,
|
||||
Inbox = p.Inbox,
|
||||
|
|
|
@ -71,9 +71,7 @@ public class MigrationController(
|
|||
aliasUri ??= await db.Users.IncludeCommonProperties()
|
||||
.Where(p => p.Id == rq.UserId)
|
||||
.FirstOrDefaultAsync()
|
||||
.ContinueWithResultAsync(p => p is null
|
||||
? null
|
||||
: p.Uri ?? p.GetPublicUri(config.Value));
|
||||
.ContinueWithResult(p => p is null ? null : p.Uri ?? p.GetPublicUri(config.Value));
|
||||
}
|
||||
|
||||
if (aliasUri is null) throw GracefulException.NotFound("Alias user not found");
|
||||
|
|
|
@ -95,7 +95,7 @@ public class UserController(
|
|||
.Paginate(pq, ControllerContext)
|
||||
.PrecomputeVisibilities(localUser)
|
||||
.ToListAsync()
|
||||
.ContinueWithResultAsync(res => res.EnforceRenoteReplyVisibility());
|
||||
.ContinueWithResult(res => res.EnforceRenoteReplyVisibility());
|
||||
|
||||
return await noteRenderer.RenderManyAsync(notes, localUser, Filter.FilterContext.Accounts);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Iceshrimp.Backend.Core.Extensions;
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static class TaskExtensions
|
||||
{
|
||||
public static async Task SafeWaitAsync(this Task task, TimeSpan timeSpan)
|
||||
|
@ -58,13 +61,13 @@ public static class TaskExtensions
|
|||
return (await task).ToList();
|
||||
}
|
||||
|
||||
public static async Task ContinueWithResultAsync(this Task task, Action continuation)
|
||||
public static async Task ContinueWithResult(this Task task, Action continuation)
|
||||
{
|
||||
await task;
|
||||
continuation();
|
||||
}
|
||||
|
||||
public static async Task<TNewResult> ContinueWithResultAsync<TNewResult>(
|
||||
public static async Task<TNewResult> ContinueWithResult<TNewResult>(
|
||||
this Task task, Func<TNewResult> continuation
|
||||
)
|
||||
{
|
||||
|
@ -72,25 +75,25 @@ public static class TaskExtensions
|
|||
return continuation();
|
||||
}
|
||||
|
||||
public static async Task ContinueWithResultAsync<TResult>(this Task<TResult> task, Action<TResult> continuation)
|
||||
public static async Task ContinueWithResult<TResult>(this Task<TResult> task, Action<TResult> continuation)
|
||||
{
|
||||
continuation(await task);
|
||||
}
|
||||
|
||||
public static async Task<TNewResult> ContinueWithResultAsync<TResult, TNewResult>(
|
||||
public static async Task<TNewResult> ContinueWithResult<TResult, TNewResult>(
|
||||
this Task<TResult> task, Func<TResult, TNewResult> continuation
|
||||
)
|
||||
{
|
||||
return continuation(await task);
|
||||
}
|
||||
|
||||
public static async Task ContinueWithResultAsync(this Task task, Func<Task> continuation)
|
||||
public static async Task ContinueWithResult(this Task task, Func<Task> continuation)
|
||||
{
|
||||
await task;
|
||||
await continuation();
|
||||
}
|
||||
|
||||
public static async Task<TNewResult> ContinueWithResultAsync<TNewResult>(
|
||||
public static async Task<TNewResult> ContinueWithResult<TNewResult>(
|
||||
this Task task, Func<Task<TNewResult>> continuation
|
||||
)
|
||||
{
|
||||
|
@ -98,12 +101,12 @@ public static class TaskExtensions
|
|||
return await continuation();
|
||||
}
|
||||
|
||||
public static async Task ContinueWithResultAsync<TResult>(this Task<TResult> task, Func<TResult, Task> continuation)
|
||||
public static async Task ContinueWithResult<TResult>(this Task<TResult> task, Func<TResult, Task> continuation)
|
||||
{
|
||||
await continuation(await task);
|
||||
}
|
||||
|
||||
public static async Task<TNewResult> ContinueWithResultAsync<TResult, TNewResult>(
|
||||
public static async Task<TNewResult> ContinueWithResult<TResult, TNewResult>(
|
||||
this Task<TResult> task, Func<TResult, Task<TNewResult>> continuation
|
||||
)
|
||||
{
|
||||
|
|
|
@ -286,7 +286,7 @@ public class DriveService(
|
|||
.Select(p => ProcessAndStoreFileVersionAsync(p.Key, p.Value,
|
||||
request.Filename))
|
||||
.AwaitAllNoConcurrencyAsync()
|
||||
.ContinueWithResultAsync(p => p.ToImmutableArray());
|
||||
.ContinueWithResult(p => p.ToImmutableArray());
|
||||
|
||||
original = processed.FirstOrDefault(p => p?.format.Key == KeyEnum.Original) ??
|
||||
throw new Exception("Image processing didn't result in an original version");
|
||||
|
|
|
@ -247,7 +247,7 @@ public class StorageMaintenanceService(
|
|||
p.PublicAccessKey
|
||||
})
|
||||
.ToArrayAsync()
|
||||
.ContinueWithResultAsync(res => res.SelectMany(p => new List<string?>
|
||||
.ContinueWithResult(res => res.SelectMany(p => new List<string?>
|
||||
{
|
||||
p.AccessKey,
|
||||
p.ThumbnailAccessKey,
|
||||
|
|
Loading…
Add table
Reference in a new issue