Skip to content

Commit

Permalink
Optional Pet Size
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-Hopkinson committed Jun 5, 2024
1 parent 46691b4 commit b16bd8a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const EXTRA_PETS_KEY = 'vscode-pets.extra-pets';
const EXTRA_PETS_KEY_TYPES = EXTRA_PETS_KEY + '.types';
const EXTRA_PETS_KEY_COLORS = EXTRA_PETS_KEY + '.colors';
const EXTRA_PETS_KEY_NAMES = EXTRA_PETS_KEY + '.names';
const DEFAULT_PET_SCALE = PetSize.nano;
const DEFAULT_PET_SCALE = PetSize.medium;
const DEFAULT_COLOR = PetColor.brown;
const DEFAULT_PET_TYPE = PetType.cat;
const DEFAULT_POSITION = ExtPosition.panel;
Expand Down Expand Up @@ -49,7 +49,7 @@ class PetQuickPickItem implements vscode.QuickPickItem {

let webviewViewProvider: PetWebviewViewProvider;

function getConfiguredSize(petSize: PetSize): PetSize {
function getConfiguredSize(petSize?: PetSize | any): PetSize {
var size = vscode.workspace
.getConfiguration('vscode-pets')
.get<PetSize>('petSize', petSize);
Expand Down Expand Up @@ -127,15 +127,15 @@ export class PetSpecification {
var type = vscode.workspace
.getConfiguration('vscode-pets')
.get<PetType>('petType', DEFAULT_PET_TYPE);

var size = vscode.workspace
.getConfiguration('vscode-pets')
.get<PetSize>('petSize');
if (ALL_PETS.lastIndexOf(type) === -1) {
type = DEFAULT_PET_TYPE;
}

return new PetSpecification(
color,
type,
getConfiguredSize(DEFAULT_PET_SCALE),
);
return new PetSpecification(color, type, getConfiguredSize(size));
}

static collectionFromMemento(
Expand Down Expand Up @@ -562,6 +562,11 @@ export function activate(context: vscode.ExtensionContext) {
return;
}

// store the selectedSize in the vscode.workspace
vscode.workspace

Check warning on line 566 in src/extension/extension.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check warning on line 566 in src/extension/extension.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
.getConfiguration('vscode-pets')
.update('petSize', selectedSize.value);

const name = await vscode.window.showInputBox({
placeHolder: vscode.l10n.t('Leave blank for a random name'),
prompt: vscode.l10n.t('Name your pet'),
Expand Down

0 comments on commit b16bd8a

Please sign in to comment.