Skip to content

Commit

Permalink
Make the dialog gray out while fetching the seamntic order.
Browse files Browse the repository at this point in the history
Part of #688.
  • Loading branch information
jkomoros committed Apr 8, 2024
1 parent b2089b2 commit f13391f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/actions/bulk-import.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BULK_IMPORT_DIALOG_CLOSE,
BULK_IMPORT_DIALOG_OPEN,
BULK_IMPORT_PENDING,
BULK_IMPORT_SET_BODIES,
BULK_IMPORT_SET_OVERRIDE_CARD_ORDER,
SomeAction
Expand Down Expand Up @@ -89,6 +90,9 @@ export const semanticSortExport = () : ThunkSomeAction => async (dispatch, getSt
if (!selectUserMayUseAI(state)) throw new Error('User may not use AI');
const cards = selectActiveCollectionCards(state);
const cardIDs = cards.map(card => card.id);
dispatch({
type: BULK_IMPORT_PENDING
});
const result = await semanticSortCallable({cards: cardIDs});
dispatch({
type: BULK_IMPORT_SET_OVERRIDE_CARD_ORDER,
Expand Down
17 changes: 11 additions & 6 deletions src/components/bulk-import-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class BulkImportDialog extends connect(store)(DialogElement) {
];

private innerRenderImport() {
return html`<div class='${this._pending ? 'pending' : ''}'>
<div class='scrim'></div>
return html`
${this._bodies.length ?
html`<p>Verify these bodies are ones you want to create!</p>
${this._bodies.map((body) => html`<textarea disabled .value=${body}></textarea>`)}` :
Expand All @@ -124,8 +123,7 @@ class BulkImportDialog extends connect(store)(DialogElement) {
>
${CHECK_CIRCLE_OUTLINE_ICON}
</button>
</div>
</div>`;
</div>`;
}

private innerRenderExport() {
Expand All @@ -146,15 +144,22 @@ class BulkImportDialog extends connect(store)(DialogElement) {
}

override innerRender() {
let content = html``;
if (!this.open) return html``;
switch (this._mode) {
case 'import':
return this.innerRenderImport();
content = this.innerRenderImport();
break;
case 'export':
return this.innerRenderExport();
content = this.innerRenderExport();
break;
default:
return assertUnreachable(this._mode);
}
return html`<div class='${this._pending ? 'pending' : ''}'>
<div class='scrim'></div>
${content}
</div>`;
}

_handleRawPaste(e : ClipboardEvent) {
Expand Down
3 changes: 2 additions & 1 deletion src/reducers/bulk-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ const app = (state : BulkImportState = INITIAL_STATE, action : SomeAction) : Bul
case BULK_IMPORT_SET_OVERRIDE_CARD_ORDER:
return {
...state,
overrideCardOrder: action.order
overrideCardOrder: action.order,
pending: false
};
default:
return state;
Expand Down

0 comments on commit f13391f

Please sign in to comment.