Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ginkgo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vjrj
ginkgo
Commits
5cda63b7
Commit
5cda63b7
authored
1 year ago
by
vjrj
Browse files
Options
Downloads
Patches
Plain Diff
Better humanize contacts
parent
7156fa50
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/ui/ui_helpers.dart
+11
-18
11 additions, 18 deletions
lib/ui/ui_helpers.dart
with
11 additions
and
18 deletions
lib/ui/ui_helpers.dart
+
11
−
18
View file @
5cda63b7
...
...
@@ -95,26 +95,22 @@ String humanizeFromToPubKey(String publicAddress, String address) {
}
String
humanizeContacts
(
{
required
String
fromAddress
,
required
List
<
Contact
>
contacts
})
{
final
Iterable
<
Contact
>
contactsWithoutCashBack
=
contacts
.
where
(
(
Contact
c
)
=
>
extractPublicKey
(
c
.
pubKey
)
!=
extractPublicKey
(
fromAddress
));
{
required
String
publicAddress
,
required
List
<
Contact
>
contacts
})
{
if
(
contacts
.
length
>
3
)
{
return
'
${contacts
WithoutCashBack
.take(3).map((Contact contact) => humanizeContact(
''
, contact)).join(', ')}
...'
;
return
'
${contacts.take(3).map((Contact contact) => humanizeContact(
publicAddress
, contact)).join(', ')}
...'
;
}
else
if
(
contacts
.
length
>
1
)
{
final
String
lastContact
=
humanizeContact
(
''
,
contactsWithoutCashBack
.
last
);
final
String
otherContacts
=
contactsWithoutCashBack
.
take
(
contactsWithoutCashBack
.
length
-
1
)
.
map
((
Contact
contact
)
=
>
humanizeContact
(
''
,
contact
))
final
String
lastContact
=
humanizeContact
(
publicAddress
,
contacts
.
last
);
final
String
otherContacts
=
contacts
.
take
(
contacts
.
length
-
1
)
.
map
((
Contact
contact
)
=
>
humanizeContact
(
publicAddress
,
contact
))
.
join
(
', '
);
return
tr
(
'others_and_someone'
,
namedArgs:
<
String
,
String
>{
'others'
:
otherContacts
,
'someone'
:
lastContact
,
});
}
else
{
return
contacts
WithoutCashBack
.
map
((
Contact
contact
)
=
>
humanizeContact
(
''
,
contact
))
return
contacts
.
map
((
Contact
contact
)
=
>
humanizeContact
(
publicAddress
,
contact
))
.
join
(
', '
);
}
}
...
...
@@ -123,7 +119,7 @@ String humanizeContact(String publicAddress, Contact contact,
[
bool
addKey
=
false
,
bool
minimal
=
false
,
String
Function
(
String
s
)
trf
=
tr
])
{
if
(
contact
.
pubKey
==
publicAddress
)
{
if
(
extractPublicKey
(
contact
.
pubKey
)
==
extractPublicKey
(
publicAddress
)
)
{
return
trf
(
'your_wallet'
);
}
else
{
final
String
pubKey
=
humanizePubKey
(
contact
.
pubKey
);
...
...
@@ -329,13 +325,12 @@ Future<void> fetchTransactionsFromBackground([bool init = true]) async {
loggerDev
(
'Initialized background context'
);
final
GetIt
getIt
=
GetIt
.
instance
;
final
AppCubit
appCubit
=
getIt
.
get
<
AppCubit
>();
final
UtxoCubit
utxoCubit
=
getIt
.
get
<
UtxoCubit
>();
final
MultiWalletTransactionCubit
transCubit
=
getIt
.
get
<
MultiWalletTransactionCubit
>();
final
NodeListCubit
nodeListCubit
=
getIt
.
get
<
NodeListCubit
>();
for
(
final
CesiumCard
card
in
SharedPreferencesHelper
()
.
cards
)
{
loggerDev
(
'Fetching transactions for
${card.pubKey}
in background'
);
transCubit
.
fetchTransactions
(
nodeListCubit
,
utxoCubit
,
appCubit
,
transCubit
.
fetchTransactions
(
nodeListCubit
,
appCubit
,
pubKey:
card
.
pubKey
);
}
if
(
inDevelopment
)
{
...
...
@@ -355,10 +350,8 @@ Future<void> fetchTransactions(BuildContext context) async {
final
MultiWalletTransactionCubit
transCubit
=
context
.
read
<
MultiWalletTransactionCubit
>();
final
NodeListCubit
nodeListCubit
=
context
.
read
<
NodeListCubit
>();
final
UtxoCubit
utxoCubit
=
context
.
read
<
UtxoCubit
>();
for
(
final
CesiumCard
card
in
SharedPreferencesHelper
()
.
cards
)
{
transCubit
.
fetchTransactions
(
nodeListCubit
,
utxoCubit
,
appCubit
,
pubKey:
card
.
pubKey
);
transCubit
.
fetchTransactions
(
nodeListCubit
,
appCubit
,
pubKey:
card
.
pubKey
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment