From ed4648e5868d8d97561ffa37ca3349c16ff18a8c Mon Sep 17 00:00:00 2001 From: soopeach Date: Sun, 11 Dec 2022 02:37:29 +0900 Subject: [PATCH] =?UTF-8?q?:fire:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20withContext=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RunningHistoryLocalDataSourceImpl.kt | 2 +- .../GroupNotificationDataSourceImpl.kt | 46 ++++++++----------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/data/src/main/java/com/whyranoid/data/account/RunningHistoryLocalDataSourceImpl.kt b/data/src/main/java/com/whyranoid/data/account/RunningHistoryLocalDataSourceImpl.kt index 2b3411e0..cc181da6 100644 --- a/data/src/main/java/com/whyranoid/data/account/RunningHistoryLocalDataSourceImpl.kt +++ b/data/src/main/java/com/whyranoid/data/account/RunningHistoryLocalDataSourceImpl.kt @@ -22,7 +22,7 @@ class RunningHistoryLocalDataSourceImpl @Inject constructor( } override suspend fun saveRunningHistory(runningHistoryEntity: RunningHistoryEntity): Result { - return kotlin.runCatching { + return runCatching { runningHistoryDao.addRunningHistory(runningHistoryEntity) runningHistoryEntity.toRunningHistory() } diff --git a/data/src/main/java/com/whyranoid/data/groupnotification/GroupNotificationDataSourceImpl.kt b/data/src/main/java/com/whyranoid/data/groupnotification/GroupNotificationDataSourceImpl.kt index b5308513..35aa6d16 100644 --- a/data/src/main/java/com/whyranoid/data/groupnotification/GroupNotificationDataSourceImpl.kt +++ b/data/src/main/java/com/whyranoid/data/groupnotification/GroupNotificationDataSourceImpl.kt @@ -13,7 +13,6 @@ import com.whyranoid.domain.model.FinishNotification import com.whyranoid.domain.model.GroupNotification import com.whyranoid.domain.model.RunningHistory import com.whyranoid.domain.model.StartNotification -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow @@ -22,7 +21,6 @@ import kotlinx.coroutines.flow.flattenMerge import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.tasks.await -import kotlinx.coroutines.withContext import java.util.UUID import javax.inject.Inject @@ -98,19 +96,17 @@ class GroupNotificationDataSourceImpl @Inject constructor( } override suspend fun notifyRunningStart(uid: String, groupIdList: List) { - withContext(Dispatchers.IO) { - groupIdList.forEach { groupId -> - db.collection(GROUP_NOTIFICATIONS_COLLECTION) - .document(groupId) - .collection(START_NOTIFICATION) - .document(UUID.randomUUID().toString()) - .set( - StartNotification( - startedAt = System.currentTimeMillis(), - uid = uid - ) + groupIdList.forEach { groupId -> + db.collection(GROUP_NOTIFICATIONS_COLLECTION) + .document(groupId) + .collection(START_NOTIFICATION) + .document(UUID.randomUUID().toString()) + .set( + StartNotification( + startedAt = System.currentTimeMillis(), + uid = uid ) - } + ) } } @@ -119,19 +115,17 @@ class GroupNotificationDataSourceImpl @Inject constructor( runningHistory: RunningHistory, groupIdList: List ) { - withContext(Dispatchers.IO) { - groupIdList.forEach { groupId -> - db.collection(GROUP_NOTIFICATIONS_COLLECTION) - .document(groupId) - .collection(FINISH_NOTIFICATION) - .document(UUID.randomUUID().toString()) - .set( - FinishNotificationResponse( - uid = uid, - historyId = runningHistory.historyId - ) + groupIdList.forEach { groupId -> + db.collection(GROUP_NOTIFICATIONS_COLLECTION) + .document(groupId) + .collection(FINISH_NOTIFICATION) + .document(UUID.randomUUID().toString()) + .set( + FinishNotificationResponse( + uid = uid, + historyId = runningHistory.historyId ) - } + ) } } }