From 22446263f137b3e1333cef000b9bacdd7d17df1f Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Fri, 30 Aug 2019 15:14:00 +0200 Subject: [PATCH] Rename ExceptionsStore/State/Action to ExceptionsFragmentStore/State/Action. --- .../fenix/exceptions/ExceptionsFragment.kt | 8 ++++---- ...ptionsStore.kt => ExceptionsFragmentStore.kt} | 16 ++++++++-------- .../mozilla/fenix/exceptions/ExceptionsView.kt | 2 +- ...oreTest.kt => ExceptionsFragmentStoreTest.kt} | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) rename app/src/main/java/org/mozilla/fenix/exceptions/{ExceptionsStore.kt => ExceptionsFragmentStore.kt} (58%) rename app/src/test/java/org/mozilla/fenix/exceptions/{ExceptionsStoreTest.kt => ExceptionsFragmentStoreTest.kt} (72%) diff --git a/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragment.kt b/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragment.kt index d530e75f3..7d06e3a5f 100644 --- a/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragment.kt @@ -26,7 +26,7 @@ import org.mozilla.fenix.components.StoreProvider import org.mozilla.fenix.settings.SupportUtils class ExceptionsFragment : Fragment() { - private lateinit var exceptionsStore: ExceptionsStore + private lateinit var exceptionsStore: ExceptionsFragmentStore private lateinit var exceptionsView: ExceptionsView private lateinit var exceptionsInteractor: ExceptionsInteractor @@ -43,8 +43,8 @@ class ExceptionsFragment : Fragment() { ): View? { val view = inflater.inflate(R.layout.fragment_exceptions, container, false) exceptionsStore = StoreProvider.get(this) { - ExceptionsStore( - ExceptionsState( + ExceptionsFragmentStore( + ExceptionsFragmentState( items = loadAndMapExceptions() ) ) @@ -102,7 +102,7 @@ class ExceptionsFragment : Fragment() { coroutineScope { launch(Main) { - exceptionsStore.dispatch(ExceptionsAction.Change(items)) + exceptionsStore.dispatch(ExceptionsFragmentAction.Change(items)) } } } diff --git a/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsStore.kt b/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragmentStore.kt similarity index 58% rename from app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsStore.kt rename to app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragmentStore.kt index b77137e25..6d4ae4960 100644 --- a/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsStore.kt +++ b/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragmentStore.kt @@ -15,29 +15,29 @@ import mozilla.components.lib.state.Store data class ExceptionsItem(val url: String) /** - * The [Store] for holding the [ExceptionsState] and applying [ExceptionsAction]s. + * The [Store] for holding the [ExceptionsFragmentState] and applying [ExceptionsFragmentAction]s. */ -class ExceptionsStore(initialState: ExceptionsState) : - Store(initialState, ::exceptionsStateReducer) +class ExceptionsFragmentStore(initialState: ExceptionsFragmentState) : + Store(initialState, ::exceptionsStateReducer) /** * Actions to dispatch through the `ExceptionsStore` to modify `ExceptionsState` through the reducer. */ -sealed class ExceptionsAction : Action { - data class Change(val list: List) : ExceptionsAction() +sealed class ExceptionsFragmentAction : Action { + data class Change(val list: List) : ExceptionsFragmentAction() } /** * The state for the Exceptions Screen * @property items List of exceptions to display */ -data class ExceptionsState(val items: List) : State +data class ExceptionsFragmentState(val items: List) : State /** * The ExceptionsState Reducer. */ -fun exceptionsStateReducer(state: ExceptionsState, action: ExceptionsAction): ExceptionsState { +fun exceptionsStateReducer(state: ExceptionsFragmentState, action: ExceptionsFragmentAction): ExceptionsFragmentState { return when (action) { - is ExceptionsAction.Change -> state.copy(items = action.list) + is ExceptionsFragmentAction.Change -> state.copy(items = action.list) } } diff --git a/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsView.kt b/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsView.kt index 80bcd3237..a01cc910e 100644 --- a/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsView.kt +++ b/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsView.kt @@ -79,7 +79,7 @@ class ExceptionsView( view.exceptions_empty_view.text = textWithLink } - fun update(state: ExceptionsState) { + fun update(state: ExceptionsFragmentState) { view.exceptions_empty_view.visibility = if (state.items.isEmpty()) View.VISIBLE else View.GONE view.exceptions_list.visibility = if (state.items.isEmpty()) View.GONE else View.VISIBLE diff --git a/app/src/test/java/org/mozilla/fenix/exceptions/ExceptionsStoreTest.kt b/app/src/test/java/org/mozilla/fenix/exceptions/ExceptionsFragmentStoreTest.kt similarity index 72% rename from app/src/test/java/org/mozilla/fenix/exceptions/ExceptionsStoreTest.kt rename to app/src/test/java/org/mozilla/fenix/exceptions/ExceptionsFragmentStoreTest.kt index 058f38cea..85e012b32 100644 --- a/app/src/test/java/org/mozilla/fenix/exceptions/ExceptionsStoreTest.kt +++ b/app/src/test/java/org/mozilla/fenix/exceptions/ExceptionsFragmentStoreTest.kt @@ -9,14 +9,14 @@ import org.junit.Assert.assertEquals import org.junit.Assert.assertNotSame import org.junit.Test -class ExceptionsStoreTest { +class ExceptionsFragmentStoreTest { @Test fun onChange() = runBlocking { val initialState = emptyDefaultState() - val store = ExceptionsStore(initialState) + val store = ExceptionsFragmentStore(initialState) val newExceptionsItem = ExceptionsItem("URL") - store.dispatch(ExceptionsAction.Change(listOf(newExceptionsItem))).join() + store.dispatch(ExceptionsFragmentAction.Change(listOf(newExceptionsItem))).join() assertNotSame(initialState, store.state) assertEquals( store.state.items, @@ -24,7 +24,7 @@ class ExceptionsStoreTest { ) } - private fun emptyDefaultState(): ExceptionsState = ExceptionsState( + private fun emptyDefaultState(): ExceptionsFragmentState = ExceptionsFragmentState( items = listOf() ) }