From 7a5e8e608633dfc5aa2211902ee3cec97e3955fa Mon Sep 17 00:00:00 2001 From: niamu01 Date: Tue, 12 Mar 2024 23:03:08 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20:bug:=20=EA=B0=92=EC=9D=B4=200?= =?UTF-8?q?=EC=9D=BC=EB=95=8C=EB=A5=BC=20=EA=B3=A0=EB=A0=A4=ED=95=B4=20nul?= =?UTF-8?q?l=EC=B2=98=EB=A6=AC=20=EB=B3=80=EA=B2=BD=20||=20->=20=3F=3F,=20?= =?UTF-8?q?push=EC=97=90=EC=84=9C=20=EC=8A=A4=ED=94=84=EB=A0=88=EB=93=9C?= =?UTF-8?q?=EC=97=B0=EC=82=B0=EC=9E=90=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - #416 --- app/src/feed/feed.cache.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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]); } }