Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
xenonnn4w committed Aug 30, 2024
1 parent dcdff92 commit a3a4b04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class CardAnalysisWidget : AnalyticsWidgetProvider() {
val deckData = getDeckNameAndStats(deckId.toList())

if (deckData.isEmpty()) {
// If the deck was deleted, clear the stored deck ID
val widgetPreferences = CardAnalysisWidgetPreferences(context)
val selectedDeck = longArrayOf().map { it.toString() }
widgetPreferences.saveSelectedDeck(appWidgetId, selectedDeck)

// Show empty_widget and set click listener to open configuration
remoteViews.setViewVisibility(R.id.empty_widget, View.VISIBLE)
remoteViews.setViewVisibility(R.id.cardAnalysisDataHolder, View.GONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ class CardAnalysisWidgetConfig : AnkiActivity(), DeckSelectionListener, BaseSnac
}

initializeUIComponents()
showDeckSelectionDialog()
// Show the Deck selection dialog only when there are no decks selected while opening the configuration screen.
val selectedDeckIds = cardAnalysisWidgetPreferences.getSelectedDeckIdFromPreferences(appWidgetId)
if (selectedDeckIds.isEmpty()) {
showDeckSelectionDialog()
}
}
}

Expand Down

0 comments on commit a3a4b04

Please sign in to comment.