Skip to content

Commit

Permalink
Improve liking
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Feb 16, 2024
1 parent 5e429d7 commit 96ae430
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,5 +486,5 @@ interface ApiService {
suspend fun retrievePartySeekingUsers(@Query("page") page: Int): HabitResponse<List<Member>>

@POST("challenges/{challengeId}/flag")
suspend fun reportChallenge(@Query("challengeId") challengeid: String, @Body updateData: Map<String, String>): HabitResponse<Void>
suspend fun reportChallenge(@Path("challengeId") challengeid: String, @Body updateData: Map<String, String>): HabitResponse<Void>
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public static Gson createGson() {
.registerTypeAdapter(SocialAuthentication.class, new SocialAuthenticationDeserializer())
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
.serializeNulls()
.setLenient()
.create();
}
public static GsonConverterFactory create() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class SocialRepositoryImpl(
val message = apiClient.likeMessage(chatMessage.groupId ?: "", chatMessage.id)
message?.groupId = chatMessage.groupId
message?.let { localRepository.save(it) }
return null
return message
}

override suspend fun deleteMessage(chatMessage: ChatMessage): Void? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,23 +188,30 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
}

override fun likeMessage(chatMessage: ChatMessage, userId: String, liked: Boolean) {
if (chatMessage.userLikesMessage(userId) == liked) {
val liveMessage = getLiveObject(chatMessage)
if (liveMessage == null) {
executeTransaction {
realm.insertOrUpdate(chatMessage)
return@executeTransaction
}
return
}
if (liveMessage.userLikesMessage(userId) == liked) {
return
}
val liveMessage = getLiveObject(chatMessage)
if (liked) {
executeTransaction {
liveMessage?.likes?.add(ChatMessageLike(userId))
liveMessage?.likeCount = liveMessage?.likes?.size ?: 0
liveMessage.likes?.add(ChatMessageLike(userId))
liveMessage.likeCount = liveMessage.likes?.size ?: 0
}
} else {
liveMessage?.likes?.filter { userId == it.id && it.isManaged }?.forEach { like ->
liveMessage.likes?.filter { userId == it.id && it.isManaged }?.forEach { like ->
executeTransaction {
like.deleteFromRealm()
}
}
executeTransaction {
liveMessage?.likeCount = liveMessage?.likes?.size ?: 0
liveMessage.likeCount = liveMessage.likes?.size ?: 0
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ class ChallengeDetailFragment : BaseMainFragment<FragmentChallengeDetailBinding>
editMenuItem?.isVisible = isCreator
val endChallengeMenuItem = menu.findItem(R.id.action_end_challenge)
endChallengeMenuItem?.isVisible = isCreator
val reportMenuItem = menu.findItem(R.id.action_report)
reportMenuItem?.isVisible = challenge?.official == false
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
Expand Down Expand Up @@ -254,6 +256,7 @@ class ChallengeDetailFragment : BaseMainFragment<FragmentChallengeDetailBinding>

binding?.gemAmount?.text = challenge.prize.toString()
binding?.participantCount?.text = challenge.memberCount.toString()
this.mainActivity?.invalidateOptionsMenu()
}

private fun set(creator: Member?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class ExceptionHandler {
private var exceptionLogger: ((Throwable) -> Unit)? = null

companion object {

private var instance = ExceptionHandler()

fun init(exceptionLogger: ((Throwable) -> Unit)? = null) {
Expand All @@ -34,10 +33,7 @@ class ExceptionHandler {
} catch (ignored: Exception) {
}
} else {
if (throwable !is IOException &&
throwable !is HttpException &&
throwable !is CancellationException
) {
if (throwable !is CancellationException) {
instance.exceptionLogger?.invoke(throwable)
}
}
Expand Down
11 changes: 5 additions & 6 deletions fastlane/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
New in 4.3.4:

To Do reminders should show more reliably
Added password reset option to the Account Reset and Account Delete screens
Group Plan invites will show in the notification center
Added the ability to report a Challenge for community violations
Various other bug fixes and improvements
- To Do reminders should show more reliably
- Added password reset option to the Account Reset and Account Delete screens
- Group Plan invites will show in the notification center
- Added the ability to report a Challenge for community violations
- Various other bug fixes and improvements
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NAME=4.3.4
CODE=6901
CODE=6921

0 comments on commit 96ae430

Please sign in to comment.