@@ -4,7 +4,6 @@ import { action } from '@ember/object';
4
4
import type Owner from ' @ember/owner' ;
5
5
import { service } from ' @ember/service' ;
6
6
import Component from ' @glimmer/component' ;
7
- import { tracked } from ' @glimmer/tracking' ;
8
7
9
8
import Folder from ' @cardstack/boxel-icons/folder' ;
10
9
import { task } from ' ember-concurrency' ;
@@ -31,11 +30,10 @@ import {
31
30
cardTypeIcon ,
32
31
chooseCard ,
33
32
type Query ,
34
- type LooseSingleCardDocument ,
35
33
type ResolvedCodeRef ,
36
34
} from ' @cardstack/runtime-common' ;
37
35
38
- import CreateCardJsonCommand from ' @cardstack/host/commands/create-card-json ' ;
36
+ import CreateCardInstanceCommand from ' @cardstack/host/commands/create-card-instance ' ;
39
37
40
38
import { getCard } from ' @cardstack/host/resources/card-resource' ;
41
39
import { getCodeRef , type CardType } from ' @cardstack/host/resources/card-type' ;
@@ -382,7 +380,6 @@ class PlaygroundPanelContent extends Component<PlaygroundContentSignature> {
382
380
@service private declare realm: RealmService ;
383
381
@service private declare realmServer: RealmServerService ;
384
382
@service declare recentFilesService: RecentFilesService ;
385
- @tracked newCardJSON: LooseSingleCardDocument | undefined ;
386
383
private playgroundSelections: Record <
387
384
string , // moduleId
388
385
{ cardId: string ; format: Format }
@@ -435,8 +432,7 @@ class PlaygroundPanelContent extends Component<PlaygroundContentSignature> {
435
432
436
433
private cardResource = getCard (
437
434
this ,
438
- () =>
439
- this .newCardJSON ?? this .playgroundSelections [this .args .moduleId ]?.cardId ,
435
+ () => this .playgroundSelections [this .args .moduleId ]?.cardId ,
440
436
{ isAutoSave : () => true },
441
437
);
442
438
@@ -483,7 +479,6 @@ class PlaygroundPanelContent extends Component<PlaygroundContentSignature> {
483
479
}
484
480
485
481
private persistSelections = (cardId : string , format = this .format ) => {
486
- this .newCardJSON = undefined ;
487
482
this .playgroundSelections [this .args .moduleId ] = { cardId , format };
488
483
window .localStorage .setItem (
489
484
PlaygroundSelections ,
@@ -514,17 +509,16 @@ class PlaygroundPanelContent extends Component<PlaygroundContentSignature> {
514
509
}
515
510
});
516
511
517
- // TODO: convert this to @action once we no longer need to await below
518
512
private createNew = task (async () => {
519
513
let { commandContext } = this .commandService ;
520
- this .newCardJSON = await new CreateCardJsonCommand (commandContext ).execute ({
514
+ let card = await new CreateCardInstanceCommand (commandContext ).execute ({
515
+ parent: this ,
521
516
module: this .args .codeRef ,
522
517
realm: this .operatorModeStateService .realmURL .href ,
523
518
});
524
- await this .cardResource .loaded ; // TODO: remove await when card-resource is refactored
525
- if (this .card ) {
526
- this .recentFilesService .addRecentFileUrl (` ${this .card .id }.json ` );
527
- this .persistSelections (this .card .id , ' edit' ); // open new instance in playground in edit format
519
+ if (card ) {
520
+ this .recentFilesService .addRecentFileUrl (` ${card .id }.json ` );
521
+ this .persistSelections (card .id , ' edit' ); // open new instance in playground in edit format
528
522
}
529
523
});
530
524
0 commit comments