Proper Ephemeral Integration 🥳
This commit is contained in:
parent
efa31a414c
commit
b1cb4e21c4
6 changed files with 98 additions and 2 deletions
58
Components/NewEphemeral.razor
Normal file
58
Components/NewEphemeral.razor
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
@inject State State
|
||||||
|
@inject RestService api
|
||||||
|
@inject NavigationManager navigationManager
|
||||||
|
|
||||||
|
<div class="overlay @(Active ? "active" : string.Empty)" data-ui="#@id"></div>
|
||||||
|
<dialog id="@id" class="@(Active ? "active" : string.Empty)" open="@Active">
|
||||||
|
<h5>Share a fleeting thought</h5>
|
||||||
|
<div class="row">
|
||||||
|
<div class="field textarea border max">
|
||||||
|
<InputTextArea @bind-Value="Content"></InputTextArea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<p>Your anonymous post will be shared for a while, and then it will disappear forever. It can’t be edited, so take care before submitting.</p>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<p><strong>If you need help, don’t suffer in silence. <a href="https://www.helpguide.org/find-help.htm">Talk to someone right now</a>.</strong></p>
|
||||||
|
</div>
|
||||||
|
<nav class="right-align no-space">
|
||||||
|
<button class="transparent link" data-ui="#@id" disabled="@loading">Cancel</button>
|
||||||
|
<button @onclick="PostEphemeral" disabled="@loading">
|
||||||
|
@if (loading) {
|
||||||
|
<span>Saving...</span>
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
<i class="fa-solid fa-floppy-disk"></i> <span>Save</span>
|
||||||
|
}
|
||||||
|
</button>
|
||||||
|
</nav>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string id { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public bool Active { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public string Content { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private bool loading = false;
|
||||||
|
|
||||||
|
public async Task PostEphemeral() {
|
||||||
|
loading = true;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
var result = await api.PostEphemeral(Content);
|
||||||
|
if (result != null) {
|
||||||
|
await State.RefreshStatuses();
|
||||||
|
State.SendRefresh();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Active = false;
|
||||||
|
await JS.InvokeVoidAsync("ui", "#" + id);
|
||||||
|
Content = string.Empty;
|
||||||
|
loading = false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,15 @@
|
||||||
<Description><a href="https://eph.emer.al">Eph.emer.al</a> is a place for fleeting thoughts. Everything on this page will disappear after a while.</Description>
|
<Description><a href="https://eph.emer.al">Eph.emer.al</a> is a place for fleeting thoughts. Everything on this page will disappear after a while.</Description>
|
||||||
</PageHeading>
|
</PageHeading>
|
||||||
|
|
||||||
|
<AuthorizeView>
|
||||||
|
<Authorized>
|
||||||
|
<button class="fab circle extra large-elevate" data-ui="#ephemeral-modal">
|
||||||
|
<i class="fa-light fa-comment-plus"></i>
|
||||||
|
</button>
|
||||||
|
<NewEphemeral id="ephemeral-modal"></NewEphemeral>
|
||||||
|
</Authorized>
|
||||||
|
</AuthorizeView>
|
||||||
|
|
||||||
<div id="ephemeral" class="responsive">
|
<div id="ephemeral" class="responsive">
|
||||||
|
|
||||||
@if (messages != null) {
|
@if (messages != null) {
|
||||||
|
|
11
Models/EphemeralData.cs
Normal file
11
Models/EphemeralData.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Neighbourhood.omg.lol.Models {
|
||||||
|
public class EphemeralData {
|
||||||
|
public string Content { get; set; }
|
||||||
|
}
|
||||||
|
}
|
12
Models/EphemeralResponseData.cs
Normal file
12
Models/EphemeralResponseData.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Neighbourhood.omg.lol.Models {
|
||||||
|
public class EphemeralResponseData : IOmgLolResponseData {
|
||||||
|
public string Message { get; set; }
|
||||||
|
public List<string> Content { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ using System.Text.Json;
|
||||||
namespace Neighbourhood.omg.lol.Models {
|
namespace Neighbourhood.omg.lol.Models {
|
||||||
public class State : INotifyPropertyChanged {
|
public class State : INotifyPropertyChanged {
|
||||||
// Feature flags
|
// Feature flags
|
||||||
public bool FeatureFollowing { get; } = true;
|
public bool FeatureFollowing { get; } = false;
|
||||||
// Main data lists
|
// Main data lists
|
||||||
public List<Status>? Statuses { get; set; }
|
public List<Status>? Statuses { get; set; }
|
||||||
public List<Pic>? Pics { get; set; }
|
public List<Pic>? Pics { get; set; }
|
||||||
|
|
|
@ -219,7 +219,13 @@ namespace Neighbourhood.omg.lol {
|
||||||
public async Task<BasicResponseData?> PostNowPage(string address, string content, bool listed) =>
|
public async Task<BasicResponseData?> PostNowPage(string address, string content, bool listed) =>
|
||||||
await Post<BasicResponseData, NowContentData>($"/address/{address}/now", new NowContentData { Content = content, Listed = listed ? 1 : 0 });
|
await Post<BasicResponseData, NowContentData>($"/address/{address}/now", new NowContentData { Content = content, Listed = listed ? 1 : 0 });
|
||||||
|
|
||||||
public async Task<List<MarkupString>> Ephemeral() {
|
public async Task<List<MarkupString>> Ephemeral() =>
|
||||||
|
(await Get<EphemeralResponseData>($"/ephemeral"))?.Content?.Select(s => (MarkupString)s)?.ToList() ?? new List<MarkupString>();
|
||||||
|
|
||||||
|
public async Task<BasicResponseData?> PostEphemeral(string content) =>
|
||||||
|
await Post<BasicResponseData, EphemeralData>("/ephemeral", new EphemeralData { Content = content });
|
||||||
|
|
||||||
|
public async Task<List<MarkupString>> EphemeralScrape() {
|
||||||
List<string> notes = new List<string>();
|
List<string> notes = new List<string>();
|
||||||
Uri Uri = new Uri($"https://eph.emer.al/");
|
Uri Uri = new Uri($"https://eph.emer.al/");
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue