Skip to content

Commit

Permalink
fix(town): list was not 100% width
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Sep 21, 2023
1 parent 7444cdd commit c576533
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 15 deletions.
20 changes: 11 additions & 9 deletions client/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ export class AppComponent {
url: 'town',
icon: 'town',
indicator: combineLatest([
this.marketService.getClaimCoins().pipe(
map((coins: any) =>
(coins as number) > 0
? {
color: 'primary',
icon: 'global-important',
tooltip: `${coins.toLocaleString()} coins to take from the market!`,
}
: undefined,
timer(0, 1000).pipe(
switchMap(() =>
this.store.select((state) =>
state.market.claimCoins > 0
? {
color: 'primary',
icon: 'global-important',
tooltip: 'Crafting complete!',
}
: undefined,
),
),
),
this.marketService.claimedCoins$,
Expand Down
8 changes: 2 additions & 6 deletions client/src/app/pages/login/login.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { MenuController } from '@ionic/angular';
import { AnnouncementService } from '@services/announcement.service';
import { NotificationsService } from '@services/notifications.service';
import { AuthService } from '../../services/auth.service';

import { marked } from 'marked';
Expand Down Expand Up @@ -80,7 +79,6 @@ export class LoginPage implements OnInit {
constructor(
public menu: MenuController,
private authService: AuthService,
private notificationService: NotificationsService,
public announcementService: AnnouncementService,
private router: Router,
) {}
Expand Down Expand Up @@ -129,8 +127,7 @@ export class LoginPage implements OnInit {
return;
}

this.router.navigate(['/']);
this.notificationService.getNotifications();
this.authService.postLoginActions();
},
error: () => {
this.loginError = 'Invalid email or password.';
Expand Down Expand Up @@ -179,8 +176,7 @@ export class LoginPage implements OnInit {
return;
}

this.router.navigate(['/']);
this.notificationService.getNotifications();
this.authService.postLoginActions();
},
error: (err) => {
this.registerError = err.error.message;
Expand Down
22 changes: 22 additions & 0 deletions client/src/app/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { JwtHelperService } from '@auth0/angular-jwt';
import { Store } from '@ngxs/store';
import { MarketService } from '@services/market.service';
import { NotificationsService } from '@services/notifications.service';
import { SetClaimCoins } from '@stores/market/market.actions';
import { interval, tap } from 'rxjs';
import { environment } from '../../environments/environment';

Expand All @@ -10,9 +14,12 @@ import { environment } from '../../environments/environment';
})
export class AuthService {
constructor(
private store: Store,
private router: Router,
private http: HttpClient,
private jwtHelper: JwtHelperService,
private notificationService: NotificationsService,
private marketService: MarketService,
) {}

public init() {
Expand All @@ -32,6 +39,7 @@ export class AuthService {

this.login(lastEmail, lastPassword).subscribe(() => {
this.updateToken();
this.postLoginActionsAlways();
});
}

Expand Down Expand Up @@ -78,4 +86,18 @@ export class AuthService {

this.router.navigate(['/login']);
}

public postLoginActions() {
this.router.navigate(['/']);

this.postLoginActionsAlways();
}

private postLoginActionsAlways() {
this.notificationService.getNotifications();

this.marketService.getClaimCoins().subscribe((coins) => {
this.store.dispatch(new SetClaimCoins(coins as number));
});
}
}
1 change: 1 addition & 0 deletions client/src/interfaces/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import { IMarketItemExpanded, IPagination } from '@interfaces';

export interface IMarketStore {
version: number;
claimCoins: number;
marketData: IPagination<IMarketItemExpanded>;
}
5 changes: 5 additions & 0 deletions client/src/stores/market/market.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ export class RepriceMarketItem {
static type = 'RepriceMarketItem';
constructor(public listingId: string, public newPrice: number) {}
}

export class SetClaimCoins {
static type = '[Market] Set Claim Coins';
constructor(public coins: number) {}
}
3 changes: 3 additions & 0 deletions client/src/stores/market/market.attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ import { IAttachment } from '../../interfaces';
import {
RemoveMarketItem,
RepriceMarketItem,
SetClaimCoins,
SetMarketItems,
} from './market.actions';
import {
removeMarketItem,
repriceMarketItem,
setClaimCoins,
setMarketItems,
} from './market.functions';

export const attachments: IAttachment[] = [
{ action: SetMarketItems, handler: setMarketItems },
{ action: RemoveMarketItem, handler: removeMarketItem },
{ action: RepriceMarketItem, handler: repriceMarketItem },
{ action: SetClaimCoins, handler: setClaimCoins },
];
13 changes: 13 additions & 0 deletions client/src/stores/market/market.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { patch, removeItem, updateItem } from '@ngxs/store/operators';
import {
RemoveMarketItem,
RepriceMarketItem,
SetClaimCoins,
SetMarketItems,
} from './market.actions';

export const defaultStore: () => IMarketStore = () => ({
version: 0,
claimCoins: 0,
marketData: {
lastPage: 0,
page: 0,
Expand Down Expand Up @@ -61,3 +63,14 @@ export function repriceMarketItem(
}),
);
}

export function setClaimCoins(
ctx: StateContext<IMarketStore>,
{ coins }: SetClaimCoins,
) {
ctx.setState(
patch({
claimCoins: coins,
}),
);
}
5 changes: 5 additions & 0 deletions client/src/stores/market/market.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export class MarketStore {
});
}

@Selector()
static claimCoins(state: IMarketStore) {
return state.claimCoins ?? 0;
}

@Selector()
static marketData(state: IMarketStore) {
return state.marketData;
Expand Down
4 changes: 4 additions & 0 deletions client/src/styles/ionic-overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ ion-chip.readonly {
ion-icon {
transition: color 0.3s ease-in-out;
}

ion-card ion-list {
width: 100%;
}

0 comments on commit c576533

Please sign in to comment.