Skip to content

Commit 422ef3e

Browse files
Adressed some coderabbit comments
1 parent b95621c commit 422ef3e

4 files changed

Lines changed: 11 additions & 16 deletions

File tree

app/src/main/java/com/cornellappdev/uplift/data/repositories/DatastoreRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ object PreferencesKeys {
2626
val NETID = stringPreferencesKey("netId")
2727
val EMAIL = stringPreferencesKey("email")
2828
val GOAL = intPreferencesKey("workoutGoal")
29-
val SKIP = booleanPreferencesKey("skip")
29+
val GOAL_SETTING_SKIPPED = booleanPreferencesKey("goalSkip")
3030
val FCM_TOKEN = stringPreferencesKey("fcmToken")
3131
val DECLINED_NOTIFICATION_PERMISSION =
3232
booleanPreferencesKey("declinedNotificationPermission")

app/src/main/java/com/cornellappdev/uplift/data/repositories/UserInfoRepository.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.cornellappdev.uplift.SetWorkoutGoalsMutation
1414
import kotlinx.coroutines.flow.map;
1515
import kotlinx.coroutines.flow.firstOrNull
1616
import com.cornellappdev.uplift.data.models.UserInfo
17+
import com.google.common.collect.Iterables.skip
1718
import com.google.firebase.auth.FirebaseAuth
1819
import com.google.firebase.auth.FirebaseUser
1920
import com.google.firebase.auth.GoogleAuthProvider
@@ -69,7 +70,7 @@ class UserInfoRepository @Inject constructor(
6970
username = userFields.name,
7071
netId = userFields.netId,
7172
email = userFields.email ?: email,
72-
skip = skip,
73+
goalSkip = skip,
7374
goal = goal
7475
)
7576
Log.d("UserInfoRepositoryImpl", "User created successfully")
@@ -101,14 +102,14 @@ class UserInfoRepository @Inject constructor(
101102
}
102103

103104

104-
suspend fun storeUserFields(id: String, username: String, netId: String, email: String, skip: Boolean, goal: Int) {
105+
suspend fun storeUserFields(id: String, username: String, netId: String, email: String, goalSkip: Boolean, goal: Int) {
105106
dataStore.edit { preferences ->
106107
preferences[PreferencesKeys.ID] = id
107108
preferences[PreferencesKeys.NETID] = netId
108109
preferences[PreferencesKeys.USERNAME] = username
109110
preferences[PreferencesKeys.EMAIL] = email
110-
preferences[PreferencesKeys.SKIP] = skip
111-
if (!skip) {
111+
preferences[PreferencesKeys.GOAL_SETTING_SKIPPED] = goalSkip
112+
if (!goalSkip) {
112113
preferences[PreferencesKeys.GOAL] = goal
113114
}
114115
}
@@ -151,7 +152,7 @@ class UserInfoRepository @Inject constructor(
151152
username = user.name,
152153
netId = user.netId,
153154
email = user.email,
154-
skip = false,
155+
goalSkip = user.workoutGoal == null,
155156
goal = user.workoutGoal ?: 0
156157
)
157158

@@ -212,14 +213,14 @@ class UserInfoRepository @Inject constructor(
212213

213214
suspend fun storeSkip(skip: Boolean) {
214215
dataStore.edit { preferences ->
215-
preferences[PreferencesKeys.SKIP] = skip
216+
preferences[PreferencesKeys.GOAL_SETTING_SKIPPED] = skip
216217
}
217218
}
218219

219220

220221
suspend fun getSkipFromDataStore(): Boolean {
221222
return dataStore.data.map { preferences ->
222-
preferences[PreferencesKeys.SKIP]
223+
preferences[PreferencesKeys.GOAL_SETTING_SKIPPED]
223224
}.firstOrNull() ?: false
224225
}
225226

app/src/main/java/com/cornellappdev/uplift/ui/screens/profile/ProfileScreen.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ private fun ProfileScreenContent(
8888
workoutGoal = uiState.workoutGoal,
8989
daysOfMonth = uiState.daysOfMonth,
9090
completedDays = uiState.completedDays,
91-
reminderItems= emptyList(), //implement
9291
historyItems = uiState.historyItems,
9392
navigateToGoalsSection = toGoals,
94-
navigateToRemindersSection = { /* TODO: Replace {} with viewmodel nav call */ },
9593
navigateToHistorySection = toHistory
9694
)
9795

@@ -105,10 +103,8 @@ private fun WorkoutsSectionContent(
105103
workoutGoal: Int,
106104
daysOfMonth: List<Int>,
107105
completedDays: List<Boolean>,
108-
reminderItems: List<ReminderItem>,
109106
historyItems: List<HistoryItem>,
110107
navigateToGoalsSection: () -> Unit,
111-
navigateToRemindersSection: () -> Unit,
112108
navigateToHistorySection: () -> Unit
113109
) {
114110
Column(

app/src/main/java/com/cornellappdev/uplift/util/Functions.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,9 @@ fun Calendar.timeAgoString(): String {
210210
diffWeeks in 2L..4L -> "$diffWeeks weeks ago"
211211

212212
diffMonths == 1L -> "1 month ago"
213-
diffMonths in 2L..11L -> "$diffMonths months ago"
213+
diffMonths in 2L..12L -> "$diffMonths months ago"
214214

215215
diffYears == 1L -> "1 year ago"
216-
diffYears > 1L -> "$diffYears years ago"
217-
218-
else -> "Today"
216+
else -> "$diffYears years ago"
219217
}
220218
}

0 commit comments

Comments
 (0)