Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
Flutter App for Memri
Commits
0e17f906
Commit
0e17f906
authored
3 years ago
by
Amirjanyan
Browse files
Options
Download
Email Patches
Plain Diff
small refactoring
parent
a724230a
Pipeline
#5326
passed with stages
in 5 minutes and 20 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/MemriApp/Controllers/Database/ItemEdgeRecord.dart
+0
-9
lib/MemriApp/Controllers/Database/ItemEdgeRecord.dart
lib/MemriApp/Controllers/Database/ItemRecord.dart
+8
-14
lib/MemriApp/Controllers/Database/ItemRecord.dart
with
8 additions
and
23 deletions
+8
-23
lib/MemriApp/Controllers/Database/ItemEdgeRecord.dart
+
0
-
9
View file @
0e17f906
...
...
@@ -191,13 +191,4 @@ class ItemEdgeRecord {
print
(
"ERROR: Could not locate edge for synced edge:
$syncedEdge
"
);
}
}
static
ItemEdgeRecord
?
fromSyncEdgeDict
(
{
required
Map
<
String
,
dynamic
>
dict
,
required
DatabaseController
dbController
})
{
if
(
dict
[
"source"
]
!=
null
&&
dict
[
"target"
]
!=
null
&&
dict
[
"name"
]
!=
null
)
{
return
ItemEdgeRecord
.
fromSyncDict
(
dict
);
}
else
{
print
(
"ERROR: Source, target or name is missing for edge"
);
}
}
}
This diff is collapsed.
Click to expand it.
lib/MemriApp/Controllers/Database/ItemRecord.dart
+
8
-
14
View file @
0e17f906
...
...
@@ -539,12 +539,11 @@ class ItemRecord with EquatableMixin {
var
itemList
=
(
await
ItemRecord
.
fetchWithUIDs
(
uidList
,
dbController
))
.
toMapByKey
((
item
)
=
>
item
.
uid
);
var
dictList
=
responseObjects
.
compactMap
<
Map
<
String
,
dynamic
>>((
dict
)
{
if
(
dict
is
!
Map
<
String
,
dynamic
>)
return
null
;
if
(
dict
is
!
Map
<
String
,
dynamic
>
||
dict
[
"id"
]
==
null
)
return
null
;
dict
[
"rowId"
]
=
itemList
[
dict
[
"id"
]]
?.
rowId
;
return
dict
;
});
await
Future
.
forEach
<
Map
<
String
,
dynamic
>>(
dictList
,
(
dict
)
async
{
if
(
dict
[
"id"
]
==
null
)
return
;
// If the item has file and it does not exist on disk, mark the file to be downloaded
if
(
dict
[
"type"
]
==
"File"
&&
dict
[
"_item"
]
==
null
&&
dict
.
containsKey
(
"sha256"
))
{
String
?
fileName
=
dict
[
"sha256"
];
...
...
@@ -608,31 +607,26 @@ class ItemRecord with EquatableMixin {
edges
.
forEach
((
edge
)
{
edgeItems
.
addAll
([
edge
[
"_item"
],
edge
]);
});
List
<
ItemEdgeRecord
>
edgeRecords
=
[];
var
groupedEdgeItems
=
edgeItems
.
toMapByKey
((
item
)
=
>
item
[
"id"
]
as
String
);
var
uidList
=
edgeItems
.
map
((
item
)
=
>
item
[
"id"
]
as
String
)
.
toList
();
var
groupedEdgeItemRecords
=
(
await
ItemRecord
.
fetchWithUIDs
(
groupedEdgeItems
.
keys
.
toList
(),
dbController
))
.
toMapByKey
((
item
)
=
>
item
.
uid
);
edges
.
forEach
((
edge
)
{
(
await
ItemRecord
.
fetchWithUIDs
(
uidList
,
dbController
))
.
toMapByKey
((
item
)
=
>
item
.
uid
);
return
edges
.
map
((
edge
)
{
ItemRecord
self
=
groupedEdgeItemRecords
[
edge
[
"id"
]]
!
;
ItemRecord
target
=
groupedEdgeItemRecords
[
edge
[
"_item"
][
"id"
]]
!
;
ItemRecord
source
=
edge
[
"source"
]
;
var
edgeDict
=
{
"self"
:
edge
[
"id"
]
,
"self"
:
self
.
uid
,
"source"
:
source
.
uid
,
"name"
:
edge
[
"_edge"
],
"target"
:
edge
[
"_item"
][
"id"
]
,
"target"
:
target
.
uid
,
"selfRowId"
:
self
.
rowId
,
"targetRowId"
:
target
.
rowId
,
"sourceRowId"
:
source
.
rowId
}
;
var
edgeRecord
=
ItemEdgeRecord
.
fromSyncEdgeDict
(
dict:
edgeDict
,
dbController:
dbController
)
;
if
(
edgeRecord
!=
null
)
edgeRecords
.
add
(
edgeRecord
);
});
return
edgeRecords
;
return
ItemEdgeRecord
.
fromSyncDict
(
edgeDict
)
;
})
.
toList
();
}
static
List
<
ItemPropertyRecord
>
propertiesFromSyncItemDict
(
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets