-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added creating the founder project data on login in a new browser (#17)
* Added lookup for projects on founder page * Changing the founder page to reload missing projects and check for pending investor signatures * Moved the component to component folder * Moved the founder list to a separate component, added close subscription call when disposed and added data to the founder project * Fixed typo * Fixed issue with null in the metadata * Fixed from review * Fix from review
- Loading branch information
1 parent
75dfa63
commit 40b6b70
Showing
15 changed files
with
322 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@using Angor.Shared.Services | ||
@using Angor.Client.Models | ||
@using Nostr.Client.Messages | ||
@using Nostr.Client.Messages.Metadata | ||
|
||
@inject IRelayService RelayService; | ||
|
||
<div class="card mb-3"> | ||
@if (InvestmentRequests) | ||
{ | ||
<div class="card-header bg-success"> | ||
<h4 class="d-flex justify-content-center align-items-center">Pending investment requests</h4> | ||
</div> | ||
} | ||
<div class="card-body"> | ||
<h1 class="card-title">@FounderProject.Metadata?.Name</h1> | ||
<h2 class="card-subtitle">@FounderProject.ProjectInfo.ProjectIdentifier</h2> | ||
<p class="card-text">Nostr ID: <a href="/" target="_blank">@FounderProject.ProjectInfo.NostrPubKey</a></p> | ||
<NavLink href=@($"/view/{FounderProject.ProjectInfo.ProjectIdentifier}") class="btn btn-primary">View Project</NavLink> | ||
</div> | ||
</div> | ||
|
||
@code { | ||
|
||
[Parameter] | ||
public FounderProject FounderProject { get; set; } | ||
|
||
public bool InvestmentRequests { get; set; } | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
await RelayService.ConnectToRelaysAsync(); | ||
|
||
if (FounderProject.Metadata == null) | ||
{ | ||
await RelayService.RequestProjectCreateEventsByPubKeyAsync(FounderProject.ProjectInfo.NostrPubKey, _ => | ||
{ | ||
if (_.Kind != NostrKind.Metadata) | ||
return; | ||
|
||
var metadata = System.Text.Json.JsonSerializer.Deserialize<NostrMetadata>(_.Content, Angor.Shared.Services.RelayService.settings); | ||
FounderProject.Metadata = ProjectMetadata.Parse(metadata); | ||
StateHasChanged(); | ||
}); | ||
} | ||
|
||
await RelayService.LookupDirectMessagesForPubKeyAsync(FounderProject.ProjectInfo.NostrPubKey, FounderProject.LastRequestForSignaturesTime, 1, | ||
_ => | ||
{ | ||
if (InvestmentRequests) | ||
return; | ||
|
||
InvestmentRequests = true; | ||
StateHasChanged(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Angor.Shared.Models; | ||
|
||
namespace Angor.Client.Models; | ||
|
||
public class FounderProject | ||
{ | ||
public ProjectMetadata? Metadata { get; set; } | ||
public ProjectInfo ProjectInfo { get; set; } | ||
public DateTime? LastRequestForSignaturesTime { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Nostr.Client.Messages.Metadata; | ||
|
||
namespace Angor.Client.Models; | ||
|
||
public class ProjectMetadata | ||
{ | ||
private const string displayName = "display_name"; | ||
|
||
public string Name { get; set; } | ||
public string Website { get; set; } | ||
public string About { get; set; } | ||
public string Picture { get; set; } | ||
public string Nip05 { get; set; } | ||
public string Lud16 { get; set; } | ||
public string Banner { get; set; } | ||
public string Nip57 { get; set; } | ||
|
||
public static ProjectMetadata Parse(NostrMetadata nostrMetadata) | ||
{ | ||
var project = new ProjectMetadata | ||
{ | ||
Nip57 = nostrMetadata.Nip57, | ||
Lud16 = nostrMetadata.Nip57, | ||
Nip05 = nostrMetadata.Nip57, | ||
About = nostrMetadata.About, | ||
Banner = nostrMetadata.Banner, | ||
Picture = nostrMetadata.Picture | ||
}; | ||
if (nostrMetadata.AdditionalData.ContainsKey(nameof(project.Website))) | ||
project.Website = nostrMetadata.AdditionalData[nameof(project.Website)].ToString(); | ||
if (nostrMetadata.AdditionalData.ContainsKey(displayName)) | ||
project.Name = nostrMetadata.AdditionalData[displayName].ToString(); | ||
return project; | ||
} | ||
|
||
public NostrMetadata ToNostrMetadata() | ||
{ | ||
var nostr = new NostrMetadata | ||
{ | ||
About = About, | ||
Banner = Banner, | ||
Lud16 = Lud16, | ||
Name = Name, | ||
Nip05 = Nip05, | ||
Nip57 = Nip57, | ||
Picture = Picture, | ||
AdditionalData = new (){{displayName,Name}} | ||
}; | ||
|
||
if (Website != null) | ||
nostr.AdditionalData.Add("website",Website); | ||
|
||
return nostr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.