Skip to content

Commit

Permalink
Import newest lexicons.
Browse files Browse the repository at this point in the history
  • Loading branch information
christiandeange committed Aug 6, 2024
1 parent 6530742 commit df457f4
Show file tree
Hide file tree
Showing 50 changed files with 2,273 additions and 268 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package sh.christian.ozone.model

import app.bsky.notification.ListNotificationsNotification
import app.bsky.notification.ListNotificationsReason.FOLLOW
import app.bsky.notification.ListNotificationsReason.LIKE
import app.bsky.notification.ListNotificationsReason.MENTION
import app.bsky.notification.ListNotificationsReason.QUOTE
import app.bsky.notification.ListNotificationsReason.REPLY
import app.bsky.notification.ListNotificationsReason.REPOST
import app.bsky.notification.ListNotificationsReason.UNKNOWN
import app.bsky.notification.ListNotificationsReason
import app.bsky.notification.ListNotificationsReason.*
import kotlinx.serialization.Serializable
import sh.christian.ozone.api.AtUri
import sh.christian.ozone.api.Cid
import sh.christian.ozone.api.model.ReadOnlyList
import sh.christian.ozone.model.Notification.Content.Followed
import sh.christian.ozone.model.Notification.Content.JoinedStarterPack
import sh.christian.ozone.model.Notification.Content.Liked
import sh.christian.ozone.model.Notification.Content.Mentioned
import sh.christian.ozone.model.Notification.Content.Quoted
Expand Down Expand Up @@ -59,6 +55,8 @@ data class Notification(
data class Quoted(
val post: TimelinePost,
) : Content

data object JoinedStarterPack : Content
}

enum class Reason {
Expand All @@ -69,6 +67,7 @@ data class Notification(
MENTION,
REPLY,
QUOTE,
JOINED_STARTERPACK,
}
}

Expand All @@ -88,6 +87,7 @@ fun ListNotificationsNotification.toNotification(
MENTION -> Notification.Reason.MENTION to notificationPost?.let(::Mentioned)
REPLY -> Notification.Reason.REPLY to notificationPost?.let(::RepliedTo)
QUOTE -> Notification.Reason.QUOTE to notificationPost?.let(::Quoted)
STARTERPACK_JOINED -> Notification.Reason.JOINED_STARTERPACK to JoinedStarterPack
}

return Notification(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,11 @@ private fun RecordViewRecordUnion.toEmbedPost(): EmbedPost {
uri = value.uri,
)
}
is RecordViewRecordUnion.GraphStarterPackViewBasic -> {
// TODO support starter pack views.
InvisibleEmbedPost(
uri = value.uri,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class NotificationsRepository(
ListNotificationsReason.REPLY -> uri
ListNotificationsReason.QUOTE -> uri
ListNotificationsReason.FOLLOW -> null
ListNotificationsReason.STARTERPACK_JOINED -> null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import sh.christian.ozone.compose.PostReplyInfo
import sh.christian.ozone.model.Moment
import sh.christian.ozone.model.Notification
import sh.christian.ozone.notifications.type.FollowRow
import sh.christian.ozone.notifications.type.JoinedStarterPackRow
import sh.christian.ozone.notifications.type.LikeRow
import sh.christian.ozone.notifications.type.MentionRow
import sh.christian.ozone.notifications.type.QuoteRow
Expand Down Expand Up @@ -102,6 +103,7 @@ class NotificationsScreen(
is Notification.Content.Quoted -> QuoteRow(context, content)
is Notification.Content.RepliedTo -> ReplyRow(context, content)
is Notification.Content.Reposted -> RepostRow(context, notification, content)
is Notification.Content.JoinedStarterPack -> JoinedStarterPackRow(context, notification)
null -> Unit
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package sh.christian.ozone.notifications.type

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement.spacedBy
import androidx.compose.foundation.layout.Row
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Person
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.unit.dp
import sh.christian.ozone.model.Notification
import sh.christian.ozone.notifications.NotificationRowContext
import sh.christian.ozone.ui.compose.TimeDelta
import sh.christian.ozone.user.UserDid

@Composable
fun JoinedStarterPackRow(
context: NotificationRowContext,
notification: Notification,
) {
val profile = notification.author
NotificationRowScaffold(
modifier = Modifier.clickable { context.onOpenUser(UserDid(profile.did)) },
context = context,
profile = profile,
icon = {
Icon(
painter = rememberVectorPainter(Icons.Default.Person),
tint = MaterialTheme.colorScheme.primary,
contentDescription = "Starter Pack",
)
},
content = {
Row(horizontalArrangement = spacedBy(8.dp)) {
val profileText = profile.displayName ?: "@${profile.handle}"
Text(
modifier = Modifier.alignByBaseline(),
text = "$profileText joined from your starter pack",
)
TimeDelta(
modifier = Modifier.alignByBaseline(),
delta = context.now - notification.indexedAt,
)
}
},
)
}
Loading

0 comments on commit df457f4

Please sign in to comment.