diff --git a/app/src/feed/feed.cache.service.ts b/app/src/feed/feed.cache.service.ts index e055d1d4..9559bcf0 100644 --- a/app/src/feed/feed.cache.service.ts +++ b/app/src/feed/feed.cache.service.ts @@ -8,7 +8,7 @@ export class FeedCacheService { private feedCache = new Map(); async get(userId: number): Promise<(typeof FeedUnion)[]> { - return this.feedCache.get(userId) || []; + return this.feedCache.get(userId) ?? []; } async set(userId: number, feed: (typeof FeedUnion)[]): Promise { @@ -16,8 +16,8 @@ export class FeedCacheService { } async writeFeed(userId: number, feed: typeof FeedUnion): Promise { - const cachedFeedList = await this.get(userId); - cachedFeedList.push(feed); - await this.set(userId, cachedFeedList); + const prev = await this.get(userId); + + await this.set(userId, [...prev, feed]); } }