Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't crash when toggling an account's "Show boosts" option #1149

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ class AccountViewModel @AssistedInject constructor(

fun changeShowReblogsState() {
if (relationshipData.value?.data?.showingReblogs == true) {
changeRelationship(RelationShipAction.FOLLOW, false)
changeRelationship(RelationShipAction.HIDE_REBLOGS)
} else {
changeRelationship(RelationShipAction.FOLLOW, true)
changeRelationship(RelationShipAction.SHOW_REBLOGS)
}
}

Expand Down Expand Up @@ -230,14 +230,17 @@ class AccountViewModel @AssistedInject constructor(
relation.copy(subscribing = false)
}
}

RelationShipAction.SHOW_REBLOGS -> relation.copy(showingReblogs = true)
RelationShipAction.HIDE_REBLOGS -> relation.copy(showingReblogs = false)
}
relationshipData.postValue(Loading(newRelation))
}

val relationshipCall = when (relationshipAction) {
RelationShipAction.FOLLOW -> mastodonApi.followAccount(
accountId,
showReblogs = parameter ?: true,
showReblogs = true,
)
RelationShipAction.UNFOLLOW -> mastodonApi.unfollowAccount(accountId)
RelationShipAction.BLOCK -> mastodonApi.blockAccount(accountId)
Expand All @@ -262,6 +265,8 @@ class AccountViewModel @AssistedInject constructor(
mastodonApi.unsubscribeAccount(accountId)
}
}
RelationShipAction.SHOW_REBLOGS -> mastodonApi.followAccount(accountId, showReblogs = true)
RelationShipAction.HIDE_REBLOGS -> mastodonApi.followAccount(accountId, showReblogs = false)
}

relationshipCall
Expand Down Expand Up @@ -333,6 +338,8 @@ class AccountViewModel @AssistedInject constructor(
UNMUTE,
SUBSCRIBE,
UNSUBSCRIBE,
SHOW_REBLOGS,
HIDE_REBLOGS,
}

@AssistedFactory
Expand Down