From 815f54c7d06e89ed900b8e68e227ac142e1e9892 Mon Sep 17 00:00:00 2001 From: itailiors <78041027+itailiors@users.noreply.github.com> Date: Fri, 16 Aug 2024 04:45:06 +0300 Subject: [PATCH 1/4] fixes for issue 103 and 132 --- src/Angor/Client/Pages/Founder.razor | 91 +++++++++++----------- src/Angor/Client/Pages/Invest.razor | 20 ++++- src/Angor/Client/Pages/View.razor | 30 ++++++- src/Angor/Client/Storage/ClientStorage.cs | 5 ++ src/Angor/Client/Storage/IClientStorage.cs | 1 + 5 files changed, 96 insertions(+), 51 deletions(-) diff --git a/src/Angor/Client/Pages/Founder.razor b/src/Angor/Client/Pages/Founder.razor index 98426951..82ad6970 100644 --- a/src/Angor/Client/Pages/Founder.razor +++ b/src/Angor/Client/Pages/Founder.razor @@ -43,41 +43,38 @@ @if (founderProjects.Count == 0) { -
-
-
+
+
+
- No projects found. -
-
-
-
-
- -
- -
- + No projects found.
+
} -else +@if (founderProjects.Count > 0) { -
- @foreach (var project in founderProjects) - { - - } -
- +
+ @foreach (var project in founderProjects) + { + + } +
} +
+
+
+ +
+
+
@code { private string founderKey; @@ -105,15 +102,16 @@ else { scanningForProjects = true; + // Clear the existing projects before rescan + founderProjects.Clear(); + storage.ClearFounderProjects(); + var keys = _walletStorage.GetFounderKeys(); var founderProjectsToLookup = new Dictionary(); foreach (var key in keys.Keys) { - if (founderProjects.Exists(_ => _.ProjectInfo.ProjectIdentifier == key.ProjectIdentifier)) - continue; - var indexerProject = await _IndexerService.GetProjectByIdAsync(key.ProjectIdentifier); if (indexerProject == null) @@ -123,6 +121,7 @@ else } if (founderProjectsToLookup.Any()) + { RelayService.RequestProjectCreateEventsByPubKey(e => { switch (e) @@ -132,30 +131,32 @@ else var founderProject = founderProjects.FirstOrDefault(_ => _.ProjectInfo.NostrPubKey == e.Pubkey); if (founderProject != null && founderProject.Metadata is null) founderProject.Metadata = nostrMetadata; - // else - // notificationComponent.ShowNotificationMessage($"Couldn't find the project details for the project {nostrMetadata.Name} try adding the missing relay."); //TODO break; + case { Kind: NostrKind.ApplicationSpecificData }: var projectInfo = serializer.Deserialize(e.Content); - if (founderProjects.All(_ => _.ProjectInfo.NostrPubKey != e.Pubkey)) //Getting events from multiple relays + if (founderProjects.All(_ => _.ProjectInfo.NostrPubKey != e.Pubkey)) founderProjects.Add(new FounderProject - { - ProjectInfo = projectInfo, - ProjectIndex = founderProjectsToLookup.Keys.ToList().IndexOf(e.Pubkey) + 1, - CreationTransactionId = founderProjectsToLookup[e.Pubkey].TrxId - }); + { + ProjectInfo = projectInfo, + ProjectIndex = founderProjectsToLookup.Keys.ToList().IndexOf(e.Pubkey) + 1, + CreationTransactionId = founderProjectsToLookup[e.Pubkey].TrxId + }); break; } }, - () => - { - scanningForProjects = false; - storage.AddFounderProject(founderProjects.ToArray()); - StateHasChanged(); - }, - founderProjectsToLookup.Keys.ToArray()); + () => + { + scanningForProjects = false; + storage.AddFounderProject(founderProjects.ToArray()); + StateHasChanged(); + }, + founderProjectsToLookup.Keys.ToArray()); + } else + { scanningForProjects = false; + } } private void NavigateToCreateProject() diff --git a/src/Angor/Client/Pages/Invest.razor b/src/Angor/Client/Pages/Invest.razor index aed4f011..704afbce 100644 --- a/src/Angor/Client/Pages/Invest.razor +++ b/src/Angor/Client/Pages/Invest.razor @@ -71,8 +71,24 @@ - - @if(project is not InvestorProject investorProject) + @if (@project.ProjectInfo.StartDate < DateTime.UtcNow) //TODO: what should the order be here? if an investor has a signed trx that he has not invested yet, and the project has started, could he invest? + { +
+

Investing Period is Over

+

The investing period for this project ended on @project.ProjectInfo.ExpiryDate.ToString("dd/MM/yyyy").

+

You can no longer invest in this project.

+

Here are some details:

+
    +
  • Project ID: @project.ProjectInfo.ProjectIdentifier
  • +
  • Target Amount: @project.ProjectInfo.TargetAmount BTC
  • +
  • Start Date: @project.ProjectInfo.StartDate.ToString("dd/MM/yyyy")
  • +
  • End Date: @project.ProjectInfo.ExpiryDate.ToString("dd/MM/yyyy")
  • +
  • Total Stages: @project.ProjectInfo.Stages.Count
  • +
+

If you are already invested, you will continue to receive updates on the project's progress.

+
+ } + else if(project is not InvestorProject investorProject) {
diff --git a/src/Angor/Client/Pages/View.razor b/src/Angor/Client/Pages/View.razor index d35546fb..ecefc208 100644 --- a/src/Angor/Client/Pages/View.razor +++ b/src/Angor/Client/Pages/View.razor @@ -114,7 +114,7 @@
@{ - int startsInDays = (project.ProjectInfo.StartDate - DateTime.Now).Days; + int startsInDays = (project.ProjectInfo.StartDate - DateTime.UtcNow).Days; if (startsInDays > 0) { @@ -165,7 +165,16 @@ @*

Total Seeders: @projectStats.TotalSeeders

*@
-

Time Left for Investing: @projectStats.TimeLeft days

+

+ @if (projectStats.TimeLeft > 0) + { + Time Left for Investing: @projectStats.TimeLeft days + } + else + { + The investing period is over + } +

}
@@ -284,8 +293,21 @@

Seize the opportunity to invest in this project.

- +
+ }
@@ -510,7 +532,7 @@ projectStats.TotalInvestors = (int)data.InvestorCount; projectStats.TotalRaised = data.AmountInvested; - projectStats.TimeLeft = (project.ProjectInfo.ExpiryDate - DateTime.UtcNow).Days; + projectStats.TimeLeft = (project.ProjectInfo.StartDate - DateTime.UtcNow).Days; if (projectStats.TimeLeft < 0) projectStats.TimeLeft = 0; diff --git a/src/Angor/Client/Storage/ClientStorage.cs b/src/Angor/Client/Storage/ClientStorage.cs index 68f57d5e..586238a3 100644 --- a/src/Angor/Client/Storage/ClientStorage.cs +++ b/src/Angor/Client/Storage/ClientStorage.cs @@ -93,6 +93,11 @@ public void AddFounderProject(params FounderProject[] projects) _storage.SetItem("founder-projects", ret.OrderBy(_ => _.ProjectIndex)); } + + public void ClearFounderProjects() + { + _storage.SetItem("founder-projects", new List()); + } public List GetFounderProjects() { diff --git a/src/Angor/Client/Storage/IClientStorage.cs b/src/Angor/Client/Storage/IClientStorage.cs index 45fb8d26..0383960a 100644 --- a/src/Angor/Client/Storage/IClientStorage.cs +++ b/src/Angor/Client/Storage/IClientStorage.cs @@ -17,6 +17,7 @@ public interface IClientStorage void AddFounderProject(params FounderProject[] projects); + void ClearFounderProjects(); List GetFounderProjects(); FounderProject? GetFounderProjects(string projectIdentifier); void UpdateFounderProject(FounderProject project); From bbd2c8d275553ddf5942e756a0156ca500cb5cd1 Mon Sep 17 00:00:00 2001 From: itailiors <78041027+itailiors@users.noreply.github.com> Date: Fri, 16 Aug 2024 10:29:58 +0300 Subject: [PATCH 2/4] add option to have decimal stage --- src/Angor/Client/Pages/Create.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Angor/Client/Pages/Create.razor b/src/Angor/Client/Pages/Create.razor index 5c4c6eb5..ec30f71a 100644 --- a/src/Angor/Client/Pages/Create.razor +++ b/src/Angor/Client/Pages/Create.razor @@ -156,7 +156,7 @@
- +
From e08c66060ff87a2d3a226c7a4b417898a691a26c Mon Sep 17 00:00:00 2001 From: itailiors <78041027+itailiors@users.noreply.github.com> Date: Thu, 5 Sep 2024 02:18:32 +0300 Subject: [PATCH 3/4] cleanup and reformat --- src/Angor/Client/Pages/Founder.razor | 103 +++++++++++++-------------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/src/Angor/Client/Pages/Founder.razor b/src/Angor/Client/Pages/Founder.razor index 2c2d2d54..ed17b372 100644 --- a/src/Angor/Client/Pages/Founder.razor +++ b/src/Angor/Client/Pages/Founder.razor @@ -1,8 +1,8 @@ @page "/founder" +@using Angor.Client.Models @using Angor.Client.Storage @using Angor.Shared.Models @using Angor.Shared.Services -@using Angor.Client.Models @using Nostr.Client.Messages @inject NavigationManager NavigationManager @@ -12,11 +12,11 @@ @inject IIndexerService _IndexerService @inject ISerializer serializer - + @if (!hasWallet) { - NavigationManager.NavigateTo($"/wallet"); + NavigationManager.NavigateTo("/wallet"); return; } @@ -25,13 +25,13 @@
- +
Founder
- +
-
+

- To create a new project or view your existing projects, an on-chain transaction and a Nostr DID are required. -

+ To create a new project or view your existing projects, an on-chain transaction and a Nostr DID are required. +

@if (founderProjects.Count == 0) { -
-
-
+
+
+
- + - No projects found. + No projects found. +
-
} @if (founderProjects.Count > 0) { -
- @foreach (var project in founderProjects) - { - - } -
+
+ @foreach (var project in founderProjects) + { + + } +
}
@@ -76,7 +76,7 @@ - @((founderProjects.Count == 0) ? "Scan for founder projects" : "Rescan founder projects") + @(founderProjects.Count == 0 ? "Scan for founder projects" : "Rescan founder projects")
@@ -92,8 +92,6 @@ private NotificationComponent notificationComponent; - - protected override async Task OnInitializedAsync() { hasWallet = _walletStorage.HasWallet(); @@ -110,7 +108,7 @@ // Clear the existing projects before rescan founderProjects.Clear(); - storage.ClearFounderProjects(); + storage.ClearFounderProjects(); var keys = _walletStorage.GetFounderKeys(); @@ -129,35 +127,35 @@ if (founderProjectsToLookup.Any()) { RelayService.RequestProjectCreateEventsByPubKey(e => - { - switch (e) { - case { Kind: NostrKind.Metadata }: - var nostrMetadata = serializer.Deserialize(e.Content); - var founderProject = founderProjects.FirstOrDefault(_ => _.ProjectInfo.NostrPubKey == e.Pubkey); - if (founderProject != null && founderProject.Metadata is null) - founderProject.Metadata = nostrMetadata; - break; - - case { Kind: NostrKind.ApplicationSpecificData }: - var projectInfo = serializer.Deserialize(e.Content); - if (founderProjects.All(_ => _.ProjectInfo.NostrPubKey != e.Pubkey)) - founderProjects.Add(new FounderProject - { - ProjectInfo = projectInfo, - ProjectIndex = founderProjectsToLookup.Keys.ToList().IndexOf(e.Pubkey) + 1, - CreationTransactionId = founderProjectsToLookup[e.Pubkey].TrxId - }); - break; - } - }, - () => - { - scanningForProjects = false; - storage.AddFounderProject(founderProjects.ToArray()); - StateHasChanged(); - }, - founderProjectsToLookup.Keys.ToArray()); + switch (e) + { + case { Kind: NostrKind.Metadata }: + var nostrMetadata = serializer.Deserialize(e.Content); + var founderProject = founderProjects.FirstOrDefault(_ => _.ProjectInfo.NostrPubKey == e.Pubkey); + if (founderProject != null && founderProject.Metadata is null) + founderProject.Metadata = nostrMetadata; + break; + + case { Kind: NostrKind.ApplicationSpecificData }: + var projectInfo = serializer.Deserialize(e.Content); + if (founderProjects.All(_ => _.ProjectInfo.NostrPubKey != e.Pubkey)) + founderProjects.Add(new FounderProject + { + ProjectInfo = projectInfo, + ProjectIndex = founderProjectsToLookup.Keys.ToList().IndexOf(e.Pubkey) + 1, + CreationTransactionId = founderProjectsToLookup[e.Pubkey].TrxId + }); + break; + } + }, + () => + { + scanningForProjects = false; + storage.AddFounderProject(founderProjects.ToArray()); + StateHasChanged(); + }, + founderProjectsToLookup.Keys.ToArray()); } else { @@ -169,4 +167,5 @@ { NavigationManager.NavigateTo("/create"); } + } \ No newline at end of file From 660765ee662d1f3f91093c34f61a8fc5076e237a Mon Sep 17 00:00:00 2001 From: dangershony Date: Tue, 15 Oct 2024 19:07:18 +0100 Subject: [PATCH 4/4] Act on review --- src/Angor/Client/Pages/Founder.razor | 11 ++++++----- src/Angor/Client/Pages/View.razor | 6 ++---- src/Angor/Client/Storage/ClientStorage.cs | 5 ----- src/Angor/Client/Storage/IClientStorage.cs | 1 - 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/Angor/Client/Pages/Founder.razor b/src/Angor/Client/Pages/Founder.razor index ed17b372..308e9aa4 100644 --- a/src/Angor/Client/Pages/Founder.razor +++ b/src/Angor/Client/Pages/Founder.razor @@ -60,6 +60,7 @@
} + @if (founderProjects.Count > 0) {
@@ -69,6 +70,7 @@ }
} +
@@ -106,16 +108,15 @@ { scanningForProjects = true; - // Clear the existing projects before rescan - founderProjects.Clear(); - storage.ClearFounderProjects(); - var keys = _walletStorage.GetFounderKeys(); var founderProjectsToLookup = new Dictionary(); foreach (var key in keys.Keys) { + if (founderProjects.Exists(_ => _.ProjectInfo.ProjectIdentifier == key.ProjectIdentifier)) + continue; + var indexerProject = await _IndexerService.GetProjectByIdAsync(key.ProjectIdentifier); if (indexerProject == null) @@ -139,7 +140,7 @@ case { Kind: NostrKind.ApplicationSpecificData }: var projectInfo = serializer.Deserialize(e.Content); - if (founderProjects.All(_ => _.ProjectInfo.NostrPubKey != e.Pubkey)) + if (founderProjects.All(_ => _.ProjectInfo.NostrPubKey != e.Pubkey)) // Getting events from multiple relays founderProjects.Add(new FounderProject { ProjectInfo = projectInfo, diff --git a/src/Angor/Client/Pages/View.razor b/src/Angor/Client/Pages/View.razor index e13b1f56..51a0775b 100644 --- a/src/Angor/Client/Pages/View.razor +++ b/src/Angor/Client/Pages/View.razor @@ -58,13 +58,11 @@ { var metadata = project.Metadata; -
Profile Picture
-
@@ -168,11 +166,11 @@

@if (projectStats.TimeLeft > 0) { - Time Left for Investing: @projectStats.TimeLeft days + Time Left for Investing: @projectStats.TimeLeft days } else { - The investing period is over + The investing period is over }

diff --git a/src/Angor/Client/Storage/ClientStorage.cs b/src/Angor/Client/Storage/ClientStorage.cs index 586238a3..6f78a0b5 100644 --- a/src/Angor/Client/Storage/ClientStorage.cs +++ b/src/Angor/Client/Storage/ClientStorage.cs @@ -94,11 +94,6 @@ public void AddFounderProject(params FounderProject[] projects) _storage.SetItem("founder-projects", ret.OrderBy(_ => _.ProjectIndex)); } - public void ClearFounderProjects() - { - _storage.SetItem("founder-projects", new List()); - } - public List GetFounderProjects() { var ret = _storage.GetItem>("founder-projects"); diff --git a/src/Angor/Client/Storage/IClientStorage.cs b/src/Angor/Client/Storage/IClientStorage.cs index 0383960a..45fb8d26 100644 --- a/src/Angor/Client/Storage/IClientStorage.cs +++ b/src/Angor/Client/Storage/IClientStorage.cs @@ -17,7 +17,6 @@ public interface IClientStorage void AddFounderProject(params FounderProject[] projects); - void ClearFounderProjects(); List GetFounderProjects(); FounderProject? GetFounderProjects(string projectIdentifier); void UpdateFounderProject(FounderProject project);