Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Unable to delete autocomplete history items #5168

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ class BrowserTabViewModelTest {
whenever(mockAutoCompleteScorer.score("title", "https://foo.com".toUri(), 1, "title")).thenReturn(1)
whenever(mockUserStageStore.getUserAppStage()).thenReturn(ESTABLISHED)

testee.autoCompleteSuggestionsShown()
testee.onAutoCompleteSuggestionsChanged()
testee.autoCompleteStateFlow.value = "title"
delay(500)
testee.autoCompleteSuggestionsGone()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,7 @@ class BrowserTabFragment :
}

private fun autocompleteItemRemoved() {
viewModel.onAutoCompleteSuggestionsChanged()
showKeyboardAndRestorePosition(autocompleteFirstVisibleItemPosition, autocompleteItemOffsetTop)
}

Expand Down Expand Up @@ -3710,7 +3711,7 @@ class BrowserTabFragment :
binding.autoCompleteSuggestionsList.gone()
} else {
binding.autoCompleteSuggestionsList.show()
viewModel.autoCompleteSuggestionsShown()
viewModel.onAutoCompleteSuggestionsChanged()
autoCompleteSuggestionsAdapter.updateData(viewState.searchResults.query, viewState.searchResults.suggestions)
hideFocusedView()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3696,7 +3696,7 @@ class BrowserTabViewModel @Inject constructor(
}
}

fun autoCompleteSuggestionsShown() {
fun onAutoCompleteSuggestionsChanged() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this.

configureAutoComplete()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ class SystemSearchActivity : DuckDuckGoActivity() {
}
}

fun onAutoCompleteSuggestionsChanged() {
configureAutoComplete()
}

private fun sendLaunchPixels(intent: Intent) {
when {
launchedFromAssist(intent) -> pixel.fire(AppPixelName.APP_ASSIST_LAUNCH)
Expand Down Expand Up @@ -487,6 +491,7 @@ class SystemSearchActivity : DuckDuckGoActivity() {
}

private fun autocompleteItemRemoved() {
viewModel.onAutoCompleteSuggestionsChanged()
showKeyboardAndRestorePosition()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ class SystemSearchViewModel @Inject constructor(
}
}

fun onAutoCompleteSuggestionsChanged() {
configureResults()
}

private fun showRemoveSearchSuggestionDialog(suggestion: AutoCompleteSuggestion) {
appCoroutineScope.launch(dispatchers.main()) {
command.value = Command.ShowRemoveSearchSuggestionDialog(suggestion)
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/com/duckduckgo/app/tabs/db/TabsDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import com.duckduckgo.app.tabs.model.TabSelectionEntity
import com.duckduckgo.common.utils.swap
import com.duckduckgo.di.scopes.AppScope
import dagger.SingleInstanceIn
import io.reactivex.Single
import kotlinx.coroutines.flow.Flow

@Dao
Expand All @@ -45,10 +44,6 @@ abstract class TabsDao {
@Query("select * from tabs where deletable is 0 order by position")
abstract fun flowTabs(): Flow<List<TabEntity>>

// TODO: ANA to remove this
@Query("select * from tabs where deletable is 0 order by position")
abstract fun singleTabs(): Single<List<TabEntity>>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed also some unused code.


@Query("select * from tabs where deletable is 0 order by position")
abstract fun liveTabs(): LiveData<List<TabEntity>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.di.scopes.AppScope
import dagger.SingleInstanceIn
import io.reactivex.Scheduler
import io.reactivex.Single
import io.reactivex.schedulers.Schedulers
import java.util.UUID
import javax.inject.Inject
Expand Down Expand Up @@ -82,8 +81,6 @@ class TabDataRepository @Inject constructor(

private var purgeDeletableTabsJob = ConflatedJob()

override fun getTabsObservable(): Single<List<TabEntity>> = tabsDao.singleTabs()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, removed unused code.


override suspend fun add(
url: String?,
skipHome: Boolean,
Expand Down
4 changes: 0 additions & 4 deletions browser-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ dependencies {

// LiveData
implementation AndroidX.lifecycle.liveDataKtx

// TODO: ANA to remove this
implementation "io.reactivex.rxjava2:rxjava:_"
implementation "io.reactivex.rxjava2:rxandroid:_"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unneeded dependencies.

}
android {
namespace 'com.duckduckgo.browser.api'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.duckduckgo.app.global.model.Site
import com.duckduckgo.app.tabs.model.TabSwitcherData.LayoutType
import io.reactivex.Single
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharedFlow

Expand All @@ -44,8 +43,6 @@ interface TabRepository {

val tabSwitcherData: Flow<TabSwitcherData>

fun getTabsObservable(): Single<List<TabEntity>>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused.


/**
* @return tabId of new record
*/
Expand Down
Loading