Merge branch '6-develop-topic' into 'develop'
subscribe to a topic by default See merge request e/os/ntfy-android!4
This commit is contained in:
commit
8af874a499
1 changed files with 30 additions and 0 deletions
|
@ -207,6 +207,36 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
maybeRequestNotificationPermission()
|
maybeRequestNotificationPermission()
|
||||||
|
|
||||||
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
|
val subscriptions = repository.getSubscriptions()
|
||||||
|
val defaultTopic = "murena_notification"
|
||||||
|
val hasTestTopic = subscriptions.any { it.topic == defaultTopic }
|
||||||
|
if (hasTestTopic) {
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
|
||||||
|
val subscription = Subscription(
|
||||||
|
id = randomSubscriptionId(),
|
||||||
|
baseUrl = appBaseUrl!!,
|
||||||
|
topic = defaultTopic,
|
||||||
|
instant = true,
|
||||||
|
dedicatedChannels = false,
|
||||||
|
mutedUntil = 0,
|
||||||
|
minPriority = Repository.MIN_PRIORITY_USE_GLOBAL,
|
||||||
|
autoDelete = Repository.AUTO_DELETE_USE_GLOBAL,
|
||||||
|
insistent = Repository.INSISTENT_MAX_PRIORITY_USE_GLOBAL,
|
||||||
|
lastNotificationId = null,
|
||||||
|
icon = null,
|
||||||
|
upAppId = null,
|
||||||
|
upConnectorToken = null,
|
||||||
|
displayName = null,
|
||||||
|
totalCount = 0,
|
||||||
|
newCount = 0,
|
||||||
|
lastActive = Date().time / 1000
|
||||||
|
)
|
||||||
|
viewModel.add(subscription)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun maybeRequestNotificationPermission() {
|
private fun maybeRequestNotificationPermission() {
|
||||||
|
|
Loading…
Reference in a new issue