diff --git a/Otakians/MainLayout.razor b/Otakians/MainLayout.razor index 5a52ea8..109decd 100644 --- a/Otakians/MainLayout.razor +++ b/Otakians/MainLayout.razor @@ -24,7 +24,7 @@ - + @Body @@ -53,4 +53,9 @@ { await httpClient.PostAsJsonAsync("https://globalchat-4a89f-default-rtdb.europe-west1.firebasedatabase.app/Database/Users.json", new User()); } + + protected override async Task OnInitializedAsync() + { + //Response.Cookies.Append("MyCookie", "value1"); + } } \ No newline at end of file diff --git a/Otakians/Otakians.csproj b/Otakians/Otakians.csproj index 81d178b..c979e28 100644 --- a/Otakians/Otakians.csproj +++ b/Otakians/Otakians.csproj @@ -7,6 +7,7 @@ + diff --git a/Otakians/Pages/Chatting.razor b/Otakians/Pages/Chatting.razor index e6dae78..2a1a7ad 100644 --- a/Otakians/Pages/Chatting.razor +++ b/Otakians/Pages/Chatting.razor @@ -1,9 +1,112 @@ @page "/Chatting" +@using System.Globalization; +@inject NavigationManager NavManager +@inject HttpClient Http + - - Test + + + + + @if (messages != null) + { + @for (int i = 0; i < messages.Length; i++) + { + Message message = messages[i]; + + + + + @message.Content + @("@" + message.Name) + + @(DateTime.Now.ToString("dd/MM/yyyy HH:mm", danishCulture)) + + + } + } + + + + + World! + @("@Alex") + + @(DateTime.Now.ToString("dd/MM/yyyy HH:mm", danishCulture)) + + + + + + + How about a longer thing here?!?!?! Test testes tetst estestse testset estsete stestest + @("@Adam") + + @(DateTime.Now.ToString("dd/MM/yyyy HH:mm", danishCulture)) + + + + + + + It is working! + @("@Alex") + + @(DateTime.Now.ToString("dd/MM/yyyy HH:mm", danishCulture)) + + + + + + + + @if (isSending) + { + + } + else + { + + } + Send + + + @code { + string TextValue = ""; + bool isSending = false; + CultureInfo danishCulture = new CultureInfo("da-DK"); + async void SendMessage() + { + isSending = true; + StateHasChanged(); + await Task.Delay(3000); + //isSending = false; + messages = null; + NavManager.NavigateTo("/"); + NavManager.NavigateTo("/Chatting"); + } + + Message[]? messages; + + protected override async Task OnInitializedAsync() + { + if (messages == null) + messages = (await Http.GetFromJsonAsync("https://globalchat-4a89f-default-rtdb.europe-west1.firebasedatabase.app/Database/Messages.json")); + + //for (int i = 0; i < messages.Length; i++) + //{ + // Console.WriteLine($"Name: {messages[i].Name} Content: {messages[i].Content}"); + //} + } + + public class Message + { + public string? Content { get; set; } + public long DatePosted { get; set; } + public string? Name { get; set; } + } } \ No newline at end of file