Skip to content

Commit 04d3900

Browse files
committed
Format code
1 parent 5bbd4a2 commit 04d3900

File tree

24 files changed

+93
-132
lines changed

24 files changed

+93
-132
lines changed

composeApp/src/androidMain/kotlin/com/hypergonial/chat/MainActivity.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ class MainActivity : ComponentActivity() {
4242
showPushNotification = false,
4343
)
4444
)
45-
NotifierManager.setLogger {
46-
Logger.withTag("NotifierManager").i(it)
47-
}
45+
NotifierManager.setLogger { Logger.withTag("NotifierManager").i(it) }
4846

4947
val permissionUtil by permissionUtil()
5048
permissionUtil.askNotificationPermission()

composeApp/src/androidMain/kotlin/com/hypergonial/chat/MessagingService.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ class MessagingService : FirebaseMessagingService() {
3333
showPushNotification = false,
3434
)
3535
)
36-
NotifierManager.setLogger {
37-
Logger.withTag("NotifierManager").i(it)
38-
}
36+
NotifierManager.setLogger { Logger.withTag("NotifierManager").i(it) }
3937

4038
if (message.data["type"] == "notification") {
4139
notificationProvider.sendNotification {

composeApp/src/commonMain/kotlin/com/hypergonial/chat/model/Client.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,13 @@ interface Client : InstanceKeeper.Instance, EventManagerAware, CacheAware {
133133
*/
134134
suspend fun updateSelf(scope: (UserUpdateRequest.Builder.() -> Unit)): User
135135

136-
/** Update the Firebase Cloud Messaging token for the currently authenticated user
136+
/**
137+
* Update the Firebase Cloud Messaging token for the currently authenticated user
137138
*
138139
* @param fcmToken The new FCM token
139-
* @param previousToken The previous FCM token, if any
140-
* This will be used to remove the previous token from the user's account
141-
* */
140+
* @param previousToken The previous FCM token, if any This will be used to remove the previous token from the
141+
* user's account
142+
*/
142143
suspend fun updateFcmToken(fcmToken: String, previousToken: String? = null)
143144

144145
/**

composeApp/src/commonMain/kotlin/com/hypergonial/chat/model/FCMSettings.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ package com.hypergonial.chat.model
33
import kotlinx.datetime.Instant
44
import kotlinx.serialization.Serializable
55

6-
@Serializable
7-
data class FCMSettings(
8-
val token: String,
9-
val lastUpdated: Instant,
10-
)
6+
@Serializable data class FCMSettings(val token: String, val lastUpdated: Instant)

composeApp/src/commonMain/kotlin/com/hypergonial/chat/model/payloads/fcm/PushNotificationData.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@ import com.hypergonial.chat.model.payloads.Snowflake
44
import com.hypergonial.chat.model.payloads.toSnowflake
55
import com.mmk.kmpnotifier.notification.PayloadData
66

7-
data class PushNotificationData(
8-
val channelId: Snowflake,
9-
val guildId: Snowflake,
10-
) {
7+
data class PushNotificationData(val channelId: Snowflake, val guildId: Snowflake) {
118
companion object {
129
fun fromPayload(payload: PayloadData): PushNotificationData {
13-
require(payload["type"]?.toString() == "notification") {
14-
"Invalid notification type"
15-
}
10+
require(payload["type"]?.toString() == "notification") { "Invalid notification type" }
1611

1712
return PushNotificationData(
1813
channelId = (payload["channel_id"] as String).toSnowflake(),

composeApp/src/commonMain/kotlin/com/hypergonial/chat/view/EditorFocusInhibitor.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import kotlinx.coroutines.CompletableDeferred
99
* This interface is responsible for registering and releasing the inhibition of editor auto-focus behaviour via global
1010
* key events.
1111
*
12-
* If the user presses a key and no other component is currently using the editor, the main editor will automatically gain
13-
* focus.
12+
* If the user presses a key and no other component is currently using the editor, the main editor will automatically
13+
* gain focus.
1414
*
1515
* This interface allows components to inhibit this behaviour by acquiring and releasing focus for a given key.
1616
*
@@ -44,15 +44,17 @@ object NoOpEditorFocusInhibitor : EditorFocusInhibitor {
4444

4545
sealed class InhibitorMessage {
4646
data class Acquire(val key: String) : InhibitorMessage()
47+
4748
data class Release(val key: String) : InhibitorMessage()
49+
4850
data class Query(val response: CompletableDeferred<Boolean>) : InhibitorMessage()
4951
}
5052

5153
class EditorFocusInhibitorActor : Actor<InhibitorMessage>() {
5254
private val focusStates = hashSetOf<String>()
5355

5456
override fun onMessage(message: InhibitorMessage) {
55-
when(message) {
57+
when (message) {
5658
is InhibitorMessage.Acquire -> acquire(message.key)
5759
is InhibitorMessage.Release -> release(message.key)
5860
is InhibitorMessage.Query -> message.response.complete(isFree())

composeApp/src/commonMain/kotlin/com/hypergonial/chat/view/Notifications.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import kotlin.random.Random
99

1010
interface NotificationProvider {
1111
fun sendNotification(builder: NotificationBuilder.() -> Unit)
12+
1213
fun dismissNotification(channelId: Snowflake, id: Int)
14+
1315
fun dismissAllForChannel(channelId: Snowflake) {
1416
val ids = settings.getNotificationsIn(channelId)
15-
ids?.forEach { id ->
16-
dismissNotification(channelId, id)
17-
}
17+
ids?.forEach { id -> dismissNotification(channelId, id) }
1818
}
1919
}
2020

@@ -29,9 +29,7 @@ class NotificationBuilder {
2929
var image: NotificationImage? = null
3030

3131
companion object {
32-
fun toKMPNotify(
33-
builder: NotificationBuilder
34-
): NotifierBuilder.() -> Unit {
32+
fun toKMPNotify(builder: NotificationBuilder): NotifierBuilder.() -> Unit {
3533
return {
3634
this.id = builder.id
3735
this.title = builder.title

composeApp/src/commonMain/kotlin/com/hypergonial/chat/view/components/ChannelComponent.kt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import com.hypergonial.chat.appendMessages
1818
import com.hypergonial.chat.containAsEffect
1919
import com.hypergonial.chat.genNonce
2020
import com.hypergonial.chat.model.Client
21-
import com.hypergonial.chat.model.DelicateCacheApi
2221
import com.hypergonial.chat.model.ClientResumedEvent
22+
import com.hypergonial.chat.model.DelicateCacheApi
2323
import com.hypergonial.chat.model.LifecycleResumedEvent
2424
import com.hypergonial.chat.model.MessageCreateEvent
2525
import com.hypergonial.chat.model.MessageRemoveEvent
@@ -747,27 +747,29 @@ class DefaultChannelComponent(
747747
val index = data.value.messageEntries.indexOf(entry)
748748

749749
// Try the top first, then bottom, or create new entry if needed
750-
val nextEntry = data.value.messageEntries.getOrNull(index + 1)
751-
?: data.value.messageEntries.getOrNull(index - 1)
752-
?: run {
753-
messageEntryComponent(mutableStateListOf()).also { newEntry ->
754-
data.value.messageEntries.add(index, newEntry)
750+
val nextEntry =
751+
data.value.messageEntries.getOrNull(index + 1)
752+
?: data.value.messageEntries.getOrNull(index - 1)
753+
?: run {
754+
messageEntryComponent(mutableStateListOf()).also { newEntry ->
755+
data.value.messageEntries.add(index, newEntry)
756+
}
755757
}
756-
}
757758

758759
nextEntry.setTopEndIndicator(entry.data.value.topEndIndicator)
759760
}
760761
if (entry.data.value.bottomEndIndicator != null) {
761762
val index = data.value.messageEntries.indexOf(entry)
762763

763764
// Try the bottom first, then top, or create new entry if needed
764-
val nextEntry = data.value.messageEntries.getOrNull(index - 1)
765-
?: data.value.messageEntries.getOrNull(index + 1)
766-
?: run {
767-
messageEntryComponent(mutableStateListOf()).also { newEntry ->
768-
data.value.messageEntries.add(index, newEntry)
765+
val nextEntry =
766+
data.value.messageEntries.getOrNull(index - 1)
767+
?: data.value.messageEntries.getOrNull(index + 1)
768+
?: run {
769+
messageEntryComponent(mutableStateListOf()).also { newEntry ->
770+
data.value.messageEntries.add(index, newEntry)
771+
}
769772
}
770-
}
771773

772774
nextEntry.setBottomEndIndicator(entry.data.value.bottomEndIndicator)
773775
}

composeApp/src/commonMain/kotlin/com/hypergonial/chat/view/components/GuildSettingsComponent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import com.arkivanov.essenty.lifecycle.coroutines.coroutineScope
99
import com.hypergonial.chat.EffectContainer
1010
import com.hypergonial.chat.containAsEffect
1111
import com.hypergonial.chat.model.Client
12+
import com.hypergonial.chat.model.ClientPausedEvent
1213
import com.hypergonial.chat.model.GuildRemoveEvent
1314
import com.hypergonial.chat.model.GuildUpdateEvent
14-
import com.hypergonial.chat.model.ClientPausedEvent
1515
import com.hypergonial.chat.model.exceptions.ClientException
1616
import com.hypergonial.chat.model.payloads.Snowflake
1717
import com.hypergonial.chat.view.content.GuildSettingsContent

composeApp/src/commonMain/kotlin/com/hypergonial/chat/view/components/MainComponent.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ class DefaultMainComponent(
253253
is SlotConfig.Channel -> {
254254
val selectedChannel = data.value.selectedChannel
255255
if (selectedChannel == null) {
256-
logger.w { "Main slot activated with channel config, but no channel is selected. (This is a bug)" }
256+
logger.w {
257+
"Main slot activated with channel config, but no channel is selected. (This is a bug)"
258+
}
257259
DefaultFallbackMainComponent(childCtx, ::onChannelCreateClicked)
258260
} else {
259261
DefaultChannelComponent(

0 commit comments

Comments
 (0)