add a button to return to default relay list

This commit is contained in:
greenart7c3 2023-07-24 13:55:55 -03:00
parent 2b6abcbfb9
commit 1e25688f9d
3 changed files with 17 additions and 0 deletions

View File

@ -58,6 +58,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.RelayInformation
import com.vitorpamplona.amethyst.model.RelaySetupInfo
import com.vitorpamplona.amethyst.service.relays.Constants.defaultRelays
import com.vitorpamplona.amethyst.service.relays.FeedType
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
@ -105,6 +106,15 @@ fun NewRelayListView(onClose: () -> Unit, accountViewModel: AccountViewModel, re
onClose()
})
Button(
onClick = {
postViewModel.deleteAll()
defaultRelays.forEach { postViewModel.addRelay(it) }
}
) {
Text(stringResource(R.string.default_relays))
}
PostButton(
onPost = {
postViewModel.create()

View File

@ -90,6 +90,12 @@ class NewRelayListViewModel : ViewModel() {
}
}
fun deleteAll() {
_relays.update { relays ->
relays.dropWhile { relays.isNotEmpty() }
}
}
fun toggleDownload(relay: RelaySetupInfo) {
_relays.update {
it.updated(relay, relay.copy(read = !relay.read))

View File

@ -507,4 +507,5 @@
<string name="nip05_failed">Nostr address failed verification</string>
<string name="nip05_checking">Checking Nostr address</string>
<string name="select_deselect_all">Select/Deselect all</string>
<string name="default_relays">Default</string>
</resources>