Skip to content

Commit 7432bab

Browse files
Closing Snackbar Rules
1. Setting the default configuration for the snackbar to close after 5 seconds. 2. Closing the snackbar in the destroy. closes #35
1 parent ba20c7a commit 7432bab

File tree

6 files changed

+11
-44
lines changed

6 files changed

+11
-44
lines changed

src/src/app/app.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@ import { routes } from './app.routes';
55
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
66
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from "@angular/common/http";
77
import { BearerTokenInterceptor } from "./middleware/bearer-token-interceptor";
8+
import {MAT_SNACK_BAR_DEFAULT_OPTIONS} from "@angular/material/snack-bar";
89

910
export const noopInterceptorProvider: Provider =
1011
{provide: HTTP_INTERCEPTORS, useClass: BearerTokenInterceptor, multi: true};
1112

13+
export const materialSnackbarDefaults: Provider =
14+
{provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: {duration: 5 * 1000}};
15+
1216
export const appConfig: ApplicationConfig = {
1317
providers: [
1418
provideRouter(routes),
1519
provideAnimationsAsync(),
1620
provideHttpClient(withInterceptorsFromDi()),
1721
noopInterceptorProvider,
22+
materialSnackbarDefaults
1823
]
1924
};

src/src/app/common/components/success-snack-bar/success-snack-bar.component.html

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/src/app/common/components/success-snack-bar/success-snack-bar.component.scss

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/src/app/common/components/success-snack-bar/success-snack-bar.component.spec.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/src/app/common/components/success-snack-bar/success-snack-bar.component.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/src/app/view/twitch/twitch-bot-config/twitch-bot-config.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ export class TwitchBotConfigComponent implements OnInit, OnDestroy {
5151
if (this.timerId !== -1) {
5252
clearTimeout(this.timerId);
5353
}
54+
55+
// Close any open notifications when we move to a different screen.
56+
this.snackBar.dismiss();
5457
}
5558

5659
ngOnInit(): void {
@@ -62,9 +65,9 @@ export class TwitchBotConfigComponent implements OnInit, OnDestroy {
6265
if (Errors.TwitchAccountHasNoEmail === errorNum) {
6366
this.onLoginFailed('Your Twitch account must have a valid e-mail address, please add one and try again', false)
6467
} else if (Errors.TwitchErrorWithToken === errorNum) {
65-
this.onLoginFailed('Twitch failed to give us a valid token, please add one and try again', false)
68+
this.onLoginFailed('Twitch failed to log you in successfully, please try again', false)
6669
} else {
67-
this.onLoginFailed('Sorry we did something wrong trying to log you in, please add one and try again', false)
70+
this.onLoginFailed('Sorry we did something wrong trying to log you in, please try again', false)
6871
}
6972

7073
return;
@@ -167,7 +170,7 @@ export class TwitchBotConfigComponent implements OnInit, OnDestroy {
167170
},
168171
error: err => {
169172
console.error(err);
170-
this.snackBar.open('Failed to save config, please try again...', undefined, {
173+
this.snackBar.open('Failed to save, please try again', undefined, {
171174
panelClass: ['snackbar-failure']
172175
});
173176
}

0 commit comments

Comments
 (0)