Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
443 changes: 431 additions & 12 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"@angular/platform-browser": "^11.2.12",
"@angular/platform-browser-dynamic": "^11.2.12",
"@angular/router": "^11.2.12",
"@apollo/client": "^3.0.0",
"amplitude-js": "^7.4.3",
"apollo-angular": "^2.6.0",
"autolinker": "^3.14.2",
"bs58": "^4.0.1",
"canvas-confetti": "^1.3.0",
Expand All @@ -36,6 +38,7 @@
"currency-symbol-map": "^5.0.1",
"fs": "0.0.1-security",
"google-libphonenumber": "^3.2.16",
"graphql": "^15.0.0",
"hash-base": "^3.0.4",
"intl-tel-input": "^17.0.3",
"is-buffer": "^2.0.4",
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ import { lightTheme } from "./theme/light-theme";
import { darkTheme } from "./theme/dark-theme";
import { icydarkTheme } from "./theme/icy-dark-theme";
import { legendsTheme } from "./theme/legends-theme";
import { GraphQLModule } from './graphql.module';

@NgModule({
declarations: [
Expand Down Expand Up @@ -251,6 +252,7 @@ import { legendsTheme } from "./theme/legends-theme";
localStorage.getItem("theme") ||
(window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark"),
}),
GraphQLModule,
],
providers: [BackendApiService, GlobalVarsService, BsModalService, IdentityService],
bootstrap: [AppComponent],
Expand Down
2 changes: 0 additions & 2 deletions src/app/backend-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ export class PostEntryResponse {
TimestampNanos: number;
IsHidden: boolean;
ConfirmationBlockHeight: number;
StakeEntry: any;
StakeEntryStats: any;
// PostEntryResponse of the post that this post reclouts.
RecloutedPostEntryResponse: PostEntryResponse;
// The profile associated with this post.
Expand Down
49 changes: 0 additions & 49 deletions src/app/feed/feed-post/feed-post.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ export class FeedPostComponent implements OnInit {
@Output() userBlocked = new EventEmitter();

AppRoutingModule = AppRoutingModule;
stakeAmount = 1;
loggedInUserStakeAmount = 0;
loggedInUserNextStakePayout = -1;
addingPostToGlobalFeed = false;
reclout: any;
postContent: any;
Expand All @@ -112,10 +109,6 @@ export class FeedPostComponent implements OnInit {
constructedEmbedURL: any;

ngOnInit() {
if (this.globalVars.loggedInUser) {
this.loggedInUserStakeAmount = this._getLoggedInUserStakeAmount();
this.loggedInUserNextStakePayout = this._getLoggedInUserNextStakePayout();
}
if (!this.post.RecloutCount) {
this.post.RecloutCount = 0;
}
Expand Down Expand Up @@ -330,48 +323,6 @@ export class FeedPostComponent implements OnInit {
}
}

_getLoggedInUserStakeAmount() {
if (this.post.StakeEntry.StakeList.length === 0) {
return 0;
}
let totalStake = 0;
for (let ii = 0; ii < this.post.StakeEntry.StakeList.length; ii++) {
if (
this.post.StakeEntry.StakeList[ii].StakerPublicKeyBase58Check ==
this.globalVars.loggedInUser.PublicKeyBase58Check
) {
totalStake += this.post.StakeEntry.StakeList[ii].InitialStakeNanos;
}
}
return totalStake / 1e9;
}

// Returns -1 if the user is not expecting another payout.
_getLoggedInUserNextStakePayout() {
if (this.post.StakeEntry.StakeList.length == 0) {
return -1;
}
// Start with the current amount staked.
let payoutStakeAmount = this.post.StakeEntryStats.TotalStakeNanos;

const loggedInUserPK = this.globalVars.loggedInUser.PublicKeyBase58Check;
for (let ii = 0; ii < this.post.StakeEntry.StakeList.length; ii++) {
const stakerPK = this.post.StakeEntry.StakeList[ii].StakerPublicKeyBase58Check;

// If we find a stake that isn't the current user, add the remaining stake owed.
if (stakerPK != loggedInUserPK && this.post.StakeEntry.StakeList[ii].RemainingStakeOwedNanos > 0) {
payoutStakeAmount += this.post.StakeEntry.StakeList[ii].RemainingStakeOwedNanos;
}

// If we find a stake that *is* the current user and is unpaid, we are at the payoutStakeAmount and can return.
else if (stakerPK == loggedInUserPK && this.post.StakeEntry.StakeList[ii].RemainingStakeOwedNanos > 0) {
return payoutStakeAmount / 1e9;
}
}

return -1;
}

_addPostToGlobalFeed(event: any) {
// Prevent the post from navigating.
event.stopPropagation();
Expand Down
23 changes: 23 additions & 0 deletions src/app/graphql.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {NgModule} from '@angular/core';
import {APOLLO_OPTIONS} from 'apollo-angular';
import {ApolloClientOptions, InMemoryCache} from '@apollo/client/core';
import {HttpLink} from 'apollo-angular/http';

const uri = 'http://localhost:17001/api/graphql'; // <-- add the URL of the GraphQL server here
export function createApollo(httpLink: HttpLink): ApolloClientOptions<any> {
return {
link: httpLink.create({uri}),
cache: new InMemoryCache(),
};
}

@NgModule({
providers: [
{
provide: APOLLO_OPTIONS,
useFactory: createApollo,
deps: [HttpLink],
},
],
})
export class GraphQLModule {}
71 changes: 0 additions & 71 deletions src/app/network-info/network-info.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -289,76 +289,5 @@
</div>
</div>

<div class="fs-15px mt-15px px-15px">
<span (click)="isOpen.bitcoinNode = !isOpen.bitcoinNode" class="font-weight-bold cursor-pointer">
<i *ngIf="!isOpen.bitcoinNode" class="fas fa-caret-right"></i>
<i *ngIf="isOpen.bitcoinNode" class="fas fa-caret-down"></i>
Bitcoin Node Info
</span>
<div *ngIf="isOpen.bitcoinNode && updatingBitcoinPeer" class="ml-15px fc-muted">Updating Bitcoin peer...</div>
<div *ngIf="isOpen.bitcoinNode && !updatingBitcoinPeer" class="ml-15px">
Sync Peer:
<div class="fc-blue">
<div *ngIf="globalVars.nodeInfo.BitcoinSyncPeer == null">No sync peer currently set.</div>
<div *ngIf="globalVars.nodeInfo.BitcoinSyncPeer != null">
<div style="display: flex; align-items: center">
<div style="display: inline-block">
{{ globalVars.nodeInfo.BitcoinSyncPeer.IP + ":" + globalVars.nodeInfo.BitcoinSyncPeer.ProtocolPort }}
</div>
</div>
</div>
</div>
Unconnected Peers ({{ globalVars.nodeInfo.BitcoinUnconnectedPeers.length }}):
<div
class="fc-blue border border-color-grey px-5px pt-5px"
style="max-height: 150px; overflow-y: scroll; width: fit-content"
>
<div
*ngIf="
globalVars.nodeInfo.BitcoinUnconnectedPeers == null ||
globalVars.nodeInfo.BitcoinUnconnectedPeers.length === 0
"
>
No other peers available.
</div>
<div *ngFor="let peer of globalVars.nodeInfo.BitcoinUnconnectedPeers; index as peerIndex">
<div class="d-flex align-items-center justify-content-between pb-5px">
<div style="display: inline-block">
{{ peer.IP + ":" + peer.ProtocolPort }}
</div>
<div class="d-flex">
<div
*ngIf="peer.isCopied !== true"
(click)="copyPeer(peer)"
class="btn btn-outline-secondary d-flex fs-15px p-5px ml-10px"
>
<i class="far fa-copy fa-xs"></i>
</div>
<div *ngIf="peer.isCopied === true" class="fs-15px px-5px py-0px">
<i class="far fa-check-circle fa-xs"></i>
</div>
<div
(click)="connectBitcoinPeer(peer.IP + ':' + peer.ProtocolPort)"
class="btn btn-outline-secondary fs-15px lh-15px p-5px ml-5px"
>
Connect
</div>
</div>
</div>
</div>
</div>
Manual Connection:
<div class="fc-blue d-flex align-items-center">
<input [(ngModel)]="manualBitcoinPeer" placeholder="Enter an address." style="width: 200px; border-radius: 3px" />
<div
(click)="connectBitcoinPeer(manualBitcoinPeer)"
class="btn btn-outline-secondary fs-15px lh-15px p-5px ml-5px"
>
Connect
</div>
</div>
</div>
</div>

<!-- Spacer for scrolling past the bottom. -->
<div style="height: 100px; width: 100%"></div>
Loading