diff --git a/app/services/activity.js b/app/services/activity.js index 183e01a..5e7b50f 100644 --- a/app/services/activity.js +++ b/app/services/activity.js @@ -61,7 +61,7 @@ export default class ActivityService extends Service { * @param {string|null} pubkey The user's Nostr pubkey, or null */ async load(pubkey) { - if (this.items.length > 0 && pubkey) return; + if (this.items.length > 0) return; this._userPubkey = pubkey || null; this._since = Math.floor(Date.now() / 1000) - SINCE_WINDOW; this.isLoading = true; diff --git a/tests/unit/services/activity-test.js b/tests/unit/services/activity-test.js index d992c23..cf4e40d 100644 --- a/tests/unit/services/activity-test.js +++ b/tests/unit/services/activity-test.js @@ -273,13 +273,17 @@ module('Unit | Service | activity', function (hooks) { assert.strictEqual(service._userPubkey, null); }); - test('load with no pubkey clears items', async function (assert) { + test('load with no pubkey preserves existing items', async function (assert) { const service = this.owner.lookup('service:activity'); service.items = [{ fake: true }]; await service.load(null); - assert.strictEqual(service.items.length, 0); + assert.strictEqual( + service.items.length, + 1, + 'items preserved when already loaded' + ); }); test('_resolveSender applies profile when available', function (assert) {