Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
circles-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Circles
circles-android
Commits
4649f14f
Commit
4649f14f
authored
1 year ago
by
Taras
Browse files
Options
Downloads
Patches
Plain Diff
Setup initial post data in preview
parent
3e5b3098
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/org/futo/circles/feature/timeline/post/create/CreatePostViewModel.kt
+9
-10
9 additions, 10 deletions
...rcles/feature/timeline/post/create/CreatePostViewModel.kt
with
9 additions
and
10 deletions
app/src/main/java/org/futo/circles/feature/timeline/post/create/CreatePostViewModel.kt
+
9
−
10
View file @
4649f14f
...
@@ -5,20 +5,21 @@ import androidx.lifecycle.SavedStateHandle
...
@@ -5,20 +5,21 @@ import androidx.lifecycle.SavedStateHandle
import
androidx.lifecycle.ViewModel
import
androidx.lifecycle.ViewModel
import
dagger.hilt.android.lifecycle.HiltViewModel
import
dagger.hilt.android.lifecycle.HiltViewModel
import
org.futo.circles.core.extensions.getOrThrow
import
org.futo.circles.core.extensions.getOrThrow
import
org.futo.circles.core.provider.MatrixSessionProvider
import
org.futo.circles.core.model.PostContent
import
org.matrix.android.sdk.api.session.getRoom
import
org.futo.circles.core.timeline.post.PostContentDataSource
import
org.matrix.android.sdk.api.session.room.getTimelineEvent
import
org.matrix.android.sdk.api.session.room.timeline.getTextEditableContent
import
javax.inject.Inject
import
javax.inject.Inject
@HiltViewModel
@HiltViewModel
class
CreatePostViewModel
@Inject
constructor
(
savedStateHandle
:
SavedStateHandle
)
:
ViewModel
()
{
class
CreatePostViewModel
@Inject
constructor
(
savedStateHandle
:
SavedStateHandle
,
private
val
postContentDataSource
:
PostContentDataSource
)
:
ViewModel
()
{
private
val
roomId
:
String
=
savedStateHandle
.
getOrThrow
(
"roomId"
)
private
val
roomId
:
String
=
savedStateHandle
.
getOrThrow
(
"roomId"
)
private
val
eventId
:
String
?
=
savedStateHandle
[
"eventId"
]
private
val
eventId
:
String
?
=
savedStateHandle
[
"eventId"
]
private
val
isEdit
:
Boolean
=
savedStateHandle
.
getOrThrow
(
"isEdit"
)
private
val
isEdit
:
Boolean
=
savedStateHandle
.
getOrThrow
(
"isEdit"
)
val
tex
tToEditLiveData
=
MutableLiveData
<
String
>()
val
pos
tToEdit
Content
LiveData
=
MutableLiveData
<
PostContent
>()
init
{
init
{
if
(
isEdit
)
setEditPostInfo
()
if
(
isEdit
)
setEditPostInfo
()
...
@@ -26,9 +27,7 @@ class CreatePostViewModel @Inject constructor(savedStateHandle: SavedStateHandle
...
@@ -26,9 +27,7 @@ class CreatePostViewModel @Inject constructor(savedStateHandle: SavedStateHandle
private
fun
setEditPostInfo
()
{
private
fun
setEditPostInfo
()
{
eventId
?:
return
eventId
?:
return
val
session
=
MatrixSessionProvider
.
currentSession
val
content
=
postContentDataSource
.
getPostContent
(
roomId
,
eventId
)
?:
return
val
room
=
session
?.
getRoom
(
roomId
)
?:
return
postToEditContentLiveData
.
value
=
content
val
event
=
room
.
getTimelineEvent
(
eventId
)
?:
return
textToEditLiveData
.
postValue
(
event
.
getTextEditableContent
(
false
))
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment