Skip to content

Commit

Permalink
Fix farming alert for rejoiners without accepted partials
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbrucker committed Oct 21, 2023
1 parent 67163a6 commit 0c99d06
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/app/my-farmer/my-farmer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
</div>
</div>
<div class="col-12" *ngIf="(accountService.haveAccountIdentifier$ | async) && (accountService.haveAccount$ | async)">
<div *ngIf="isPoolMember && (accountHasNeverSubmittedAPartial || showNewAccountFarmingAlert)" class="row mb-1 ps-2 pe-2">
<ngb-alert *ngIf="accountHasNeverSubmittedAPartial" type="primary" class="mb-1 text-center no-border-color" [dismissible]="false">
{{accountHasNeverSubmittedPartialsAlertMessage}}
<div *ngIf="isPoolMember && (accountHasNeverSubmittedAPartial || shouldShowRejoinedAlert || shouldShowNewAccountFarmingAlert)" class="row mb-1 ps-2 pe-2">
<ngb-alert *ngIf="accountHasNeverSubmittedAPartial || shouldShowRejoinedAlert" type="primary" class="mb-1 text-center no-border-color" [dismissible]="false">
{{accountHasJoinedAlertMessage}}
</ngb-alert>
<ngb-alert *ngIf="!accountHasNeverSubmittedAPartial && showNewAccountFarmingAlert" type="primary" class="mb-1 text-center no-border-color" (closed)="hideNewAccountInfoAlert()">
<ngb-alert *ngIf="shouldShowNewAccountFarmingAlert" type="primary" class="mb-1 text-center no-border-color" (closed)="hideNewAccountInfoAlert()">
You just started farming, it will take 24h to show accurate estimations based on farm size.
</ngb-alert>
</div>
Expand Down
32 changes: 22 additions & 10 deletions src/app/my-farmer/my-farmer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,24 +1000,36 @@ export class MyFarmerComponent implements OnInit, OnDestroy {
return this.accountService.account?.lastAcceptedPartialAt === undefined
}

public get accountHasNeverSubmittedPartialsAlertMessage(): string|undefined {
if (this.accountService.account === null) {
public get accountHasJoinedAlertMessage(): string|undefined {
const farmingSinceRaw = this.accountService.account?.rejoinedAt ?? this.accountService.account?.createdAt
if (farmingSinceRaw === undefined) {
return
}

const createdAt = moment(this.accountService.account.createdAt)
if (createdAt.isAfter(moment().subtract(1, 'hour'))) {
return 'You just joined the pool, waiting for your farm to start submitting partials to the pool.'
const farmingSince = moment(farmingSinceRaw)
const joinedWording = this.accountService.account.rejoinedAt === undefined ? 'joined' : 'rejoined'
if (farmingSince.isAfter(moment().subtract(1, 'hour'))) {
return `You just ${joinedWording} the pool, waiting for your farm to start submitting partials to the pool.`
}
if (farmingSince.isAfter(moment().subtract(7, 'days'))) {
return `You recently ${joinedWording} the pool, waiting for your farm to start submitting partials to the pool.`
}
if (createdAt.isAfter(moment().subtract(7, 'days'))) {
return 'You recently joined the pool, waiting for your farm to start submitting partials to the pool.'

return `You ${joinedWording} the pool a while ago, waiting for your farm to start submitting partials to the pool.`
}

public get shouldShowRejoinedAlert(): boolean {
const rejoinedAt = this.accountService.account?.rejoinedAt
const lastAcceptedPartialAt = this.accountService.account?.lastAcceptedPartialAt
if (rejoinedAt === undefined || lastAcceptedPartialAt === undefined) {
return false
}

return 'You joined the pool a while ago, waiting for your farm to start submitting partials to the pool.'
return moment(rejoinedAt).isAfter(lastAcceptedPartialAt)
}

public get showNewAccountFarmingAlert(): boolean {
if (this.configService.hideNewAccountInfoAlert || this.accountService.account === null || this.accountHasNeverSubmittedAPartial) {
public get shouldShowNewAccountFarmingAlert(): boolean {
if (this.configService.hideNewAccountInfoAlert || this.accountService.account === null || this.accountHasNeverSubmittedAPartial || this.shouldShowRejoinedAlert) {
return false
}
const farmingSince = this.accountService.account.rejoinedAt || this.accountService.account.createdAt
Expand Down

0 comments on commit 0c99d06

Please sign in to comment.