File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,27 @@ class QuickChatViewModel @Inject constructor(private val quickChatActionReposito
3333 val quickChatActions
3434 get() = quickChatActionRepository.getAllActions().stateInWhileSubscribed(initialValue = emptyList())
3535
36+ init {
37+ // Initialize default location action if database is empty
38+ viewModelScope.launch(Dispatchers .IO ) {
39+ val actions = quickChatActionRepository.getAllActions()
40+ var isEmpty = true
41+ actions.collect { list ->
42+ if (isEmpty && list.isEmpty()) {
43+ quickChatActionRepository.upsert(
44+ QuickChatAction (
45+ name = " π" ,
46+ message = " https://maps.google.com/?q=%GPS" ,
47+ mode = QuickChatAction .Mode .Append ,
48+ position = 0 ,
49+ )
50+ )
51+ }
52+ isEmpty = false
53+ }
54+ }
55+ }
56+
3657 fun updateActionPositions (actions : List <QuickChatAction >) {
3758 viewModelScope.launch(Dispatchers .IO ) {
3859 for (position in actions.indices) {
You canβt perform that action at this time.
0 commit comments