Last active
December 30, 2020 20:44
-
-
Save arturaz/06f81fdfc7914205c4325292e3a6f396 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pre copy-paste | |
getAccount(accountId) | |
.filterMap((account) => | |
account.details.owner != modifier | |
? Some( | |
"Can't modify a transaction $eventToModifyRef in account $accountId that you don't own: " | |
"owner=${account.details.owner}, modifier=$modifier" | |
) | |
: const Option.none() | |
) | |
// pasting into here: | |
return getAccount(newTxData.accountId) | |
.filterMap((newAccount) { | |
final either = | |
originalAccount.delTx(modifyEventRef, eventToModifyRef, _eventDatas, accountId); | |
if (either.isLeft) return either.left; | |
either.rightOrThrow(); | |
newAccount.addTx(eventToModifyRef, newTx, newTxData.total); | |
return const Option.none(); | |
}) | |
.left; | |
// after copy paste | |
return getAccount(newTxData.accountId) | |
.filterMap((account) => | |
account.details.owner != modifier | |
? Some( | |
"Can't modify a transaction $eventToModifyRef in account $accountId that you don't own: " | |
"owner=${account.details.owner}, modifier=$modifier" | |
) | |
: const Option.none() | |
) | |
.filterMap((newAccount) { | |
final either = | |
originalAccount.delTx(modifyEventRef, eventToModifyRef, _eventDatas, accountId); | |
if (either.isLeft) return either.left; | |
either.rightOrThrow(); | |
newAccount.addTx(eventToModifyRef, newTx, newTxData.total); | |
return const Option.none(); | |
}) | |
.left; | |
// after manual formatting | |
return getAccount(newTxData.accountId) | |
.filterMap((account) => | |
account.details.owner != modifier | |
? Some( | |
"Can't modify a transaction $eventToModifyRef in account ${newTxData.accountId} " | |
"that you don't own: owner=${account.details.owner}, modifier=$modifier" | |
) | |
: const Option.none() | |
) | |
.filterMap((newAccount) { | |
final either = | |
originalAccount.delTx(modifyEventRef, eventToModifyRef, _eventDatas, accountId); | |
if (either.isLeft) return either.left; | |
either.rightOrThrow(); | |
newAccount.addTx(eventToModifyRef, newTx, newTxData.total); | |
return const Option.none(); | |
}) | |
.left; | |
// after dartfmt | |
return getAccount(newTxData.accountId) | |
.filterMap((account) => account.details.owner != modifier | |
? Some( | |
"Can't modify a transaction $eventToModifyRef in account ${newTxData.accountId} " | |
"that you don't own: owner=${account.details.owner}, modifier=$modifier") | |
: const Option.none()) | |
.filterMap((newAccount) { | |
// !!! What is this? Why is this indented LESS than previous line? | |
final either = | |
originalAccount.delTx(modifyEventRef, eventToModifyRef, _eventDatas, accountId); | |
if (either.isLeft) return either.left; | |
either.rightOrThrow(); | |
newAccount.addTx(eventToModifyRef, newTx, newTxData.total); | |
return const Option.none(); | |
// !!! What is this? Why is this indented LESS than opening block? | |
}).left; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment