-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CommentReplyView refactored on its own viewmodel. Added mark replied …
…message as read. Fixes #45
- Loading branch information
1 parent
3dc8bca
commit 26da8fd
Showing
10 changed files
with
194 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
app/src/main/java/com/jerboa/ui/components/comment/reply/CommentReplyViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.jerboa.ui.components.comment.reply | ||
|
||
import android.content.Context | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.ui.focus.FocusManager | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import androidx.navigation.NavController | ||
import com.jerboa.datatypes.CommentView | ||
import com.jerboa.datatypes.PostView | ||
import com.jerboa.db.Account | ||
import com.jerboa.ui.components.comment.createCommentRoutine | ||
import com.jerboa.ui.components.inbox.InboxViewModel | ||
import com.jerboa.ui.components.person.PersonProfileViewModel | ||
import com.jerboa.ui.components.post.PostViewModel | ||
|
||
class CommentReplyViewModel : ViewModel() { | ||
|
||
var commentParentView = mutableStateOf<CommentView?>(null) | ||
private set | ||
var postId = mutableStateOf<Int?>(null) | ||
private set | ||
var postView = mutableStateOf<PostView?>(null) | ||
private set | ||
var loading = mutableStateOf(false) | ||
private set | ||
|
||
fun setCommentParentView( | ||
newCommentParentView: CommentView? | ||
) { | ||
commentParentView.value = newCommentParentView | ||
} | ||
|
||
fun setPostView( | ||
newPostView: PostView? | ||
) { | ||
postView.value = newPostView | ||
} | ||
|
||
fun setPostId( | ||
newPostId: Int | ||
) { | ||
postId.value = newPostId | ||
} | ||
|
||
fun createComment( | ||
content: String, | ||
account: Account, | ||
ctx: Context, | ||
navController: NavController, | ||
focusManager: FocusManager, | ||
personProfileViewModel: PersonProfileViewModel, | ||
postViewModel: PostViewModel, | ||
inboxViewModel: InboxViewModel, | ||
) { | ||
postId.value?.also { postId -> | ||
createCommentRoutine( | ||
content = content, | ||
parentCommentView = commentParentView.value, | ||
postId = postId, | ||
account = account, | ||
loading = loading, | ||
ctx = ctx, | ||
scope = viewModelScope, | ||
navController = navController, | ||
focusManager = focusManager, | ||
personProfileViewModel = personProfileViewModel, | ||
postViewModel = postViewModel, | ||
inboxViewModel = inboxViewModel, | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.