Skip to content

Commit 31730a8

Browse files
committed
Block production won slots improvements
1 parent 3073436 commit 31730a8

File tree

4 files changed

+38
-43
lines changed

4 files changed

+38
-43
lines changed

frontend/src/app/features/block-production/won-slots/block-production-won-slots.effects.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { MinaState, selectMinaState } from '@app/app.setup';
33
import { Actions, createEffect, ofType } from '@ngrx/effects';
4-
import { Effect } from '@openmina/shared';
4+
import { Effect, isDesktop } from '@openmina/shared';
55
import { EMPTY, map, switchMap } from 'rxjs';
66
import { catchErrorAndRepeat2 } from '@shared/constants/store-functions';
77
import { MinaErrorType } from '@shared/types/error-preview/mina-error-type.enum';
@@ -47,7 +47,8 @@ export class BlockProductionWonSlotsEffects extends BaseEffect {
4747
? EMPTY
4848
: this.wonSlotsService.getSlots().pipe(
4949
switchMap(({ slots, epoch }) => {
50-
const activeSlotRoute = state.blockProduction[BLOCK_PRODUCTION_WON_SLOTS_KEY].activeSlotRoute;
50+
const bpState = state.blockProduction[BLOCK_PRODUCTION_WON_SLOTS_KEY];
51+
const activeSlotRoute = bpState.activeSlotRoute;
5152
let newActiveSlot = slots.find(s => s.globalSlot.toString() === activeSlotRoute);
5253
if (!activeSlotRoute || (activeSlotRoute && !newActiveSlot)) {
5354
newActiveSlot = slots.find(s => s.active)
@@ -56,7 +57,7 @@ export class BlockProductionWonSlotsEffects extends BaseEffect {
5657
?? null;
5758
}
5859
const routes: string[] = [Routes.BLOCK_PRODUCTION, Routes.WON_SLOTS];
59-
if (newActiveSlot) {
60+
if (newActiveSlot && isDesktop() || (activeSlotRoute && !bpState.activeSlot) || (activeSlotRoute && bpState.openSidePanel)) {
6061
routes.push(newActiveSlot.globalSlot.toString());
6162
}
6263
return fromPromise(this.router.navigate(routes, { queryParamsHandling: 'merge' })).pipe(map(() => ({

frontend/src/app/features/block-production/won-slots/block-production-won-slots.reducer.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createReducer, on } from '@ngrx/store';
22
import { BlockProductionWonSlotsState } from '@block-production/won-slots/block-production-won-slots.state';
3-
import { isMobile, sort, SortDirection, TableSort } from '@openmina/shared';
3+
import { isDesktop, isMobile, sort, SortDirection, TableSort } from '@openmina/shared';
44
import { BlockProductionWonSlotsActions } from '@block-production/won-slots/block-production-won-slots.actions';
55
import {
66
BlockProductionWonSlotsSlot,
@@ -38,7 +38,7 @@ export const blockProductionWonSlotsReducer = createReducer(
3838
epoch,
3939
filteredSlots: filterSlots(sortSlots(slots, state.sort), state.filters),
4040
activeSlot,
41-
openSidePanel: !!activeSlot,
41+
openSidePanel: state.activeSlot ? state.openSidePanel : isDesktop(),
4242
})),
4343
on(BlockProductionWonSlotsActions.setActiveSlot, (state, { slot }) => ({
4444
...state,
@@ -56,7 +56,12 @@ export const blockProductionWonSlotsReducer = createReducer(
5656
filters,
5757
filteredSlots: filterSlots(sortSlots(state.slots, state.sort), filters),
5858
})),
59-
on(BlockProductionWonSlotsActions.toggleSidePanel, state => ({ ...state, openSidePanel: !state.openSidePanel })),
59+
on(BlockProductionWonSlotsActions.toggleSidePanel, state => ({
60+
...state,
61+
openSidePanel: !state.openSidePanel,
62+
activeSlot: !state.openSidePanel ? state.activeSlot : undefined,
63+
activeSlotRoute: !state.openSidePanel ? state.activeSlotRoute : undefined,
64+
})),
6065
on(BlockProductionWonSlotsActions.close, () => initialState),
6166
);
6267

frontend/src/app/features/block-production/won-slots/side-panel/block-production-won-slots-side-panel.component.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import {
2-
ChangeDetectionStrategy,
3-
Component,
4-
OnDestroy,
5-
OnInit,
6-
TemplateRef,
7-
ViewChild,
8-
ViewContainerRef,
9-
} from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';
102
import { StoreDispatcher } from '@shared/base-classes/store-dispatcher.class';
113
import { BlockProductionWonSlotsSelectors } from '@block-production/won-slots/block-production-won-slots.state';
124
import {
@@ -15,19 +7,13 @@ import {
157
BlockProductionWonSlotTimes,
168
} from '@shared/types/block-production/won-slots/block-production-won-slots-slot.type';
179
import { getTimeDiff } from '@shared/helpers/date.helper';
18-
import {
19-
any,
20-
hasValue,
21-
isMobile,
22-
noMillisFormat,
23-
ONE_THOUSAND, safelyExecuteInBrowser,
24-
SecDurationConfig,
25-
toReadableDate,
26-
} from '@openmina/shared';
10+
import { any, hasValue, isMobile, noMillisFormat, ONE_THOUSAND, safelyExecuteInBrowser, SecDurationConfig, toReadableDate } from '@openmina/shared';
2711
import { filter } from 'rxjs';
2812
import { BlockProductionWonSlotsActions } from '@block-production/won-slots/block-production-won-slots.actions';
2913
import { AppSelectors } from '@app/app.state';
3014
import { AppNodeDetails } from '@shared/types/app/app-node-details.type';
15+
import { Router } from '@angular/router';
16+
import { Routes } from '@shared/enums/routes.enum';
3117

3218
@Component({
3319
selector: 'mina-block-production-won-slots-side-panel',
@@ -70,6 +56,8 @@ export class BlockProductionWonSlotsSidePanelComponent extends StoreDispatcher i
7056

7157
@ViewChild('discarded') private discardedTemplate: TemplateRef<void>;
7258

59+
constructor(private router: Router) {super();}
60+
7361
ngOnInit(): void {
7462
this.listenToActiveSlot();
7563
this.parseRemainingTime();
@@ -198,6 +186,7 @@ export class BlockProductionWonSlotsSidePanelComponent extends StoreDispatcher i
198186
}
199187

200188
closeSidePanel(): void {
189+
this.router.navigate([Routes.BLOCK_PRODUCTION, Routes.WON_SLOTS]);
201190
this.dispatch2(BlockProductionWonSlotsActions.toggleSidePanel());
202191
}
203192

frontend/src/environments/environment.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const environment: Readonly<MinaEnv> = {
44
production: false,
55
identifier: 'Dev FE',
66
canAddNodes: true,
7-
showWebNodeLandingPage: true,
7+
showWebNodeLandingPage: false,
88
globalConfig: {
99
features: {
1010
dashboard: [],
@@ -39,26 +39,26 @@ export const environment: Readonly<MinaEnv> = {
3939
// name: 'Producer-2',
4040
// url: 'https://staging-devnet-openmina-bp-2-dashboard.minaprotocol.network',
4141
// },
42-
// {
43-
// name: 'staging-devnet-bp-0',
44-
// url: 'https://staging-devnet-openmina-bp-0.minaprotocol.network',
45-
// },
46-
// {
47-
// name: 'staging-devnet-bp-1',
48-
// url: 'https://staging-devnet-openmina-bp-1.minaprotocol.network',
49-
// },
50-
// {
51-
// name: 'staging-devnet-bp-2',
52-
// url: 'https://staging-devnet-openmina-bp-2.minaprotocol.network',
53-
// },
54-
// {
55-
// name: 'staging-devnet-bp-3',
56-
// url: 'https://staging-devnet-openmina-bp-3.minaprotocol.network',
57-
// },
5842
{
59-
name: 'Web Node 1',
60-
isWebNode: true,
43+
name: 'staging-devnet-bp-0',
44+
url: 'https://staging-devnet-openmina-bp-0.minaprotocol.network',
6145
},
46+
{
47+
name: 'staging-devnet-bp-1',
48+
url: 'https://staging-devnet-openmina-bp-1.minaprotocol.network',
49+
},
50+
{
51+
name: 'staging-devnet-bp-2',
52+
url: 'https://staging-devnet-openmina-bp-2.minaprotocol.network',
53+
},
54+
{
55+
name: 'staging-devnet-bp-3',
56+
url: 'https://staging-devnet-openmina-bp-3.minaprotocol.network',
57+
},
58+
// {
59+
// name: 'Web Node 1',
60+
// isWebNode: true,
61+
// },
6262
// {
6363
// name: 'http://65.109.105.40:3000',
6464
// url: 'http://65.109.105.40:3000',

0 commit comments

Comments
 (0)