Merge pull request #5010 from mempool/mononaut/tracker-tx-routing

Transparently redirect direct mobile tx visits to pizza tracker
This commit is contained in:
wiz 2024-08-01 14:30:56 -04:00 committed by GitHub
commit 94e223e8da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 60 additions and 14 deletions

View File

@ -9,6 +9,7 @@ import { StatusViewComponent } from './components/status-view/status-view.compon
import { AddressGroupComponent } from './components/address-group/address-group.component'; import { AddressGroupComponent } from './components/address-group/address-group.component';
import { TrackerComponent } from './components/tracker/tracker.component'; import { TrackerComponent } from './components/tracker/tracker.component';
import { AccelerateCheckout } from './components/accelerate-checkout/accelerate-checkout.component'; import { AccelerateCheckout } from './components/accelerate-checkout/accelerate-checkout.component';
import { TrackerGuard } from './route-guards';
const browserWindow = window || {}; const browserWindow = window || {};
// @ts-ignore // @ts-ignore
@ -140,16 +141,17 @@ let routes: Routes = [
loadChildren: () => import('./bitcoin-graphs.module').then(m => m.BitcoinGraphsModule), loadChildren: () => import('./bitcoin-graphs.module').then(m => m.BitcoinGraphsModule),
data: { preload: true }, data: { preload: true },
}, },
{
path: 'tx',
canMatch: [TrackerGuard],
runGuardsAndResolvers: 'always',
loadChildren: () => import('./components/tracker/tracker.module').then(m => m.TrackerModule),
},
{ {
path: '', path: '',
loadChildren: () => import('./master-page.module').then(m => m.MasterPageModule), loadChildren: () => import('./master-page.module').then(m => m.MasterPageModule),
data: { preload: true }, data: { preload: true },
}, },
{
path: 'tracker',
data: { networkSpecific: true },
loadChildren: () => import('./components/tracker/tracker.module').then(m => m.TrackerModule),
},
{ {
path: 'wallet', path: 'wallet',
children: [], children: [],
@ -213,10 +215,6 @@ let routes: Routes = [
loadChildren: () => import('./bitcoin-graphs.module').then(m => m.BitcoinGraphsModule), loadChildren: () => import('./bitcoin-graphs.module').then(m => m.BitcoinGraphsModule),
data: { preload: true }, data: { preload: true },
}, },
{
path: '**',
redirectTo: ''
},
]; ];
if (browserWindowEnv && browserWindowEnv.BASE_MODULE === 'liquid') { if (browserWindowEnv && browserWindowEnv.BASE_MODULE === 'liquid') {
@ -301,13 +299,16 @@ if (browserWindowEnv && browserWindowEnv.BASE_MODULE === 'liquid') {
loadChildren: () => import('./liquid/liquid-graphs.module').then(m => m.LiquidGraphsModule), loadChildren: () => import('./liquid/liquid-graphs.module').then(m => m.LiquidGraphsModule),
data: { preload: true }, data: { preload: true },
}, },
{
path: '**',
redirectTo: ''
},
]; ];
} }
if (!window['isMempoolSpaceBuild']) {
routes.push({
path: '**',
redirectTo: ''
});
}
@NgModule({ @NgModule({
imports: [RouterModule.forRoot(routes, { imports: [RouterModule.forRoot(routes, {
initialNavigation: 'enabledBlocking', initialNavigation: 'enabledBlocking',

View File

@ -185,7 +185,11 @@
} }
</div> </div>
<div class="footer-link" [routerLink]="['/tx' | relativeUrl, tx?.txid]"> <div class="footer-link"
[routerLink]="['/tx' | relativeUrl, tx?.txid]"
[queryParams]="{ mode: 'details' }"
queryParamsHandling="merge"
>
<span><ng-container i18n="accelerator.show-more-details">See more details</ng-container>&nbsp;<fa-icon [icon]="['fas', 'arrow-alt-circle-right']"></fa-icon></span> <span><ng-container i18n="accelerator.show-more-details">See more details</ng-container>&nbsp;<fa-icon [icon]="['fas', 'arrow-alt-circle-right']"></fa-icon></span>
</div> </div>
</div> </div>

View File

@ -31,6 +31,8 @@ import { TrackerStage } from './tracker-bar.component';
import { MiningService, MiningStats } from '../../services/mining.service'; import { MiningService, MiningStats } from '../../services/mining.service';
import { ETA, EtaService } from '../../services/eta.service'; import { ETA, EtaService } from '../../services/eta.service';
import { getTransactionFlags, getUnacceleratedFeeRate } from '../../shared/transaction.utils'; import { getTransactionFlags, getUnacceleratedFeeRate } from '../../shared/transaction.utils';
import { RelativeUrlPipe } from '../../shared/pipes/relative-url/relative-url.pipe';
interface Pool { interface Pool {
id: number; id: number;
@ -140,6 +142,7 @@ export class TrackerComponent implements OnInit, OnDestroy {
private priceService: PriceService, private priceService: PriceService,
private enterpriseService: EnterpriseService, private enterpriseService: EnterpriseService,
private miningService: MiningService, private miningService: MiningService,
private router: Router,
private cd: ChangeDetectorRef, private cd: ChangeDetectorRef,
private zone: NgZone, private zone: NgZone,
@Inject(ZONE_SERVICE) private zoneService: any, @Inject(ZONE_SERVICE) private zoneService: any,

View File

@ -518,6 +518,13 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
}); });
} }
} }
if (window.innerWidth <= 767.98) {
this.router.navigate([this.relativeUrlPipe.transform('/tx'), this.txId], {
queryParamsHandling: 'merge',
preserveFragment: true,
queryParams: { mode: 'details' },
});
}
this.seoService.setTitle( this.seoService.setTitle(
$localize`:@@bisq.transaction.browser-title:Transaction: ${this.txId}:INTERPOLATION:` $localize`:@@bisq.transaction.browser-title:Transaction: ${this.txId}:INTERPOLATION:`
); );

View File

@ -0,0 +1,22 @@
import { Injectable, inject } from '@angular/core';
import { CanMatchFn, Route, Router, UrlSegment } from '@angular/router';
import { NavigationService } from './services/navigation.service';
@Injectable({
providedIn: 'root'
})
class GuardService {
constructor(
private router: Router,
private navigationService: NavigationService,
) {}
trackerGuard(route: Route, segments: UrlSegment[]): boolean {
const preferredRoute = this.router.getCurrentNavigation()?.extractedUrl.queryParams?.mode;
return preferredRoute !== 'details' && this.navigationService.isInitialLoad() && window.innerWidth <= 767.98;
}
}
export const TrackerGuard: CanMatchFn = (route: Route, segments: UrlSegment[]): boolean => {
return inject(GuardService).trackerGuard(route, segments);
};

View File

@ -27,6 +27,7 @@ export class NavigationService {
} }
}; };
networks = Object.keys(this.networkModules); networks = Object.keys(this.networkModules);
initialLoad = true;
constructor( constructor(
private stateService: StateService, private stateService: StateService,
@ -40,6 +41,10 @@ export class NavigationService {
if (this.enforceSubnetRestrictions(state)) { if (this.enforceSubnetRestrictions(state)) {
this.updateSubnetPaths(state); this.updateSubnetPaths(state);
} }
if (this.initialLoad) {
this.initialLoad = false;
}
this.updateSubnetPaths(state);
}); });
} }
@ -98,4 +103,8 @@ export class NavigationService {
}); });
this.subnetPaths.next(subnetPaths); this.subnetPaths.next(subnetPaths);
} }
isInitialLoad(): boolean {
return this.initialLoad;
}
} }