Skip to content

Commit

Permalink
feat: disable already used models (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
aykutkardas authored Mar 5, 2024
1 parent a7d7d2e commit 6904d6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,15 @@ export default function UpscalerBattleground() {
<div className="flex w-full items-end justify-between border-y py-2 mb-3">
<div className="w-1/2 flex justify-start">
<ModelDropdown
disableList={[secondModel?.model]}
onSelect={(model) => setFirstModel(model)}
value={firstModel}
/>
</div>

<div className="w-1/2 flex justify-end">
<ModelDropdown
disableList={[firstModel?.model]}
onSelect={(model) => setSecondModel(model)}
value={secondModel}
/>
Expand Down
8 changes: 7 additions & 1 deletion components/model-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ export const UPSCALE_MODELS: Model[] = [
];

export function ModelDropdown({
disableList,
onSelect,
value,
}: {
value: Model | null;
onSelect: (model: Model) => void;
disableList: Array<string | undefined>;
}) {
return (
<DropdownMenu>
Expand All @@ -62,7 +64,11 @@ export function ModelDropdown({
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{UPSCALE_MODELS.map((model) => (
<DropdownMenuItem key={model.name} onClick={() => onSelect(model)}>
<DropdownMenuItem
key={model.name}
disabled={disableList.includes(model.model)}
onClick={() => onSelect(model)}
>
{model.name}
</DropdownMenuItem>
))}
Expand Down

0 comments on commit 6904d6b

Please sign in to comment.