Skip to content

Commit 0c406b5

Browse files
committed
feat: integrate WorkRepository to schedule ad watch sync on failure
1 parent 450c983 commit 0c406b5

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

presentation/diaryfeedback/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ android {
2525

2626
dependencies {
2727
implementation(projects.core.ads)
28+
implementation(projects.core.work)
2829
implementation(projects.data.diary)
2930
}

presentation/diaryfeedback/src/main/java/com/hilingual/presentation/diaryfeedback/DiaryFeedbackViewModel.kt

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
/*
2-
* Copyright 2025 The Hilingual Project
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
161
package com.hilingual.presentation.diaryfeedback
172

183
import androidx.lifecycle.SavedStateHandle
@@ -23,6 +8,7 @@ import com.hilingual.core.common.extension.onLogFailure
238
import com.hilingual.core.common.extension.updateSuccess
249
import com.hilingual.core.common.util.UiState
2510
import com.hilingual.core.common.util.suspendRunCatching
11+
import com.hilingual.core.work.repository.WorkRepository
2612
import com.hilingual.data.diary.model.BookmarkResult
2713
import com.hilingual.data.diary.model.PhraseBookmarkModel
2814
import com.hilingual.data.diary.repository.DiaryRepository
@@ -45,6 +31,7 @@ import kotlinx.coroutines.launch
4531
internal class DiaryFeedbackViewModel @Inject constructor(
4632
savedStateHandle: SavedStateHandle,
4733
private val diaryRepository: DiaryRepository,
34+
private val workRepository: WorkRepository,
4835
) : ViewModel() {
4936
private val _uiState = MutableStateFlow<UiState<DiaryFeedbackUiState>>(UiState.Loading)
5037
val uiState: StateFlow<UiState<DiaryFeedbackUiState>> = _uiState.asStateFlow()
@@ -98,12 +85,7 @@ internal class DiaryFeedbackViewModel @Inject constructor(
9885
viewModelScope.launch {
9986
diaryRepository.patchAdWatch(diaryId)
10087
.onLogFailure {
101-
_uiState.updateSuccess { it.copy(isAdWatched = true) }
102-
/*
103-
* TODO:: 서버 동기화 실패 처리
104-
* patchAdWatch API 실패 시 서버는 여전히 isAdWatched = false 상태입니다.
105-
* WorkManager로 Sync 필요
106-
*/
88+
workRepository.scheduleAdWatchSync(diaryId)
10789
}
10890
}
10991
}

0 commit comments

Comments
 (0)