Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 4546ce6

Browse files
Merge pull request #1043 from deckgo/signin
fix: signin if already signedin from website
2 parents e409138 + c78f14d commit 4546ce6

File tree

9 files changed

+132
-31
lines changed

9 files changed

+132
-31
lines changed

studio/src/app/app-root.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,19 @@ export class AppRoot {
176176
return [
177177
<ion-app class={this.loading ? 'loading' : undefined}>
178178
<ion-router useHash={false}>
179-
<ion-route url="/" component="app-dashboard" />
179+
<ion-route url="/" component="app-dashboard-page" />
180180

181181
<ion-route url="/editor" component="app-editor" />
182182
<ion-route url="/editor/:deckId" component="app-editor" />
183183

184184
<ion-route url="/profile" component="app-profile" />
185185
<ion-route url="/customization" component="app-customization" />
186186

187-
<ion-route url="/dashboard" component="app-dashboard" />
187+
<ion-route url="/dashboard" component="app-dashboard-page" />
188188

189-
<ion-route url="/signin" component="app-signin" />
190-
<ion-route url="/signin/:redirect" component="app-signin" />
191-
<ion-route url="/signin/:redirect/:redirectId" component="app-signin" />
189+
<ion-route url="/signin" component="app-signin-page" />
190+
<ion-route url="/signin/:redirect" component="app-signin-page" />
191+
<ion-route url="/signin/:redirect/:redirectId" component="app-signin-page" />
192192

193193
<ion-route url="/poll" component="app-poll" />
194194
<ion-route url="/poll/:pollKey" component="app-poll" />

studio/src/app/pages/core/app-signin/app-signin.tsx renamed to studio/src/app/components/core/app-signin/app-signin.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export class AppSignIn {
217217

218218
let token: string | null = null;
219219
if (authStore.state.authUser) {
220-
token = await firebase.auth().currentUser.getIdToken();
220+
token = await firebase.auth().currentUser?.getIdToken();
221221
}
222222

223223
localStorage.setItem(
@@ -280,22 +280,19 @@ export class AppSignIn {
280280

281281
render() {
282282
return [
283-
<app-navigation></app-navigation>,
284-
<ion-content class="ion-padding fullscreen-padding">
285-
<main class="ion-padding fit">
286-
{this.renderBackButton()}
283+
<main class="ion-padding fit">
284+
{this.renderBackButton()}
287285

288-
{this.renderMsg()}
286+
{this.renderMsg()}
289287

290-
{this.renderGitHub()}
288+
{this.renderGitHub()}
291289

292-
<div id="firebaseui-auth-container"></div>
290+
<div id="firebaseui-auth-container"></div>
293291

294-
<p class="ion-text-center ion-padding-start ion-padding-end">
295-
<small>DeckDeckGo is free and open source 😃.</small>
296-
</p>
297-
</main>
298-
</ion-content>,
292+
<p class="ion-text-center ion-padding-start ion-padding-end">
293+
<small>DeckDeckGo is free and open source 😃.</small>
294+
</p>
295+
</main>,
299296
];
300297
}
301298

studio/src/app/pages/core/app-dashboard/app-dashboard.tsx renamed to studio/src/app/components/dashboard/app-dashboard/app-dashboard.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class AppDashboard {
142142
const promises: Promise<void>[] = [];
143143

144144
this.decks.forEach((deck: DeckAndFirstSlide) => {
145-
if (deck.deck?.data?.clone !== undefined) {
145+
if (deck?.deck?.data?.clone !== undefined) {
146146
promises.push(this.deckDashboardService.snapshot(deck.deck, this.watchClonedDeck));
147147
}
148148
});
@@ -425,15 +425,6 @@ export class AppDashboard {
425425
};
426426

427427
render() {
428-
return (
429-
<Fragment>
430-
<app-navigation presentation={true}></app-navigation>
431-
<ion-content class="ion-padding">{this.renderContent()}</ion-content>
432-
</Fragment>
433-
);
434-
}
435-
436-
private renderContent() {
437428
if (this.loading) {
438429
return this.renderLoading();
439430
}

studio/src/app/components/editor/app-slot-type/app-slot-type.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ app-slot-type {
1313

1414
ion-list {
1515
ion-item {
16-
h1,
16+
h1 {
17+
font-size: 28px;
18+
}
19+
1720
h2 {
18-
font-weight: 400;
21+
font-size: 20px;
1922
}
2023

2124
h3 {
22-
font-weight: 400;
25+
font-size: 17px;
2326
}
2427

2528
h1,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {Component, h, Fragment} from '@stencil/core';
2+
3+
@Component({
4+
tag: 'app-dashboard-page',
5+
})
6+
export class AppDashboardPage {
7+
render() {
8+
return [
9+
<Fragment>
10+
<app-navigation presentation={true}></app-navigation>
11+
<ion-content class="ion-padding">
12+
<app-dashboard></app-dashboard>
13+
</ion-content>
14+
</Fragment>,
15+
];
16+
}
17+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import {Component, Fragment, h, Prop, State} from '@stencil/core';
2+
3+
import {AuthUser} from '../../../models/auth/auth.user';
4+
5+
import authStore from '../../../stores/auth.store';
6+
7+
@Component({
8+
tag: 'app-signin-page',
9+
})
10+
export class AppSigninPage {
11+
@Prop()
12+
redirect: string;
13+
14+
@Prop()
15+
redirectId: string;
16+
17+
@State()
18+
private signin: boolean;
19+
20+
private destroyListener;
21+
22+
async componentWillLoad() {
23+
this.destroyListener = authStore.onChange('authUser', async (authUser: AuthUser | null) => {
24+
if (!authUser) {
25+
this.signin = true;
26+
}
27+
});
28+
29+
await this.initSignedIn();
30+
}
31+
32+
private async initSignedIn() {
33+
this.signin = authStore.state.authUser === undefined || authStore.state.anonymous;
34+
}
35+
36+
disconnectedCallback() {
37+
if (this.destroyListener) {
38+
this.destroyListener();
39+
}
40+
}
41+
42+
render() {
43+
if (this.signin) {
44+
return (
45+
<Fragment>
46+
<app-navigation></app-navigation>
47+
<ion-content class="ion-padding fullscreen-padding">
48+
<app-signin redirect={this.redirect} redirectId={this.redirectId}></app-signin>
49+
</ion-content>
50+
</Fragment>
51+
);
52+
}
53+
54+
return (
55+
<Fragment>
56+
<app-navigation presentation={true}></app-navigation>
57+
<ion-content class="ion-padding">
58+
<app-dashboard></app-dashboard>
59+
</ion-content>
60+
</Fragment>
61+
);
62+
}
63+
}

studio/src/components.d.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ export namespace Components {
134134
interface AppDashboardDeckActions {
135135
"deck": Deck;
136136
}
137+
interface AppDashboardPage {
138+
}
137139
interface AppDeckDelete {
138140
"deckName": string;
139141
"published": string;
@@ -341,6 +343,10 @@ export namespace Components {
341343
"redirect": string;
342344
"redirectId": string;
343345
}
346+
interface AppSigninPage {
347+
"redirect": string;
348+
"redirectId": string;
349+
}
344350
interface AppSlideNavigate {
345351
}
346352
interface AppSlidePreview {
@@ -550,6 +556,12 @@ declare global {
550556
prototype: HTMLAppDashboardDeckActionsElement;
551557
new (): HTMLAppDashboardDeckActionsElement;
552558
};
559+
interface HTMLAppDashboardPageElement extends Components.AppDashboardPage, HTMLStencilElement {
560+
}
561+
var HTMLAppDashboardPageElement: {
562+
prototype: HTMLAppDashboardPageElement;
563+
new (): HTMLAppDashboardPageElement;
564+
};
553565
interface HTMLAppDeckDeleteElement extends Components.AppDeckDelete, HTMLStencilElement {
554566
}
555567
var HTMLAppDeckDeleteElement: {
@@ -904,6 +916,12 @@ declare global {
904916
prototype: HTMLAppSigninElement;
905917
new (): HTMLAppSigninElement;
906918
};
919+
interface HTMLAppSigninPageElement extends Components.AppSigninPage, HTMLStencilElement {
920+
}
921+
var HTMLAppSigninPageElement: {
922+
prototype: HTMLAppSigninPageElement;
923+
new (): HTMLAppSigninPageElement;
924+
};
907925
interface HTMLAppSlideNavigateElement extends Components.AppSlideNavigate, HTMLStencilElement {
908926
}
909927
var HTMLAppSlideNavigateElement: {
@@ -1006,6 +1024,7 @@ declare global {
10061024
"app-customization": HTMLAppCustomizationElement;
10071025
"app-dashboard": HTMLAppDashboardElement;
10081026
"app-dashboard-deck-actions": HTMLAppDashboardDeckActionsElement;
1027+
"app-dashboard-page": HTMLAppDashboardPageElement;
10091028
"app-deck-delete": HTMLAppDeckDeleteElement;
10101029
"app-deck-fonts": HTMLAppDeckFontsElement;
10111030
"app-deck-header-footer": HTMLAppDeckHeaderFooterElement;
@@ -1065,6 +1084,7 @@ declare global {
10651084
"app-share-deck": HTMLAppShareDeckElement;
10661085
"app-share-options": HTMLAppShareOptionsElement;
10671086
"app-signin": HTMLAppSigninElement;
1087+
"app-signin-page": HTMLAppSigninPageElement;
10681088
"app-slide-navigate": HTMLAppSlideNavigateElement;
10691089
"app-slide-preview": HTMLAppSlidePreviewElement;
10701090
"app-slide-warning": HTMLAppSlideWarningElement;
@@ -1228,6 +1248,8 @@ declare namespace LocalJSX {
12281248
"onDeckCloned"?: (event: CustomEvent<DeckDashboardCloneResult>) => void;
12291249
"onDeckDeleted"?: (event: CustomEvent<string>) => void;
12301250
}
1251+
interface AppDashboardPage {
1252+
}
12311253
interface AppDeckDelete {
12321254
"deckName"?: string;
12331255
"published"?: string;
@@ -1461,6 +1483,10 @@ declare namespace LocalJSX {
14611483
"redirect"?: string;
14621484
"redirectId"?: string;
14631485
}
1486+
interface AppSigninPage {
1487+
"redirect"?: string;
1488+
"redirectId"?: string;
1489+
}
14641490
interface AppSlideNavigate {
14651491
"onReorder"?: (event: CustomEvent<ItemReorderEventDetail>) => void;
14661492
}
@@ -1527,6 +1553,7 @@ declare namespace LocalJSX {
15271553
"app-customization": AppCustomization;
15281554
"app-dashboard": AppDashboard;
15291555
"app-dashboard-deck-actions": AppDashboardDeckActions;
1556+
"app-dashboard-page": AppDashboardPage;
15301557
"app-deck-delete": AppDeckDelete;
15311558
"app-deck-fonts": AppDeckFonts;
15321559
"app-deck-header-footer": AppDeckHeaderFooter;
@@ -1586,6 +1613,7 @@ declare namespace LocalJSX {
15861613
"app-share-deck": AppShareDeck;
15871614
"app-share-options": AppShareOptions;
15881615
"app-signin": AppSignin;
1616+
"app-signin-page": AppSigninPage;
15891617
"app-slide-navigate": AppSlideNavigate;
15901618
"app-slide-preview": AppSlidePreview;
15911619
"app-slide-warning": AppSlideWarning;
@@ -1633,6 +1661,7 @@ declare module "@stencil/core" {
16331661
"app-customization": LocalJSX.AppCustomization & JSXBase.HTMLAttributes<HTMLAppCustomizationElement>;
16341662
"app-dashboard": LocalJSX.AppDashboard & JSXBase.HTMLAttributes<HTMLAppDashboardElement>;
16351663
"app-dashboard-deck-actions": LocalJSX.AppDashboardDeckActions & JSXBase.HTMLAttributes<HTMLAppDashboardDeckActionsElement>;
1664+
"app-dashboard-page": LocalJSX.AppDashboardPage & JSXBase.HTMLAttributes<HTMLAppDashboardPageElement>;
16361665
"app-deck-delete": LocalJSX.AppDeckDelete & JSXBase.HTMLAttributes<HTMLAppDeckDeleteElement>;
16371666
"app-deck-fonts": LocalJSX.AppDeckFonts & JSXBase.HTMLAttributes<HTMLAppDeckFontsElement>;
16381667
"app-deck-header-footer": LocalJSX.AppDeckHeaderFooter & JSXBase.HTMLAttributes<HTMLAppDeckHeaderFooterElement>;
@@ -1692,6 +1721,7 @@ declare module "@stencil/core" {
16921721
"app-share-deck": LocalJSX.AppShareDeck & JSXBase.HTMLAttributes<HTMLAppShareDeckElement>;
16931722
"app-share-options": LocalJSX.AppShareOptions & JSXBase.HTMLAttributes<HTMLAppShareOptionsElement>;
16941723
"app-signin": LocalJSX.AppSignin & JSXBase.HTMLAttributes<HTMLAppSigninElement>;
1724+
"app-signin-page": LocalJSX.AppSigninPage & JSXBase.HTMLAttributes<HTMLAppSigninPageElement>;
16951725
"app-slide-navigate": LocalJSX.AppSlideNavigate & JSXBase.HTMLAttributes<HTMLAppSlideNavigateElement>;
16961726
"app-slide-preview": LocalJSX.AppSlidePreview & JSXBase.HTMLAttributes<HTMLAppSlidePreviewElement>;
16971727
"app-slide-warning": LocalJSX.AppSlideWarning & JSXBase.HTMLAttributes<HTMLAppSlideWarningElement>;

0 commit comments

Comments
 (0)