Implemented persisting for which account prominent (top) fetch all transactions view shouldn't be displayed anymore

This commit is contained in:
dankito 2020-09-28 15:44:45 +02:00
parent 51044a257c
commit 1d09789d38
9 changed files with 40 additions and 14 deletions

View File

@ -66,6 +66,9 @@ open class BankAccount(
override var displayIndex: Int = 0
override var doNotShowStrikingFetchAllTransactionsView = false
override fun toString(): String {
return stringRepresentation
}

View File

@ -33,7 +33,8 @@ open class BankAccountEntity(
override var userSetDisplayName: String? = null,
override var haveAllTransactionsBeenRetrieved: Boolean = false,
override var isAccountTypeSupportedByApplication: Boolean = true,
override var displayIndex: Int = 0
override var displayIndex: Int = 0,
override var doNotShowStrikingFetchAllTransactionsView: Boolean = false
) : IBankAccount<AccountTransactionEntity> {

View File

@ -293,8 +293,8 @@ class HomeFragment : Fragment() {
private fun setFetchAllTransactionsView() {
accountsForWhichNotAllTransactionsHaveBeenFetched = presenter.selectedAccountsForWhichNotAllTransactionsHaveBeenFetched
val showFetchAllTransactionsView = accountsForWhichNotAllTransactionsHaveBeenFetched.isNotEmpty()
|| presenter.selectedAccountsTransactionRetrievalState == TransactionsRetrievalState.RetrievedTransactions
showTopFetchAllTransactionsView = presenter.showStrikingFetchAllTransactionsViewForSelectedAccounts
val showFetchAllTransactionsView = presenter.showFetchAllTransactionsViewForSelectedAccounts
if (showFetchAllTransactionsView && showTopFetchAllTransactionsView) {
lytTopFetchAllTransactions.visibility = View.VISIBLE
@ -313,9 +313,7 @@ class HomeFragment : Fragment() {
}
private fun hideTopFetchAllTransactionsView() {
// TODO: persist
showTopFetchAllTransactionsView = false
presenter.doNotShowStrikingFetchAllTransactionsViewAnymore(accountsForWhichNotAllTransactionsHaveBeenFetched)
setFetchAllTransactionsView()
}

View File

@ -50,6 +50,10 @@ open class BankAccount @JvmOverloads constructor(
override var displayIndex: Int = 0
override var doNotShowStrikingFetchAllTransactionsView = false
override fun toString(): String {
return stringRepresentation
}

View File

@ -30,6 +30,7 @@ interface IBankAccount<TTransaction: IAccountTransaction> : OrderedDisplayable {
var haveAllTransactionsBeenRetrieved: Boolean
var isAccountTypeSupportedByApplication: Boolean
var userSetDisplayName: String?
var doNotShowStrikingFetchAllTransactionsView: Boolean
override val displayName: String

View File

@ -471,6 +471,16 @@ open class BankingPresenter(
callBanksChangedListeners()
}
open fun doNotShowStrikingFetchAllTransactionsViewAnymore(accounts: List<TypedBankAccount>) {
accounts.forEach { account ->
account.doNotShowStrikingFetchAllTransactionsView = true
persistBankAsync(account.bank)
}
callBanksChangedListeners()
}
protected open fun persistBankAsync(bank: IBankData<*, *>) {
asyncRunner.runAsync {
persistBankOffUiThread(bank)
@ -680,6 +690,13 @@ open class BankingPresenter(
open val selectedAccountsForWhichNotAllTransactionsHaveBeenFetched: List<TypedBankAccount>
get() = selectedAccounts.filter { it.haveAllTransactionsBeenRetrieved == false && it.isAccountTypeSupportedByApplication }
open val showFetchAllTransactionsViewForSelectedAccounts: Boolean
get() = selectedAccountsForWhichNotAllTransactionsHaveBeenFetched.isNotEmpty()
&& selectedAccountsTransactionRetrievalState == TransactionsRetrievalState.RetrievedTransactions
open val showStrikingFetchAllTransactionsViewForSelectedAccounts: Boolean
get() = selectedAccountsForWhichNotAllTransactionsHaveBeenFetched.any { it.doNotShowStrikingFetchAllTransactionsView == false }
open val selectedAccountsTransactionRetrievalState: TransactionsRetrievalState
get() = getAccountsTransactionRetrievalState(selectedAccounts)

View File

@ -42,6 +42,7 @@
<attribute name="balance" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="currency" attributeType="String"/>
<attribute name="displayIndex" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="doNotShowStrikingFetchAllTransactionsView" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="haveAllTransactionsBeenRetrieved" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="iban" optional="YES" attributeType="String"/>
<attribute name="identifier" attributeType="String"/>
@ -90,7 +91,7 @@
</entity>
<elements>
<element name="PersistedAccountTransaction" positionX="-36" positionY="45" width="128" height="553"/>
<element name="PersistedBankAccount" positionX="-54" positionY="63" width="128" height="358"/>
<element name="PersistedBankAccount" positionX="-54" positionY="63" width="128" height="28"/>
<element name="PersistedBankData" positionX="-63" positionY="-18" width="128" height="283"/>
<element name="PersistedTanMedium" positionX="-45" positionY="144" width="128" height="28"/>
<element name="PersistedTanMethod" positionX="-54" positionY="135" width="128" height="118"/>

View File

@ -66,6 +66,8 @@ class Mapper {
mapped.userSetDisplayName = account.userSetDisplayName
mapped.displayIndex = account.displayIndex
mapped.doNotShowStrikingFetchAllTransactionsView = account.doNotShowStrikingFetchAllTransactionsView
mapped.bookedTransactions = map(mapped, account.transactions as? Set<PersistedAccountTransaction>)
mapped.technicalId = account.objectIDAsString
@ -103,6 +105,8 @@ class Mapper {
mapped.userSetDisplayName = account.userSetDisplayName
mapped.displayIndex = account.displayIndex
mapped.doNotShowStrikingFetchAllTransactionsView = account.doNotShowStrikingFetchAllTransactionsView
mapped.transactions = NSSet(array: map(mapped, account.bookedTransactions, context))
return mapped

View File

@ -165,8 +165,8 @@ struct AccountTransactionsDialog: View {
let haveTransactionsForSelectedAccountsBeenRetrieved = transactionsRetrievalState == .retrievedtransactions
self.accountsForWhichNotAllTransactionsHaveBeenFetched = presenter.selectedAccountsForWhichNotAllTransactionsHaveBeenFetched
self.showFetchAllTransactionsView = accountsForWhichNotAllTransactionsHaveBeenFetched.isNotEmpty && haveTransactionsForSelectedAccountsBeenRetrieved
//self.showFetchAllTransactionsViewAtTop = true // TODO: read from database
self.showFetchAllTransactionsView = presenter.showFetchAllTransactionsViewForSelectedAccounts
self.showFetchAllTransactionsViewAtTop = presenter.showStrikingFetchAllTransactionsViewForSelectedAccounts
self.showTransactionsList = haveTransactionsForSelectedAccountsBeenRetrieved
@ -176,12 +176,9 @@ struct AccountTransactionsDialog: View {
}
private func hideTopFetchAllTransactionsView() {
// TODO: save that we shouldn't show showFetchAllTransactionsView at top anymore in database
for account in accountsForWhichNotAllTransactionsHaveBeenFetched {
//UserDefaults.standard.set(true, forKey: Self.DoNotShowFetchAllTransactionsOverlayForUserDefaultsKeyPrefix + account.technicalId)
}
presenter.doNotShowStrikingFetchAllTransactionsViewAnymore(accounts: accountsForWhichNotAllTransactionsHaveBeenFetched)
self.showFetchAllTransactionsViewAtTop = false
setTransactionsView()
}