a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[frontend+backend] Editing supports polls and media now - Side fix: Delete & Redraft attaches media now (I don't know if this was intended or not, but according to the code I feel like it was) - This might need to be looked at: When sending response(s) to API endpoints with notes, the attachments have their ID property sent back, this is needed to re-attach media

Lunya 83dcf60d 29a3d177

+85 -24
+17 -4
Iceshrimp.Backend/Controllers/Web/NoteController.cs
··· 732 732 .FirstOrDefaultAsync(p => p.Id == id && p.User == user) 733 733 ?? throw GracefulException.RecordNotFound(); 734 734 735 - if (note.Text == request.Text && note.Cw == request.Cw) 736 - throw GracefulException.BadRequest("Text and CW are unchanged"); 737 - 738 735 note.Text = request.Text ?? note.Text; 739 736 note.Cw = request.Cw ?? note.Cw; 737 + 738 + var attachments = request.MediaIds != null 739 + ? await db.DriveFiles.Where(p => request.MediaIds.Contains(p.Id)).ToListAsync() 740 + : null; 740 741 742 + var minPollExpire = DateTime.UtcNow.AddMinutes(5); 743 + var poll = request.Poll != null 744 + ? new Poll 745 + { 746 + ExpiresAt = request.Poll.ExpiresAt != null 747 + ? request.Poll.ExpiresAt <= minPollExpire ? minPollExpire : request.Poll.ExpiresAt 748 + : null, 749 + Multiple = request.Poll.Multiple, 750 + Choices = request.Poll.Choices, 751 + } 752 + : null; 753 + 741 754 await noteSvc.UpdateNoteAsync(new NoteService.NoteUpdateData 742 755 { 743 - Note = note, Text = request.Text, Cw = request.Cw 756 + Note = note, Text = request.Text, Cw = request.Cw, Attachments = attachments, Poll = poll 744 757 }); 745 758 746 759 return await noteRenderer.RenderOne(note, user);
+52 -6
Iceshrimp.Frontend/Components/Compose.razor
··· 315 315 NoteDraft.Text = note.Text ?? ""; 316 316 NoteDraft.Cw = note.Cw; 317 317 NoteDraft.Visibility = note.Visibility; 318 - NoteDraft.MediaIds = note.Attachments.Select(p => p.Id).ToList(); 318 + foreach (var attachment in note.Attachments) 319 + { 320 + Attachments.Add(new DriveFileResponse 321 + { 322 + Id = attachment.Id, 323 + ContentType = attachment.ContentType, 324 + Description = attachment.AltText, 325 + Filename = attachment.FileName, 326 + IsAvatar = false, 327 + IsBanner = false, 328 + Sensitive = attachment.IsSensitive, 329 + ThumbnailUrl = attachment.ThumbnailUrl, 330 + Url = attachment.Url 331 + }); 332 + } 319 333 NoteDraft.RenoteId = note.RenoteId; 320 334 NoteDraft.ReplyId = note.ReplyId; 321 335 UploadingFiles = 0; ··· 326 340 public async Task OpenDialogEdit(NoteBase note) 327 341 { 328 342 await ResetState(); 329 - NoteId = note.Id; 330 - NoteDraft.Text = note.Text ?? ""; 331 - NoteDraft.Cw = note.Cw; 332 - UploadingFiles = 0; 343 + NoteId = note.Id; 344 + NoteDraft.Text = note.Text ?? ""; 345 + NoteDraft.Cw = note.Cw; 346 + if (note.Poll != null) 347 + { 348 + NoteDraft.Poll = new PollRequest { ExpiresAt = note.Poll.ExpiresAt, Choices = note.Poll.Choices.Select(x => x.Value).ToList(), Multiple = note.Poll.Multiple }; 349 + PollChoices = note.Poll.Choices.Select(x => new Choice {Value = x.Value}).ToList(); 350 + PollEntry = ""; 351 + PollExpires = note.Poll.ExpiresAt is null ? PollExpire.Never : PollExpire.ExpiresAt; 352 + PollExpireTime = note.Poll.ExpiresAt ?? DateTime.Now; 353 + PollExpireLen = ((note.Poll.ExpiresAt ?? DateTime.Now) - DateTime.Now).Days; 354 + PollExpiresAft = PollExpireAfter.Days; 355 + } 356 + UploadingFiles = 0; 357 + foreach (var attachment in note.Attachments) 358 + { 359 + Attachments.Add(new DriveFileResponse 360 + { 361 + Id = attachment.Id, 362 + ContentType = attachment.ContentType, 363 + Description = attachment.AltText, 364 + Filename = attachment.FileName, 365 + IsAvatar = false, 366 + IsBanner = false, 367 + Sensitive = attachment.IsSensitive, 368 + ThumbnailUrl = attachment.ThumbnailUrl, 369 + Url = attachment.Url 370 + }); 371 + } 333 372 StateHasChanged(); 334 373 await JsSvc.ShowDialogAsync(Dialog, false); 335 374 } ··· 408 447 PastedText = null; 409 448 SendButton.State = StateButton.StateEnum.Initial; 410 449 AttachedQuote = null; 450 + NoteId = null; 411 451 412 452 if (EmojiList.Count == 0) 413 453 EmojiList = await EmojiService.GetEmojiAsync(); ··· 452 492 try 453 493 { 454 494 if (NoteId != null) 455 - await ApiService.Notes.EditNoteAsync(NoteId, NoteDraft); 495 + await ApiService.Notes.EditNoteAsync(NoteId, new NoteUpdateRequest 496 + { 497 + Text = NoteDraft.Text, 498 + Cw = NoteDraft.Cw, 499 + Poll = NoteDraft.Poll, 500 + MediaIds = NoteDraft.MediaIds 501 + }); 456 502 else 457 503 await ApiService.Notes.CreateNoteAsync(NoteDraft); 458 504 }
+1 -1
Iceshrimp.Frontend/Components/Note/NoteFooter.razor
··· 146 146 <hr class="rule"/> 147 147 @if (Note.User.Id == Session.Current?.Id) 148 148 { 149 - <MenuElement Icon="Icons.Pencil" OnSelect="Edit" Danger> 149 + <MenuElement Icon="Icons.Pencil" OnSelect="Edit"> 150 150 <Text>@Loc["Edit"]</Text> 151 151 </MenuElement> 152 152 <MenuElement Icon="Icons.Eraser" OnSelect="Redraft" Danger>
+1 -1
Iceshrimp.Frontend/Core/ControllerModels/NoteControllerModel.cs
··· 96 96 public Task ReportNoteAsync(string id, NoteReportRequest request) => 97 97 api.CallAsync(HttpMethod.Post, $"/notes/{id}/report", data: request); 98 98 99 - public Task EditNoteAsync(string id, NoteCreateRequest noteDraft) => 99 + public Task EditNoteAsync(string id, NoteUpdateRequest noteDraft) => 100 100 api.CallAsync(HttpMethod.Put, $"/notes/{id}", data: noteDraft); 101 101 }
+8 -8
Iceshrimp.Shared/Schemas/Web/NoteResponse.cs
··· 54 54 55 55 public class NoteAttachment 56 56 { 57 - [JI] public required string Id; 58 - public required string Url { get; set; } 59 - public required string ThumbnailUrl { get; set; } 60 - public required string ContentType { get; set; } 61 - public required bool IsSensitive { get; set; } 62 - public required string? Blurhash { get; set; } 63 - public required string? AltText { get; set; } 64 - public required string FileName { get; set; } 57 + public required string Id { get; set; } 58 + public required string Url { get; set; } 59 + public required string ThumbnailUrl { get; set; } 60 + public required string ContentType { get; set; } 61 + public required bool IsSensitive { get; set; } 62 + public required string? Blurhash { get; set; } 63 + public required string? AltText { get; set; } 64 + public required string FileName { get; set; } 65 65 } 66 66 67 67 public class NotePollSchema
+6 -4
Iceshrimp.Shared/Schemas/Web/NoteUpdateRequest.cs
··· 2 2 3 3 public class NoteUpdateRequest 4 4 { 5 - public required string Id { get; set; } 6 - 7 - public string? Text { get; set; } 8 - public string? Cw { get; set; } 5 + public string? Text { get; set; } 6 + public string? Cw { get; set; } 7 + 8 + public List<string>? MediaIds { get; set; } 9 + 10 + public PollRequest? Poll { get; set; } 9 11 }