Skip to content

Commit

Permalink
feat(feed): add info about repo collaborator actions
Browse files Browse the repository at this point in the history
Signed-off-by: SphericalKat <[email protected]>
  • Loading branch information
SphericalKat committed Aug 1, 2021
1 parent 1dd5cdb commit ffbbdd8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/at/sphericalk/gidget/data/db/AppDb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import at.sphericalk.gidget.model.Event

@Database(entities = [Event::class], version = 1, exportSchema = true)
@Database(entities = [Event::class], version = 2, exportSchema = true)
@TypeConverters(Converters::class)
abstract class AppDb : RoomDatabase() {
abstract fun eventDao(): EventDao
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/at/sphericalk/gidget/data/db/Converters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Converters {
Action.Unassigned -> 7
Action.Labeled -> 8
Action.Unlabeled -> 9
Action.Added -> 10
else -> null
}

Expand All @@ -76,6 +77,7 @@ class Converters {
7 -> Action.Unassigned
8 -> Action.Labeled
9 -> Action.Unlabeled
10 -> Action.Added
null -> null
else -> throw IllegalStateException("unknown action type")
}
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/at/sphericalk/gidget/model/Events.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ data class Payload(
val distinct_size: Long? = null,
val head: String? = null,
val before: String? = null,
@Embedded val member: Member?
)

@Keep
data class Member(
@ColumnInfo(name = "payload_member_name") val login: String
)

@Keep
Expand All @@ -62,7 +68,8 @@ enum class Action {
Assigned,
Unassigned,
Labeled,
Unlabeled;
Unlabeled,
Added;

override fun toString() = when (this) {
Published -> "published"
Expand All @@ -74,6 +81,7 @@ enum class Action {
Unassigned -> "unassigned"
Labeled -> "labeled"
Unlabeled -> "unlabeled"
Added -> "added"
}
}

Expand Down Expand Up @@ -151,7 +159,7 @@ enum class EventType {
GollumEvent -> "created a wiki page for"
IssueCommentEvent -> "commented on an issue in"
IssuesEvent -> ""
MemberEvent -> "became a member of"
MemberEvent -> "added"
PullRequestEvent -> "created a pull request in"
PullRequestReviewEvent -> "reviewed a pull request in"
PullRequestReviewCommentEvent -> "commented on a pull request review in"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.util.Log
import at.sphericalk.gidget.data.db.EventDao
import at.sphericalk.gidget.data.network.GithubDataSource
import at.sphericalk.gidget.model.Event
import at.sphericalk.gidget.model.EventType
import at.sphericalk.gidget.model.RepoExtra
import at.sphericalk.gidget.utils.destructure
import kotlinx.coroutines.FlowPreview
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/at/sphericalk/gidget/ui/routes/Feed.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ fun Feed(navController: NavController, viewModel: FeedViewModel) {
EventType.IssuesEvent -> {
append("${event.payload?.action.toString()} an issue in")
}
EventType.MemberEvent -> {
append(" ")
withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)) {
append(event.payload?.member?.login.toString())
}
append(" to")
}
}
append(" ")
withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)) {
Expand Down

0 comments on commit ffbbdd8

Please sign in to comment.