mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 11:46:32 +00:00
Improve liking
This commit is contained in:
parent
5e429d7572
commit
96ae430eec
8 changed files with 26 additions and 20 deletions
|
|
@ -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>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ public class GSonFactoryCreator {
|
|||
.registerTypeAdapter(SocialAuthentication.class, new SocialAuthenticationDeserializer())
|
||||
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
|
||||
.serializeNulls()
|
||||
.setLenient()
|
||||
.create();
|
||||
}
|
||||
public static GsonConverterFactory create() {
|
||||
|
|
|
|||
|
|
@ -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? {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -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?) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ class ExceptionHandler {
|
|||
private var exceptionLogger: ((Throwable) -> Unit)? = null
|
||||
|
||||
companion object {
|
||||
|
||||
private var instance = ExceptionHandler()
|
||||
|
||||
fun init(exceptionLogger: ((Throwable) -> Unit)? = null) {
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.3.4
|
||||
CODE=6901
|
||||
CODE=6921
|
||||
Loading…
Reference in a new issue