Skip to content

Commit

Permalink
Add node source to posts (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
maebeam authored Nov 24, 2021
1 parent 52cea7f commit 25321fa
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export class AppComponent implements OnInit {
this.globalVars.createProfileFeeNanos = res.CreateProfileFeeNanos;
this.globalVars.isCompProfileCreation = this.globalVars.showPhoneNumberVerification && res.CompProfileCreation;
this.globalVars.buyETHAddress = res.BuyETHAddress;
this.globalVars.nodes = res.Nodes;

this.globalVars.transactionFeeMap = res.TransactionFeeMap;

Expand Down
6 changes: 6 additions & 0 deletions src/app/backend-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ export class TransactionFee {
ProfileEntryResponse?: ProfileEntryResponse;
}

export class DeSoNode {
Name: string;
URL: string;
Owner: string;
}

@Injectable({
providedIn: "root",
})
Expand Down
4 changes: 4 additions & 0 deletions src/app/feed/feed-create-post/feed-create-post.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ export class FeedCreatePostComponent implements OnInit {
}
}

if (environment.node.id) {
postExtraData["Node"] = environment.node.id.toString();
}

const bodyObj = {
Body: this.postInput,
// Only submit images if the post is a quoted repost or a vanilla post.
Expand Down
39 changes: 28 additions & 11 deletions src/app/feed/feed-post/feed-post.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,34 @@
[followedPubKeyBase58Check]="postContent.ProfileEntryResponse.PublicKeyBase58Check"
[creatorCoinTemplate]="creatorCoinInfo"
></follow-button>
<feed-post-dropdown
*ngIf="showDropdown && !reposterProfile"
class="ml-auto"
[post]="post"
[postContent]="postContent"
[nftEntryResponses]="nftEntryResponses"
(postHidden)="hidePost()"
(userBlocked)="blockUser()"
(toggleGlobalFeed)="_addPostToGlobalFeed($event)"
(togglePostPin)="_pinPostToGlobalFeed($event)"
></feed-post-dropdown>

<div class="ml-auto">
<div *ngIf="getNode()" class="d-inline-block mr-15px">
<a
class="text-grey9"
target="_blank"
href="{{ getNode().URL }}"
matTooltipClass="global__mat-tooltip global__mat-tooltip-font-size"
mat-raised-button
#tooltip="matTooltip"
[matTooltip]="'Posted on ' + getNode().Name"
>
<i class="fas fa-external-link-square-alt"></i>
</a>
</div>

<feed-post-dropdown
*ngIf="showDropdown && !reposterProfile"
class="d-inline-block"
[post]="post"
[postContent]="postContent"
[nftEntryResponses]="nftEntryResponses"
(postHidden)="hidePost()"
(userBlocked)="blockUser()"
(toggleGlobalFeed)="_addPostToGlobalFeed($event)"
(togglePostPin)="_pinPostToGlobalFeed($event)"
></feed-post-dropdown>
</div>
</div>

<!-- Mobile follow button-->
Expand Down
13 changes: 12 additions & 1 deletion src/app/feed/feed-post/feed-post.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectorRef, AfterViewInit } from "@angular/core";
import { GlobalVarsService } from "../../global-vars.service";
import { BackendApiService, NFTEntryResponse, PostEntryResponse } from "../../backend-api.service";
import { BackendApiService, DeSoNode, NFTEntryResponse, PostEntryResponse } from "../../backend-api.service";
import { AppRoutingModule } from "../../app-routing.module";
import { Router } from "@angular/router";
import { SwalHelper } from "../../../lib/helpers/swal-helper";
Expand All @@ -15,6 +15,7 @@ import * as _ from "lodash";
import { PlaceBidModalComponent } from "../../place-bid-modal/place-bid-modal.component";
import { EmbedUrlParserService } from "../../../lib/services/embed-url-parser-service/embed-url-parser-service";
import { SharedDialogs } from "../../../lib/shared-dialogs";
import { environment } from "src/environments/environment";

@Component({
selector: "feed-post",
Expand Down Expand Up @@ -524,6 +525,16 @@ export class FeedPostComponent implements OnInit {
return EmbedUrlParserService.getEmbedWidth(this.postContent.PostExtraData["EmbedVideoURL"]);
}

getNode(): DeSoNode {
const nodeId = this.postContent.PostExtraData["Node"];
if (nodeId && nodeId != environment.node.id) {
const node = this.globalVars.nodes[nodeId];
if (node) {
return node;
}
}
}

// Vimeo iframes have a lot of spacing on top and bottom on mobile.
setNegativeMargins(link: string, globalVars: GlobalVarsService) {
return globalVars.isMobile() && EmbedUrlParserService.isVimeoLink(link);
Expand Down
3 changes: 3 additions & 0 deletions src/app/global-vars.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable } from "@angular/core";
import {
BackendApiService,
BalanceEntryResponse,
DeSoNode,
PostEntryResponse,
TransactionFee,
TutorialStatus,
Expand Down Expand Up @@ -221,6 +222,8 @@ export class GlobalVarsService {

buyETHAddress: string = "";

nodes: { [id: number]: DeSoNode }

SetupMessages() {
// If there's no loggedInUser, we set the notification count to zero
if (!this.loggedInUser) {
Expand Down
1 change: 1 addition & 0 deletions src/environments/environment.bitclout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const environment = {
domain: "amp.bitclout.com"
},
node: {
id: 2,
name: 'BitClout',
url: 'https://bitclout.com',
logoAssetDir: '/assets/bitclout/'
Expand Down
3 changes: 2 additions & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export const environment = {
domain: ""
},
node: {
id: 1,
name: 'DeSo',
url: 'https://deso.org',
url: 'https://node.deso.org',
logoAssetDir: '/assets/deso/'
}
};
3 changes: 2 additions & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ export const environment = {
domain: ""
},
node: {
id: 1,
name: 'DeSo',
url: 'https://deso.org',
url: 'https://node.deso.org',
logoAssetDir: '/assets/deso/'
}
};

0 comments on commit 25321fa

Please sign in to comment.