@@ -6,6 +6,8 @@ import { RedirectService } from '@app/services/redirect.service';
66import { SharedModule } from '@app/shared/shared.module' ;
77import { W3oContextFactory , W3oNetwork , W3oSession } from '@vapaee/w3o-core' ;
88import { LucideAngularModule , X } from 'lucide-angular' ;
9+ import { EthereumWalletMetakeep , googleCtrl , MetakeepWallets } from '@vapaee/w3o-ethereum' ;
10+ import { Subscription } from 'rxjs' ;
911
1012const logger = new W3oContextFactory ( 'AccountsComponent' ) ;
1113
@@ -23,17 +25,70 @@ const logger = new W3oContextFactory('AccountsComponent');
2325export class AccountsComponent implements OnInit , OnDestroy {
2426 readonly XIcon = X ;
2527 networks = this . w3o . octopus . networks . list ;
26- selectedNetwork = this . w3o . octopus . networks . current . name ;
28+ networkName = this . w3o . octopus . networks . current . name ;
29+ networkType = this . w3o . octopus . networks . current . type ;
30+
31+ // Google Obe Tap Button
32+ googleCtrl = googleCtrl ;
33+ googleSubscription : Subscription ;
34+ googleLoading : boolean = false ;
2735
2836 constructor (
2937 public sessionService : SessionService ,
3038 private w3o : Web3OctopusService ,
3139 private redirect : RedirectService ,
3240 ) {
41+ const context = logger . method ( 'constructor' , { sessionService, w3o, redirect } ) ;
3342 w3o . octopus . networks . current$ . subscribe ( ( network : W3oNetwork ) => {
34- console . log ( 'Current network changed:' , network ) ;
35- this . selectedNetwork = network . name ;
43+ context . log ( 'Current network changed:' , network ) ;
44+ this . networkName = network . name ;
45+ this . networkType = network . type ;
3646 } ) ;
47+
48+ /*
49+ if (!googleCtrl.logged) {
50+ this.googleSubscription = googleCtrl.onSuccessfulLogin.subscribe({
51+ next: (data) => {
52+ if (data) {
53+ this.googleLoading = true;
54+ const ethereumSupport = w3o.octopus.auth.getChainSupport('ethereum');
55+ const metakeepWallet = ethereumSupport.getWalletByName('metakeep', context) as EthereumWalletMetakeep;
56+ if (!metakeepWallet) {
57+ throw new Error('Metakeep wallet not found');
58+ } else {
59+ metakeepWallet.setEmail(data.email);
60+ ethereumSupport.setCurentWallet(metakeepWallet, context);
61+ this.login();
62+ }
63+ }
64+ },
65+ });
66+
67+ // we check the div is present before trying to render the google button
68+ const googleBtnLoop = setInterval(() => {
69+ // loop until div#google_btn is rendered
70+ const googleBtn = document.getElementById('google_btn');
71+ if (googleBtn !== null) {
72+ // we found it, so we stop the first loop
73+ clearInterval(googleBtnLoop);
74+
75+ // Now we call the button render function
76+ googleCtrl.renderButton('google_btn');
77+
78+ // Now we start a second loop waiting for the div#google_btn_content to be replaced by the actual google btn
79+ const googleBtnRenderSecondLoop = setInterval(() => {
80+ const googleBtnContent = document.getElementById('google_btn_content');
81+ if (googleBtnContent === null) {
82+ clearInterval(googleBtnRenderSecondLoop);
83+ } else {
84+ // if after a whole second it didn't render we call it again
85+ googleCtrl.renderButton('google_btn');
86+ }
87+ }, 1000);
88+ }
89+ }, 100);
90+ }
91+ */
3792 }
3893
3994 ngOnInit ( ) {
0 commit comments