The pages and components now use the daisyUI wrappers and the neo-* utilities instead of Bulma and the neomorph classes: - buttons are DButton, with pressed states as Active; - nav links are btn / btn-active; - the filter and composer selects are DSelect with a prefix icon; - the composer's fields are DInput and DTextarea; - the message options and scope pickers are DDropdown, which now close on an outside click and on Escape; - the settings and admin sections are DCollapse; - the dark-mode switch is a DToggle with sun and moon icons; - the hue slider is a DRange on the rainbow track. DropdownButton, OpenDownContainer and LoadingData are gone. The loader is DLoading, whose animation runs; the old one's keyframes were never defined. Icons coloured with Bulma's has-text-* now get daisyUI's text-info, success, warning and error, which had no rules before. Tailwind 3 to 4 fixes: - space-x/y become gap, which also handles the flex-col-reverse feeds; - !rounded-lg becomes rounded-lg!; - drop-shadow becomes drop-shadow-sm; - text-md becomes text-base. The thread page marks its message with Content's new Highlighted parameter rather than a second shadow size. neo.css: a select's prefix icon gets the room daisyUI leaves for a span.label, and the inner select lets the well show through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
259 lines
7.9 KiB
Plaintext
259 lines
7.9 KiB
Plaintext
@page "/"
|
|
@page "/home"
|
|
@page "/index"
|
|
@inherits LocalizableComponentBase
|
|
<Title>@Localizer["Index"]</Title>
|
|
|
|
<div class="flex w-full h-full flex-col gap-4">
|
|
|
|
<section class="block relative w-full h-full neo-inset neo-xs rounded-xl">
|
|
<div class="flex flex-col gap-4 p-4 md:p-5 w-full h-full absolute overflow-y-auto @SUtility.IfTrueThen(TimeSortingType is TimeSortingType.Descending, "flex-col-reverse")">
|
|
|
|
@if (IsLoading)
|
|
{
|
|
<p class="flex w-full items-center justify-center gap-2">
|
|
<DLoading Variant="DLoadingVariant.Dots" LabelText="@Localizer["loading"]" />
|
|
@Localizer["loading"]
|
|
</p>
|
|
}
|
|
else if (Messages.Count == 0)
|
|
{
|
|
<p class="w-full text-center text-lg">
|
|
<i class="ion-ios-remove-circle-outline"></i> @Localizer["Empty"]
|
|
</p>
|
|
}
|
|
|
|
@foreach (var message in Messages)
|
|
{
|
|
<Content Message="message"
|
|
OnMessageBoost="async (m) => await OnMessageBoost(m)" OnMessageDelete="async (m) => await OnMessageDelete(m)"
|
|
OnMessageFavourite="async (m) => await OnMessageFavourite(m)" OnMessageReply="async (m) => await OnMessageReply(m)"
|
|
OnMessageMediaDownload="async (m) => await OnMessageMediaDownload(m)"
|
|
OnUserBlock="async (u) => await OnUserBlock(u)" OnUserDirectMessage="async (u) => await OnUserDirectMessage(u)" OnUserSilence="async (u) => await OnUserSilence(u)" />
|
|
}
|
|
@*<AuthorizeView>
|
|
<Authorized>
|
|
@foreach (var message in Messages)
|
|
{
|
|
<Content Message="message"
|
|
OnMessageReply="(m) => OnMessageReply(m)" OnMessageBoost="(m) => OnMessageBoost(m)"
|
|
OnMessageFavourite="(m) => OnMessageFavourite(m)" OnMessageDelete="(m) => OnMessageDelete(m)"
|
|
OnUserBlock="(u) => OnUserBlock(u)" OnUserDirectMessage="(u) => OnUserDirectMessage(u)" OnUserMute="(u) => OnUserMute(u)" />
|
|
}
|
|
</Authorized>
|
|
<NotAuthorized>
|
|
@foreach (var message in Messages)
|
|
{
|
|
<Content Message="message" OnMessageReply="(m) => OnMessageReply(m)" />
|
|
}
|
|
</NotAuthorized>
|
|
</AuthorizeView>*@
|
|
|
|
|
|
</div>
|
|
</section>
|
|
|
|
<ActionBar OnMessageSubmit="OnMessageSubmit" OnTimelineChanged="OnTimelineChanged" OnTimeSortingChanged="OnTimeSortingChanged" />
|
|
|
|
</div>
|
|
|
|
@code {
|
|
[CascadingParameter] Task<AuthenticationState> AuthState { get; set; }
|
|
[CascadingParameter] CascadingState CascadingState { get; set; }
|
|
[Inject] IBlazorDownloadFileService BlazorDownloadFileService { get; set; }
|
|
[Inject] IStorage Storage { get; set; }
|
|
[Inject] ILocalStorageService LocalStorage { get; set; }
|
|
[Inject] HttpClient Http { get; set; }
|
|
[Inject] MessagesService MessagesService { get; set; }
|
|
|
|
TimelineType TimelineType { get; set; } = TimelineType.Home;
|
|
TimeSortingType TimeSortingType { get; set; } = TimeSortingType.Ascending;
|
|
|
|
IReadOnlyList<Claim> userClaim
|
|
{
|
|
get
|
|
{
|
|
var auth = AuthState.Result;
|
|
if (auth.User.Identity?.IsAuthenticated ?? false)
|
|
return auth.User.Claims.ToList();
|
|
return new List<Claim>();
|
|
}
|
|
}
|
|
|
|
List<Message> IncomingMessages { get; set; } = new();
|
|
List<Message> Messages { get; set; } = new();
|
|
string Response { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
var filters = await LocalStorage.GetItemAsync<ActionBarFilter>(nameof(ActionBarFilter));
|
|
if (filters == default)
|
|
await LocalStorage.SetItemAsync(nameof(ActionBarFilter), new ActionBarFilter());
|
|
else
|
|
{
|
|
TimelineType = filters.TimelineType;
|
|
TimeSortingType = filters.TimeSortingType;
|
|
}
|
|
|
|
Messages = await Storage.GetMessages();
|
|
//try
|
|
//{
|
|
// var response = await Http.GetAsync("api/test");
|
|
// Response = await response.Content.ReadAsStringAsync();
|
|
//}
|
|
//catch
|
|
//{
|
|
//}
|
|
IsLoading = false;
|
|
}
|
|
|
|
void OnTimelineChanged(TimelineType timelineType)
|
|
{
|
|
TimelineType = timelineType;
|
|
}
|
|
|
|
void OnTimeSortingChanged(TimeSortingType timeSortingType)
|
|
{
|
|
TimeSortingType = timeSortingType;
|
|
}
|
|
|
|
async Task OnMessageSubmit(MessageForm messageForm)
|
|
{
|
|
await Task.Run(() =>
|
|
{
|
|
});
|
|
var submitMessage = await MessagesService.SubmitMessage(messageForm);
|
|
Messages.Insert(0, new()
|
|
{
|
|
MessageId = Guid.NewGuid().ToString(),
|
|
Content = messageForm.Content?.ParseContent(messageForm.ContentType),
|
|
CreatedAt = DateTime.UtcNow,
|
|
MessageType = messageForm.MessageType,
|
|
Medias = messageForm.Media.Select(m => new Media
|
|
{
|
|
FileName = m.FileName,
|
|
AltText = m.AltText,
|
|
ContentType = m.ContentType,
|
|
Url = m.Base64Preview,
|
|
Blob = m.Blob
|
|
}).ToList(),
|
|
Title = messageForm.Title,
|
|
User = new MessageUser
|
|
{
|
|
UserId = CascadingState.User.Id,
|
|
UserName = CascadingState.User.UserName,
|
|
DisplayName = CascadingState.User.DisplayName,
|
|
PictureUrl = CascadingState.User.PictureUrl,
|
|
ProfileUrl = CascadingState.User.ProfileUrl,
|
|
BackgroundUrl = CascadingState.User.BackgroundUrl
|
|
},
|
|
});
|
|
}
|
|
|
|
async Task OnMessageReply(MessageForm messageForm)
|
|
{
|
|
await Task.Run(() =>
|
|
{
|
|
});
|
|
var replyMessage = await MessagesService.SubmitMessage(messageForm);
|
|
Messages.Insert(0, new()
|
|
{
|
|
RootMessageId = messageForm.RootMessageId,
|
|
MessageId = Guid.NewGuid().ToString(),
|
|
Content = messageForm.Content?.ParseContent(messageForm.ContentType),
|
|
CreatedAt = DateTime.UtcNow,
|
|
MessageType = messageForm.MessageType,
|
|
Medias = messageForm.Media.Select(m => new Media
|
|
{
|
|
FileName = m.FileName,
|
|
AltText = m.AltText,
|
|
ContentType = m.ContentType,
|
|
Url = m.Base64Preview,
|
|
Blob = m.Blob
|
|
}).ToList(),
|
|
Title = messageForm.Title,
|
|
User = new MessageUser
|
|
{
|
|
UserId = CascadingState.User.Id,
|
|
UserName = CascadingState.User.UserName,
|
|
DisplayName = CascadingState.User.DisplayName,
|
|
PictureUrl = CascadingState.User.PictureUrl,
|
|
ProfileUrl = CascadingState.User.ProfileUrl,
|
|
BackgroundUrl = CascadingState.User.BackgroundUrl
|
|
}
|
|
});
|
|
}
|
|
|
|
async ValueTask OnMessageBoost(Message message)
|
|
{
|
|
var boostedMessageTemp = await MessagesService.BoostUnboostMessage(message);
|
|
message.BoostsCounter = message.IsBoostedByCurrentUser ? message.BoostsCounter - 1 : message.BoostsCounter + 1;
|
|
message.IsBoostedByCurrentUser = !message.IsBoostedByCurrentUser;
|
|
if (message.IsBoostedByCurrentUser)
|
|
{
|
|
var boostedMessage = new Message
|
|
{
|
|
BoostingUser = new()
|
|
{
|
|
UserId = CascadingState.User.Id,
|
|
DisplayName = CascadingState.User.DisplayName,
|
|
PictureUrl = CascadingState.User.PictureUrl,
|
|
ProfileUrl = CascadingState.User.ProfileUrl,
|
|
UserName = CascadingState.User.UserName
|
|
},
|
|
BoostsCounter = message.BoostsCounter,
|
|
Content = message.Content,
|
|
CreatedAt = message.CreatedAt,
|
|
IsBoostedByCurrentUser = true,
|
|
IsFavourite = message.IsFavourite,
|
|
Medias = message.Medias,
|
|
MessageId = message.MessageId,
|
|
MessageType = message.MessageType,
|
|
RootMessageId = message.RootMessageId,
|
|
Title = message.Title,
|
|
User = message.User
|
|
};
|
|
Messages.Insert(0, boostedMessage);
|
|
}
|
|
else
|
|
{
|
|
Messages.RemoveAll(m => m.MessageId == message.MessageId && m.BoostingUser != null && m.BoostingUser.UserId == CascadingState.User.Id);
|
|
}
|
|
}
|
|
|
|
async ValueTask OnMessageFavourite(Message message)
|
|
{
|
|
message.IsFavourite = !message.IsFavourite;
|
|
var favouriteMessage = await MessagesService.FavouriteUnfavouriteMessage(message);
|
|
}
|
|
|
|
async ValueTask OnMessageDelete(Message message)
|
|
{
|
|
Messages.Remove(message);
|
|
var deleteResult = await MessagesService.DeleteMessage(message);
|
|
}
|
|
|
|
async ValueTask OnMessageMediaDownload(Media media)
|
|
{
|
|
await Task.Run(() =>
|
|
{
|
|
});
|
|
await BlazorDownloadFileService.DownloadFileAsync(media.FileName, media.Blob, media.ContentType);
|
|
}
|
|
|
|
async ValueTask OnUserBlock(MessageUser messageUser)
|
|
{
|
|
var blockResult = await MessagesService.BlockUserFromMessage(messageUser);
|
|
}
|
|
|
|
async ValueTask OnUserDirectMessage(Message message)
|
|
{
|
|
var directMessage = await MessagesService.ReplyMessage(message, MessageType.Direct);
|
|
}
|
|
|
|
async ValueTask OnUserSilence(MessageUser messageUser)
|
|
{
|
|
var silenceResult = await MessagesService.SilenceUserFromMessage(messageUser);
|
|
}
|
|
|
|
} |