Fix the sharedWith attribute in folders
This commit is contained in:
parent
d7d5f473f2
commit
8b600143c7
4 changed files with 24 additions and 21 deletions
|
@ -99,9 +99,7 @@ class FoldersDB {
|
|||
row[columnName],
|
||||
row[columnOwnerID],
|
||||
row[columnDeviceFolder],
|
||||
(jsonDecode(row[columnSharedWith]) as List<dynamic>)
|
||||
.cast<String>()
|
||||
.toSet(),
|
||||
(jsonDecode(row[columnSharedWith]) as List<dynamic>).cast<int>().toSet(),
|
||||
row[columnUpdationTime],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -133,18 +133,23 @@ class FolderSharingService {
|
|||
.then((response) {
|
||||
return Folder.fromMap(response.data);
|
||||
}).catchError((e) {
|
||||
return Folder(
|
||||
null,
|
||||
Configuration.instance.getUsername() + "s " + deviceFolder,
|
||||
Configuration.instance.getUserID(),
|
||||
deviceFolder,
|
||||
Set<String>(),
|
||||
null,
|
||||
);
|
||||
try {
|
||||
return Folder(
|
||||
null,
|
||||
Configuration.instance.getUsername() + "s " + deviceFolder,
|
||||
Configuration.instance.getUserID(),
|
||||
deviceFolder,
|
||||
Set<int>(),
|
||||
null,
|
||||
);
|
||||
} catch (e) {
|
||||
_logger.severe(e);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<Map<String, bool>> getSharingStatus(Folder folder) async {
|
||||
Future<Map<int, bool>> getSharingStatus(Folder folder) async {
|
||||
return _dio
|
||||
.get(
|
||||
Configuration.instance.getHttpEndpoint() + "/users",
|
||||
|
@ -153,7 +158,7 @@ class FolderSharingService {
|
|||
)
|
||||
.then((response) {
|
||||
final users = (response.data["users"] as List).toList();
|
||||
final result = Map<String, bool>();
|
||||
final result = Map<int, bool>();
|
||||
for (final user in users) {
|
||||
if (user != Configuration.instance.getUsername()) {
|
||||
result[user] = folder.sharedWith.contains(user);
|
||||
|
|
|
@ -7,7 +7,7 @@ class Folder {
|
|||
final String name;
|
||||
final int ownerID;
|
||||
final String deviceFolder;
|
||||
final Set<String> sharedWith;
|
||||
final Set<int> sharedWith;
|
||||
final int updationTime;
|
||||
File thumbnailPhoto;
|
||||
|
||||
|
@ -28,7 +28,7 @@ class Folder {
|
|||
map['name'],
|
||||
map['ownerID'],
|
||||
map['deviceFolder'],
|
||||
Set<String>.from(map['sharedWith']),
|
||||
Set<int>.from(map['sharedWith']),
|
||||
map['updationTime'],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class _ShareFolderWidgetState extends State<ShareFolderWidget> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<Map<String, bool>>(
|
||||
return FutureBuilder<Map<int, bool>>(
|
||||
future:
|
||||
FolderSharingService.instance.getFolder(widget.path).then((folder) {
|
||||
_folder = folder;
|
||||
|
@ -42,7 +42,7 @@ class _ShareFolderWidgetState extends State<ShareFolderWidget> {
|
|||
);
|
||||
}
|
||||
|
||||
Widget _getSharingDialog(Map<String, bool> sharingStatus) {
|
||||
Widget _getSharingDialog(Map<int, bool> sharingStatus) {
|
||||
return AlertDialog(
|
||||
title: Text('Share "' + widget.title + '" with'),
|
||||
content: SingleChildScrollView(
|
||||
|
@ -56,7 +56,7 @@ class _ShareFolderWidgetState extends State<ShareFolderWidget> {
|
|||
FlatButton(
|
||||
child: Text("Share"),
|
||||
onPressed: () async {
|
||||
var sharedWith = Set<String>();
|
||||
var sharedWith = Set<int>();
|
||||
for (var user in sharingStatus.keys) {
|
||||
if (sharingStatus[user]) {
|
||||
sharedWith.add(user);
|
||||
|
@ -75,7 +75,7 @@ class _ShareFolderWidgetState extends State<ShareFolderWidget> {
|
|||
}
|
||||
|
||||
class SharingCheckboxWidget extends StatefulWidget {
|
||||
final Map<String, bool> sharingStatus;
|
||||
final Map<int, bool> sharingStatus;
|
||||
|
||||
const SharingCheckboxWidget(
|
||||
this.sharingStatus, {
|
||||
|
@ -87,7 +87,7 @@ class SharingCheckboxWidget extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _SharingCheckboxWidgetState extends State<SharingCheckboxWidget> {
|
||||
Map<String, bool> _sharingStatus;
|
||||
Map<int, bool> _sharingStatus;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -109,7 +109,7 @@ class _SharingCheckboxWidgetState extends State<SharingCheckboxWidget> {
|
|||
_sharingStatus[user] = value;
|
||||
});
|
||||
}),
|
||||
Text(user),
|
||||
Text(user.toString()),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue