Owner display name should be shown instead of owner id

This commit is contained in:
Ming Ming 2022-07-12 03:45:20 +08:00
parent 478c25b5d0
commit a65da95f75
8 changed files with 89 additions and 9 deletions

View file

@ -231,6 +231,7 @@ class File with EquatableMixin {
this.fileId,
this.isFavorite,
this.ownerId,
this.ownerDisplayName,
this.metadata,
this.isArchived,
this.overrideDateTime,
@ -268,6 +269,7 @@ class File with EquatableMixin {
fileId: json["fileId"],
isFavorite: json_util.boolFromJson(json["isFavorite"]),
ownerId: json["ownerId"] == null ? null : CiString(json["ownerId"]),
ownerDisplayName: json["ownerDisplayName"],
trashbinFilename: json["trashbinFilename"],
trashbinOriginalLocation: json["trashbinOriginalLocation"],
trashbinDeletionTime: json["trashbinDeletionTime"] == null
@ -327,6 +329,9 @@ class File with EquatableMixin {
if (ownerId != null) {
product += "ownerId: '$ownerId', ";
}
if (ownerDisplayName != null) {
product += "ownerDisplayName: '$ownerDisplayName', ";
}
if (trashbinFilename != null) {
product += "trashbinFilename: '$trashbinFilename', ";
}
@ -362,6 +367,7 @@ class File with EquatableMixin {
if (fileId != null) "fileId": fileId,
if (isFavorite != null) "isFavorite": json_util.boolToJson(isFavorite),
if (ownerId != null) "ownerId": ownerId.toString(),
if (ownerDisplayName != null) "ownerDisplayName": ownerDisplayName,
if (trashbinFilename != null) "trashbinFilename": trashbinFilename,
if (trashbinOriginalLocation != null)
"trashbinOriginalLocation": trashbinOriginalLocation,
@ -386,6 +392,7 @@ class File with EquatableMixin {
int? fileId,
bool? isFavorite,
CiString? ownerId,
String? ownerDisplayName,
String? trashbinFilename,
String? trashbinOriginalLocation,
DateTime? trashbinDeletionTime,
@ -405,6 +412,7 @@ class File with EquatableMixin {
fileId: fileId ?? this.fileId,
isFavorite: isFavorite ?? this.isFavorite,
ownerId: ownerId ?? this.ownerId,
ownerDisplayName: ownerDisplayName ?? this.ownerDisplayName,
trashbinFilename: trashbinFilename ?? this.trashbinFilename,
trashbinOriginalLocation:
trashbinOriginalLocation ?? this.trashbinOriginalLocation,
@ -430,6 +438,7 @@ class File with EquatableMixin {
fileId,
isFavorite,
ownerId,
ownerDisplayName,
trashbinFilename,
trashbinOriginalLocation,
trashbinDeletionTime,
@ -449,6 +458,7 @@ class File with EquatableMixin {
final int? fileId;
final bool? isFavorite;
final CiString? ownerId;
final String? ownerDisplayName;
final String? trashbinFilename;
final String? trashbinOriginalLocation;
final DateTime? trashbinDeletionTime;

View file

@ -45,6 +45,7 @@ class FileWebdavDataSource implements FileDataSource {
fileid: 1,
favorite: 1,
ownerId: 1,
ownerDisplayName: 1,
trashbinFilename: 1,
trashbinOriginalLocation: 1,
trashbinDeletionTime: 1,

View file

@ -36,6 +36,7 @@ class Files extends Table {
IntColumn get usedBytes => integer().nullable()();
BoolColumn get hasPreview => boolean().nullable()();
TextColumn get ownerId => text().nullable()();
TextColumn get ownerDisplayName => text().nullable()();
@override
get uniqueKeys => [

View file

@ -406,6 +406,7 @@ class File extends DataClass implements Insertable<File> {
final int? usedBytes;
final bool? hasPreview;
final String? ownerId;
final String? ownerDisplayName;
File(
{required this.rowId,
required this.server,
@ -417,7 +418,8 @@ class File extends DataClass implements Insertable<File> {
this.isCollection,
this.usedBytes,
this.hasPreview,
this.ownerId});
this.ownerId,
this.ownerDisplayName});
factory File.fromData(Map<String, dynamic> data, {String? prefix}) {
final effectivePrefix = prefix ?? '';
return File(
@ -443,6 +445,8 @@ class File extends DataClass implements Insertable<File> {
.mapFromDatabaseResponse(data['${effectivePrefix}has_preview']),
ownerId: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}owner_id']),
ownerDisplayName: const StringType().mapFromDatabaseResponse(
data['${effectivePrefix}owner_display_name']),
);
}
@override
@ -477,6 +481,9 @@ class File extends DataClass implements Insertable<File> {
if (!nullToAbsent || ownerId != null) {
map['owner_id'] = Variable<String?>(ownerId);
}
if (!nullToAbsent || ownerDisplayName != null) {
map['owner_display_name'] = Variable<String?>(ownerDisplayName);
}
return map;
}
@ -507,6 +514,9 @@ class File extends DataClass implements Insertable<File> {
ownerId: ownerId == null && nullToAbsent
? const Value.absent()
: Value(ownerId),
ownerDisplayName: ownerDisplayName == null && nullToAbsent
? const Value.absent()
: Value(ownerDisplayName),
);
}
@ -525,6 +535,7 @@ class File extends DataClass implements Insertable<File> {
usedBytes: serializer.fromJson<int?>(json['usedBytes']),
hasPreview: serializer.fromJson<bool?>(json['hasPreview']),
ownerId: serializer.fromJson<String?>(json['ownerId']),
ownerDisplayName: serializer.fromJson<String?>(json['ownerDisplayName']),
);
}
@override
@ -542,6 +553,7 @@ class File extends DataClass implements Insertable<File> {
'usedBytes': serializer.toJson<int?>(usedBytes),
'hasPreview': serializer.toJson<bool?>(hasPreview),
'ownerId': serializer.toJson<String?>(ownerId),
'ownerDisplayName': serializer.toJson<String?>(ownerDisplayName),
};
}
@ -556,7 +568,8 @@ class File extends DataClass implements Insertable<File> {
Value<bool?> isCollection = const Value.absent(),
Value<int?> usedBytes = const Value.absent(),
Value<bool?> hasPreview = const Value.absent(),
Value<String?> ownerId = const Value.absent()}) =>
Value<String?> ownerId = const Value.absent(),
Value<String?> ownerDisplayName = const Value.absent()}) =>
File(
rowId: rowId ?? this.rowId,
server: server ?? this.server,
@ -572,6 +585,9 @@ class File extends DataClass implements Insertable<File> {
usedBytes: usedBytes.present ? usedBytes.value : this.usedBytes,
hasPreview: hasPreview.present ? hasPreview.value : this.hasPreview,
ownerId: ownerId.present ? ownerId.value : this.ownerId,
ownerDisplayName: ownerDisplayName.present
? ownerDisplayName.value
: this.ownerDisplayName,
);
@override
String toString() {
@ -586,7 +602,8 @@ class File extends DataClass implements Insertable<File> {
..write('isCollection: $isCollection, ')
..write('usedBytes: $usedBytes, ')
..write('hasPreview: $hasPreview, ')
..write('ownerId: $ownerId')
..write('ownerId: $ownerId, ')
..write('ownerDisplayName: $ownerDisplayName')
..write(')'))
.toString();
}
@ -603,7 +620,8 @@ class File extends DataClass implements Insertable<File> {
isCollection,
usedBytes,
hasPreview,
ownerId);
ownerId,
ownerDisplayName);
@override
bool operator ==(Object other) =>
identical(this, other) ||
@ -618,7 +636,8 @@ class File extends DataClass implements Insertable<File> {
other.isCollection == this.isCollection &&
other.usedBytes == this.usedBytes &&
other.hasPreview == this.hasPreview &&
other.ownerId == this.ownerId);
other.ownerId == this.ownerId &&
other.ownerDisplayName == this.ownerDisplayName);
}
class FilesCompanion extends UpdateCompanion<File> {
@ -633,6 +652,7 @@ class FilesCompanion extends UpdateCompanion<File> {
final Value<int?> usedBytes;
final Value<bool?> hasPreview;
final Value<String?> ownerId;
final Value<String?> ownerDisplayName;
const FilesCompanion({
this.rowId = const Value.absent(),
this.server = const Value.absent(),
@ -645,6 +665,7 @@ class FilesCompanion extends UpdateCompanion<File> {
this.usedBytes = const Value.absent(),
this.hasPreview = const Value.absent(),
this.ownerId = const Value.absent(),
this.ownerDisplayName = const Value.absent(),
});
FilesCompanion.insert({
this.rowId = const Value.absent(),
@ -658,6 +679,7 @@ class FilesCompanion extends UpdateCompanion<File> {
this.usedBytes = const Value.absent(),
this.hasPreview = const Value.absent(),
this.ownerId = const Value.absent(),
this.ownerDisplayName = const Value.absent(),
}) : server = Value(server),
fileId = Value(fileId);
static Insertable<File> custom({
@ -672,6 +694,7 @@ class FilesCompanion extends UpdateCompanion<File> {
Expression<int?>? usedBytes,
Expression<bool?>? hasPreview,
Expression<String?>? ownerId,
Expression<String?>? ownerDisplayName,
}) {
return RawValuesInsertable({
if (rowId != null) 'row_id': rowId,
@ -685,6 +708,7 @@ class FilesCompanion extends UpdateCompanion<File> {
if (usedBytes != null) 'used_bytes': usedBytes,
if (hasPreview != null) 'has_preview': hasPreview,
if (ownerId != null) 'owner_id': ownerId,
if (ownerDisplayName != null) 'owner_display_name': ownerDisplayName,
});
}
@ -699,7 +723,8 @@ class FilesCompanion extends UpdateCompanion<File> {
Value<bool?>? isCollection,
Value<int?>? usedBytes,
Value<bool?>? hasPreview,
Value<String?>? ownerId}) {
Value<String?>? ownerId,
Value<String?>? ownerDisplayName}) {
return FilesCompanion(
rowId: rowId ?? this.rowId,
server: server ?? this.server,
@ -712,6 +737,7 @@ class FilesCompanion extends UpdateCompanion<File> {
usedBytes: usedBytes ?? this.usedBytes,
hasPreview: hasPreview ?? this.hasPreview,
ownerId: ownerId ?? this.ownerId,
ownerDisplayName: ownerDisplayName ?? this.ownerDisplayName,
);
}
@ -753,6 +779,9 @@ class FilesCompanion extends UpdateCompanion<File> {
if (ownerId.present) {
map['owner_id'] = Variable<String?>(ownerId.value);
}
if (ownerDisplayName.present) {
map['owner_display_name'] = Variable<String?>(ownerDisplayName.value);
}
return map;
}
@ -769,7 +798,8 @@ class FilesCompanion extends UpdateCompanion<File> {
..write('isCollection: $isCollection, ')
..write('usedBytes: $usedBytes, ')
..write('hasPreview: $hasPreview, ')
..write('ownerId: $ownerId')
..write('ownerId: $ownerId, ')
..write('ownerDisplayName: $ownerDisplayName')
..write(')'))
.toString();
}
@ -849,6 +879,12 @@ class $FilesTable extends Files with TableInfo<$FilesTable, File> {
late final GeneratedColumn<String?> ownerId = GeneratedColumn<String?>(
'owner_id', aliasedName, true,
type: const StringType(), requiredDuringInsert: false);
final VerificationMeta _ownerDisplayNameMeta =
const VerificationMeta('ownerDisplayName');
@override
late final GeneratedColumn<String?> ownerDisplayName =
GeneratedColumn<String?>('owner_display_name', aliasedName, true,
type: const StringType(), requiredDuringInsert: false);
@override
List<GeneratedColumn> get $columns => [
rowId,
@ -861,7 +897,8 @@ class $FilesTable extends Files with TableInfo<$FilesTable, File> {
isCollection,
usedBytes,
hasPreview,
ownerId
ownerId,
ownerDisplayName
];
@override
String get aliasedName => _alias ?? 'files';
@ -925,6 +962,12 @@ class $FilesTable extends Files with TableInfo<$FilesTable, File> {
context.handle(_ownerIdMeta,
ownerId.isAcceptableOrUnknown(data['owner_id']!, _ownerIdMeta));
}
if (data.containsKey('owner_display_name')) {
context.handle(
_ownerDisplayNameMeta,
ownerDisplayName.isAcceptableOrUnknown(
data['owner_display_name']!, _ownerDisplayNameMeta));
}
return context;
}

View file

@ -92,6 +92,7 @@ class SqliteFileConverter {
fileId: f.file.fileId,
isFavorite: f.accountFile.isFavorite,
ownerId: f.file.ownerId?.toCi(),
ownerDisplayName: f.file.ownerDisplayName,
trashbinFilename: f.trash?.filename,
trashbinOriginalLocation: f.trash?.originalLocation,
trashbinDeletionTime: f.trash?.deletionTime,
@ -113,6 +114,7 @@ class SqliteFileConverter {
usedBytes: Value(file.usedBytes),
hasPreview: Value(file.hasPreview),
ownerId: Value(file.ownerId!.toCaseInsensitiveString()),
ownerDisplayName: Value(file.ownerDisplayName),
);
final dbAccountFile = sql.AccountFilesCompanion(
account: account == null ? const Value.absent() : Value(account.rowId),

View file

@ -94,6 +94,7 @@ class WebdavResponseParser {
int? fileId;
bool? isFavorite;
CiString? ownerId;
String? ownerDisplayName;
Metadata? metadata;
bool? isArchived;
DateTime? overrideDateTime;
@ -131,6 +132,7 @@ class WebdavResponseParser {
fileId = propParser.fileId;
isFavorite = propParser.isFavorite;
ownerId = propParser.ownerId;
ownerDisplayName = propParser.ownerDisplayName;
metadata = propParser.metadata;
isArchived = propParser.isArchived;
overrideDateTime = propParser.overrideDateTime;
@ -152,6 +154,7 @@ class WebdavResponseParser {
fileId: fileId,
isFavorite: isFavorite,
ownerId: ownerId,
ownerDisplayName: ownerDisplayName,
metadata: metadata,
isArchived: isArchived,
overrideDateTime: overrideDateTime,
@ -338,6 +341,9 @@ class _FilePropParser {
} else if (child.matchQualifiedName("owner-id",
prefix: "http://owncloud.org/ns", namespaces: namespaces)) {
_ownerId = child.innerText.toCi();
} else if (child.matchQualifiedName("owner-display-name",
prefix: "http://owncloud.org/ns", namespaces: namespaces)) {
_ownerDisplayName = child.innerText;
} else if (child.matchQualifiedName("trashbin-filename",
prefix: "http://nextcloud.org/ns", namespaces: namespaces)) {
_trashbinFilename = child.innerText;
@ -385,6 +391,7 @@ class _FilePropParser {
int? get fileId => _fileId;
bool? get isFavorite => _isFavorite;
CiString? get ownerId => _ownerId;
String? get ownerDisplayName => _ownerDisplayName;
Metadata? get metadata => _metadata;
bool? get isArchived => _isArchived;
DateTime? get overrideDateTime => _overrideDateTime;
@ -407,6 +414,7 @@ class _FilePropParser {
int? _fileId;
bool? _isFavorite;
CiString? _ownerId;
String? _ownerDisplayName;
Metadata? _metadata;
bool? _isArchived;
DateTime? _overrideDateTime;

View file

@ -203,7 +203,8 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
color: AppTheme.getSecondaryTextColor(context),
),
),
title: Text(widget.file.ownerId!.toString()),
title: Text(widget.file.ownerDisplayName ??
widget.file.ownerId!.toString()),
subtitle: Text(L10n.global().fileSharedByDescription),
),
if (_tags.isNotEmpty)

View file

@ -39,6 +39,7 @@ class FilesBuilder {
bool isCollection = false,
bool hasPreview = true,
String ownerId = "admin",
String? ownerDisplayName,
Metadata? metadata,
}) {
files.add(File(
@ -52,6 +53,7 @@ class FilesBuilder {
hasPreview: hasPreview,
fileId: fileId++,
ownerId: ownerId.toCi(),
ownerDisplayName: ownerDisplayName ?? ownerId.toString(),
metadata: metadata,
));
}
@ -64,6 +66,7 @@ class FilesBuilder {
DateTime? lastModified,
bool hasPreview = true,
String ownerId = "admin",
String? ownerDisplayName,
}) =>
add(
relativePath,
@ -73,6 +76,7 @@ class FilesBuilder {
lastModified: lastModified,
hasPreview: hasPreview,
ownerId: ownerId,
ownerDisplayName: ownerDisplayName,
);
void addJpeg(
@ -82,6 +86,7 @@ class FilesBuilder {
DateTime? lastModified,
bool hasPreview = true,
String ownerId = "admin",
String? ownerDisplayName,
OrNull<Metadata>? metadata,
}) =>
add(
@ -92,6 +97,7 @@ class FilesBuilder {
lastModified: lastModified,
hasPreview: hasPreview,
ownerId: ownerId,
ownerDisplayName: ownerDisplayName,
metadata: metadata?.obj ??
Metadata(
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5),
@ -106,6 +112,7 @@ class FilesBuilder {
String? etag,
DateTime? lastModified,
String ownerId = "admin",
String? ownerDisplayName,
}) =>
add(
relativePath,
@ -114,6 +121,7 @@ class FilesBuilder {
isCollection: true,
hasPreview: false,
ownerId: ownerId,
ownerDisplayName: ownerDisplayName,
);
void addAlbumJson(
@ -123,6 +131,7 @@ class FilesBuilder {
String? etag,
DateTime? lastModified,
String ownerId = "admin",
String? ownerDisplayName,
}) =>
add(
"$homeDir/.com.nkming.nc_photos/albums/$filename.nc_album.json",
@ -132,6 +141,7 @@ class FilesBuilder {
lastModified: lastModified,
hasPreview: false,
ownerId: ownerId,
ownerDisplayName: ownerDisplayName,
);
final files = <File>[];
@ -302,6 +312,7 @@ File buildAlbumFile({
DateTime? lastModified,
required int fileId,
String ownerId = "admin",
String? ownerDisplayName,
}) =>
File(
path: path,
@ -312,6 +323,7 @@ File buildAlbumFile({
hasPreview: false,
fileId: fileId,
ownerId: ownerId.toCi(),
ownerDisplayName: ownerDisplayName ?? ownerId.toString(),
);
String buildAlbumFilePath(
@ -341,6 +353,7 @@ File buildJpegFile({
bool hasPreview = true,
required int fileId,
String ownerId = "admin",
String? ownerDisplayName,
}) =>
File(
path: path,
@ -351,6 +364,7 @@ File buildJpegFile({
hasPreview: hasPreview,
fileId: fileId,
ownerId: ownerId.toCi(),
ownerDisplayName: ownerDisplayName ?? ownerId.toString(),
);
Share buildShare({