Skip to content

Commit

Permalink
Merge pull request #281 from sunrise-stake/bugfix/missing-start-date
Browse files Browse the repository at this point in the history
Fix for missing start date in neighbours response leading to all tree…
  • Loading branch information
dankelleher authored Sep 18, 2023
2 parents eaeb461 + c457077 commit fad6909
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions packages/app/src/api/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ export const getNeighbours = async (
fetch(`${GET_NEIGHBOURS_URL}/${address.toBase58()}?depth=${depth}`)
.then(async (resp) => resp.json() as Promise<RawGetNeighboursResponse>)
.then((rawResponse) => ({
firstTransfer: new Date(rawResponse.firstTransfer),
lastTransfer: new Date(rawResponse.lastTransfer),
firstTransfer: rawResponse.firstTransfer
? new Date(rawResponse.firstTransfer)
: null,
lastTransfer: rawResponse.lastTransfer
? new Date(rawResponse.lastTransfer)
: null,
neighbours: {
senderResult: rawResponse.neighbours.senderResult.map(
fromRawNeighbourEntry
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/api/forest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export class ForestService {
const parentTreeNode = {
address,
balance: currentBalance + lockedBalance,
startDate: firstTransfer,
mostRecentTransfer: lastTransfer,
startDate: firstTransfer ?? new Date(), // Default to the current date if for some reason the API returned no date
mostRecentTransfer: lastTransfer ?? new Date(),
parents: [],
children: [],
};
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export interface RawGetNeighboursResponse {

export interface GetNeighboursResponse {
neighbours: NeighbourResult;
firstTransfer: Date;
lastTransfer: Date;
firstTransfer: Date | null;
lastTransfer: Date | null;
}

export type ParentRelationship = "PARENT_IS_SENDER" | "PARENT_IS_RECIPIENT";
Expand Down

0 comments on commit fad6909

Please sign in to comment.