Skip to content

Commit

Permalink
🔥 불필요한 withContext 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
soopeach committed Dec 10, 2022
1 parent 68a9e24 commit ed4648e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class RunningHistoryLocalDataSourceImpl @Inject constructor(
}

override suspend fun saveRunningHistory(runningHistoryEntity: RunningHistoryEntity): Result<RunningHistory> {
return kotlin.runCatching {
return runCatching {
runningHistoryDao.addRunningHistory(runningHistoryEntity)
runningHistoryEntity.toRunningHistory()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -98,19 +96,17 @@ class GroupNotificationDataSourceImpl @Inject constructor(
}

override suspend fun notifyRunningStart(uid: String, groupIdList: List<String>) {
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
)
}
)
}
}

Expand All @@ -119,19 +115,17 @@ class GroupNotificationDataSourceImpl @Inject constructor(
runningHistory: RunningHistory,
groupIdList: List<String>
) {
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
)
}
)
}
}
}

0 comments on commit ed4648e

Please sign in to comment.