Skip to content

Commit c7b5177

Browse files
committed
feat: Add default location pin QuickChat action on first run
Initialize database with default location pin (πŸ“) QuickChat action when no actions exist. Creates entry with: - Name: πŸ“ - Message: https://maps.google.com/?q=%GPS - Mode: Append - Position: 0 Users can edit, delete, or reorder this action via QuickChat settings.
1 parent 50aff22 commit c7b5177

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

β€Žfeature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/QuickChatViewModel.ktβ€Ž

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff 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) {

0 commit comments

Comments
Β (0)