Skip to content

Commit fd91dbb

Browse files
authored
Merge pull request #114 from bustle/bug/schedule-once
[Bug] Render multiple cards successfully
2 parents 3b44547 + 0494ff2 commit fd91dbb

5 files changed

Lines changed: 262 additions & 49 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,63 +10,42 @@ jobs:
1010
lint:
1111
name: Lint
1212
runs-on: ubuntu-latest
13-
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v4
16-
17-
- name: Setup Node.js
18-
uses: actions/setup-node@v4
19-
with:
20-
node-version: '20'
21-
cache: 'pnpm'
22-
23-
- name: Setup pnpm
24-
uses: pnpm/action-setup@v2
25-
with:
26-
version: '10'
27-
28-
- name: Install dependencies
29-
run: pnpm install --frozen-lockfile
3013

31-
- name: Run lint
32-
run: pnpm run lint
33-
name: CI
34-
35-
on:
36-
push:
37-
branches:
38-
- main
39-
- master
40-
pull_request: {}
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: volta-cli/action@v4
17+
- run: volta install node pnpm
18+
- run: pnpm install --frozen-lockfile
19+
- run: pnpm run lint
4120

42-
jobs:
4321
test:
44-
name: "Tests"
22+
name: Tests
4523
runs-on: ubuntu-latest
24+
needs: lint
4625

4726
steps:
48-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v4
4928
- uses: volta-cli/action@v4
5029
- run: volta install node pnpm
5130
- run: pnpm install --frozen-lockfile
52-
- run: pnpm run lint
5331
- run: pnpm run test:ember
5432

5533
floating:
56-
name: "Floating Dependencies"
34+
name: Floating Dependencies
5735
runs-on: ubuntu-latest
36+
needs: lint
5837

5938
steps:
60-
- uses: actions/checkout@v2
39+
- uses: actions/checkout@v4
6140
- uses: volta-cli/action@v4
6241
- run: volta install node pnpm
6342
- run: pnpm install --no-lockfile
6443
- run: pnpm run test:ember
6544

6645
try-scenarios:
67-
name: ${{ matrix.try-scenario }}
46+
name: Ember Try - ${{ matrix.try-scenario }}
6847
runs-on: ubuntu-latest
69-
needs: "test"
48+
needs: test
7049

7150
strategy:
7251
fail-fast: false
@@ -79,7 +58,7 @@ jobs:
7958
- ember-canary
8059

8160
steps:
82-
- uses: actions/checkout@v2
61+
- uses: actions/checkout@v4
8362
- uses: volta-cli/action@v4
8463
- run: volta install node pnpm
8564
- run: pnpm install --frozen-lockfile

addon/components/render-mobiledoc.gts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Component from '@glimmer/component';
22
import { tracked } from '@glimmer/tracking';
3-
import { scheduleOnce } from '@ember/runloop';
3+
import { schedule, scheduleOnce } from '@ember/runloop';
44
import Renderer from 'ember-mobiledoc-dom-renderer';
55
import { getDocument } from 'ember-mobiledoc-dom-renderer/utils/document';
66
import { guidFor } from '@ember/object/internals';
@@ -324,7 +324,7 @@ export default class RenderMobiledocComponent extends Component<Signature> {
324324

325325
private addCard(card: CardRegistration): void {
326326
// Defer mutation to after the current render to avoid updating a value during computation
327-
scheduleOnce('afterRender', this, this._addCard, card);
327+
schedule('afterRender', this, this._addCard, card);
328328
}
329329

330330
private _addCard(card: CardRegistration): void {
@@ -333,7 +333,7 @@ export default class RenderMobiledocComponent extends Component<Signature> {
333333

334334
private removeCard(card: CardRegistration): void {
335335
// Defer mutation to after the current render to avoid updating a value during computation
336-
scheduleOnce('afterRender', this, this._removeCard, card);
336+
schedule('afterRender', this, this._removeCard, card);
337337
}
338338

339339
private _removeCard(card: CardRegistration): void {
@@ -344,7 +344,7 @@ export default class RenderMobiledocComponent extends Component<Signature> {
344344

345345
private addAtom(atom: AtomRegistration): void {
346346
// Defer mutation to after the current render to avoid updating a value during computation
347-
scheduleOnce('afterRender', this, this._addAtom, atom);
347+
schedule('afterRender', this, this._addAtom, atom);
348348
}
349349

350350
private _addAtom(atom: AtomRegistration): void {
@@ -353,7 +353,7 @@ export default class RenderMobiledocComponent extends Component<Signature> {
353353

354354
private removeAtom(atom: AtomRegistration): void {
355355
// Defer mutation to after the current render to avoid updating a value during computation
356-
scheduleOnce('afterRender', this, this._removeAtom, atom);
356+
schedule('afterRender', this, this._removeAtom, atom);
357357
}
358358

359359
private _removeAtom(atom: AtomRegistration): void {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
"@glint/environment-ember-template-imports": "^1.5.2",
5959
"@glint/template": "^1.6.2",
6060
"@release-it-plugins/lerna-changelog": "^8.0.1",
61+
"@types/ember__application": "^4.0.11",
62+
"@types/ember__runloop": "^4.0.10",
6163
"@typescript-eslint/eslint-plugin": "^8.46.2",
6264
"@typescript-eslint/parser": "^8.46.2",
6365
"broccoli-asset-rev": "^3.0.0",

0 commit comments

Comments
 (0)