Skip to content

Commit 62cef42

Browse files
More TS fixes
1 parent e2b28a2 commit 62cef42

7 files changed

Lines changed: 52 additions & 101 deletions

File tree

app/components/edit-selected-color.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default class EditSelectedColorComponent extends Component<EditSelectedCo
8383
@action
8484
updateColor(): void {
8585
this.args.colorPicker.setColors(
86-
this.args.palette.colors.mapBy('hex'),
86+
this.args.palette.colors.map((c) => c.hex),
8787
this.args.palette.selectedColorIndex,
8888
);
8989
}

app/components/forgot-password.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export default class ForgotPasswordComponent extends Component {
3030
await this.cognito.forgotPassword(this.username);
3131

3232
this.isConfirming = true;
33-
} catch (err) {
34-
this.errorMessage = err.message;
33+
} catch (err: unknown) {
34+
this.errorMessage = (err as Error)?.message;
3535
} finally {
3636
this.loading = false;
3737
}
@@ -49,8 +49,8 @@ export default class ForgotPasswordComponent extends Component {
4949
await this.cognito.forgotPasswordSubmit(username, code, password);
5050

5151
this.router.transitionTo('settings.cloud');
52-
} catch (err) {
53-
this.errorMessage = err.message;
52+
} catch (err: unknown) {
53+
this.errorMessage = (err as Error)?.message;
5454
} finally {
5555
this.loading = false;
5656
}

app/components/register.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export default class RegisterComponent extends Component {
2727
await this.cognito.signUp(username, password, attributes);
2828

2929
this.router.transitionTo('settings.cloud.register.confirm');
30-
} catch (err) {
31-
this.errorMessage = err?.message;
30+
} catch (err: unknown) {
31+
this.errorMessage = (err as Error)?.message;
3232
}
3333
}
3434
}

app/controllers/palettes.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { tracked } from '@glimmer/tracking';
77
import type { LiveQuery, Store } from 'ember-orbit';
88

99
import type { RecordOperationTerm } from '@orbit/records';
10+
import { TrackedArray } from 'tracked-built-ins';
1011

1112
import type ApplicationController from 'swach/controllers/application';
1213
import type ColorModel from 'swach/data-models/color';
@@ -166,7 +167,7 @@ export default class PalettesController extends Controller {
166167
...attributes,
167168
createdAt: new Date(),
168169
};
169-
const colorsList = targetList.map((c) => c.$identity);
170+
const colorsList = new TrackedArray(targetList.map((c) => c.$identity));
170171

171172
const existingColor = targetList.find((c) => c.hex === sourceColor.hex);
172173

@@ -178,7 +179,7 @@ export default class PalettesController extends Controller {
178179
}
179180
}
180181

181-
colorsList.insertAt(targetIndex, {
182+
colorsList.splice(targetIndex, 0, {
182183
type: 'color',
183184
id: colorCopy.id,
184185
});
@@ -208,12 +209,14 @@ export default class PalettesController extends Controller {
208209
sourcePalette: PaletteModel,
209210
targetIndex: number,
210211
): Promise<void> {
211-
const sourceColorList = sourceList.map((c) => c.$identity);
212-
const colorToMove = sourceColorList.findBy('id', sourceColor.id);
212+
const sourceColorList = new TrackedArray(
213+
sourceList.map((c) => c.$identity),
214+
);
215+
const colorToMove = sourceColorList.find((c) => c.id === sourceColor.id);
213216

214217
if (colorToMove) {
215218
sourceColorList.removeObject(colorToMove);
216-
sourceColorList.insertAt(targetIndex, colorToMove);
219+
sourceColorList.splice(targetIndex, 0, colorToMove);
217220

218221
await this.store.update((t) =>
219222
t.replaceAttribute(sourcePalette, 'colorOrder', sourceColorList),
@@ -233,7 +236,7 @@ export default class PalettesController extends Controller {
233236
targetPalette: PaletteModel,
234237
): Promise<void> {
235238
const sourceColorOrder = sourceList.map((c) => c.$identity);
236-
const colorToRemove = sourceColorOrder.findBy('id', sourceColor.id);
239+
const colorToRemove = sourceColorOrder.find((c) => c.id === sourceColor.id);
237240

238241
if (colorToRemove) {
239242
sourceColorOrder.removeObject(colorToRemove);
@@ -246,13 +249,16 @@ export default class PalettesController extends Controller {
246249

247250
if (!targetPalette.isColorHistory) {
248251
let insertIndex = targetIndex;
249-
const targetColorOrder = targetList.map((c) => c.$identity);
250-
const existingColor = targetList.findBy('hex', sourceColor.hex);
252+
const targetColorOrder = new TrackedArray(
253+
targetList.map((c) => c.$identity),
254+
);
255+
const existingColor = targetList.find(
256+
(c) => c.hex === sourceColor.hex,
257+
);
251258

252259
if (existingColor) {
253-
const colorToRemove = targetColorOrder.findBy(
254-
'id',
255-
existingColor.id,
260+
const colorToRemove = targetColorOrder.find(
261+
(c) => c.id === existingColor.id,
256262
);
257263

258264
if (colorToRemove) {
@@ -270,8 +276,7 @@ export default class PalettesController extends Controller {
270276

271277
t.removeFromRelatedRecords(targetPalette, 'colors', existingColor);
272278
}
273-
274-
targetColorOrder.insertAt(insertIndex, sourceColor.$identity);
279+
targetColorOrder.splice(insertIndex, 0, sourceColor.$identity);
275280

276281
operations.push(
277282
t.addToRelatedRecords(targetPalette, 'colors', sourceColor),

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"@embroider/macros": "^1.17.2",
5151
"@embroider/webpack": "^3.2.3",
5252
"@eslint/js": "^9.25.1",
53-
"@gavant/glint-template-types": "^0.4.0",
5453
"@glimmer/component": "^2.0.0",
5554
"@glimmer/tracking": "^1.1.2",
5655
"@glint/core": "^1.5.2",
@@ -82,7 +81,7 @@
8281
"color-name-list": "^10.28.1",
8382
"concurrently": "^9.1.2",
8483
"crypto-browserify": "^3.12.1",
85-
"ember-animated": "^2.0.1",
84+
"ember-animated": "^2.2.0",
8685
"ember-animated-tools": "^2.0.0",
8786
"ember-auto-import": "^2.10.0",
8887
"ember-cli": "~6.4.0",

0 commit comments

Comments
 (0)