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

Commit 71ca251

Browse files
feat: if deck is busy, can't add slide
1 parent 483a240 commit 71ca251

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

studio/src/app/components/editor/app-add-slide-action/app-add-slide-action.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import {Component, Event, EventEmitter} from '@stencil/core';
1+
import {Component, Event, EventEmitter, State} from '@stencil/core';
2+
3+
import {Subscription} from 'rxjs';
4+
5+
import {DeckBusyService} from '../../../services/deck/deck-busy.service';
26

37
@Component({
48
tag: 'app-add-slide-action',
@@ -9,12 +13,34 @@ export class AppAddSlideAction {
913

1014
@Event() private actionOpenSlideAdd: EventEmitter<UIEvent>;
1115

16+
private subscription: Subscription;
17+
private deckBusyService: DeckBusyService;
18+
19+
@State()
20+
private deckBusy: boolean = false;
21+
22+
constructor() {
23+
this.deckBusyService = DeckBusyService.getInstance();
24+
}
25+
1226
private openSlideAdd($event: UIEvent) {
1327
this.actionOpenSlideAdd.emit($event);
1428
}
1529

30+
async componentWillLoad() {
31+
this.subscription = this.deckBusyService.watch().subscribe((busy: boolean) => {
32+
this.deckBusy = busy;
33+
});
34+
}
35+
36+
async componentDidUnload() {
37+
if (this.subscription) {
38+
this.subscription.unsubscribe();
39+
}
40+
}
41+
1642
render() {
17-
return <ion-button onClick={(e: UIEvent) => this.openSlideAdd(e)} color="primary" shape="round"
43+
return <ion-button onClick={(e: UIEvent) => this.openSlideAdd(e)} color="primary" shape="round" disabled={this.deckBusy}
1844
size="small">
1945
<ion-label>Add slide</ion-label>
2046
</ion-button>;

0 commit comments

Comments
 (0)