Skip to content

Commit

Permalink
refactor(nextcloud)!: Use camel case for WebDAV props
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed Apr 1, 2024
1 parent 407e0af commit 6ff2f0c
Show file tree
Hide file tree
Showing 7 changed files with 1,294 additions and 1,292 deletions.
12 changes: 6 additions & 6 deletions packages/neon/neon_files/lib/src/blocs/browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ class _FilesBrowserBloc extends InteractiveBloc implements FilesBrowserBloc {
request: () => account.client.webdav.propfind(
uri.value,
prop: const WebDavPropWithoutValues.fromBools(
davgetcontenttype: true,
davgetetag: true,
davgetlastmodified: true,
nchaspreview: true,
ocsize: true,
ocfavorite: true,
davGetcontenttype: true,
davGetetag: true,
davGetlastmodified: true,
ncHasPreview: true,
ocSize: true,
ocFavorite: true,
),
depth: WebDavDepth.one,
),
Expand Down
4 changes: 2 additions & 2 deletions packages/neon/neon_files/lib/src/blocs/files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class _FilesBloc extends InteractiveBloc implements FilesBloc {
await wrapAction(
() async => account.client.webdav.proppatch(
uri,
set: const WebDavProp(ocfavorite: 1),
set: const WebDavProp(ocFavorite: 1),
),
);
}
Expand All @@ -205,7 +205,7 @@ class _FilesBloc extends InteractiveBloc implements FilesBloc {
await wrapAction(
() async => account.client.webdav.proppatch(
uri,
set: const WebDavProp(ocfavorite: 0),
set: const WebDavProp(ocFavorite: 0),
),
);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/nextcloud/generate_props.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:io';

import 'package:dynamite/src/helpers/dart_helpers.dart';

void main() {
final props = <String, Map<String, String>>{
'dav': {
Expand Down Expand Up @@ -49,7 +51,7 @@ void main() {
final type = props[namespacePrefix]![name]!;

final namespaceVariable = convertNamespace(namespacePrefix);
final variable = namespacePrefix + name.toLowerCase().replaceAll(RegExp('[^a-z]'), '');
final variable = toDartName('$namespacePrefix-$name');
valueProps.add('''
@annotation.XmlElement(
name: '$name',
Expand Down
34 changes: 17 additions & 17 deletions packages/nextcloud/lib/src/webdav/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,63 +36,63 @@ class WebDavFile {
}();

/// The fileid namespaced by the instance id, globally unique
late final String? id = props.ocid;
late final String? id = props.ocId;

/// The unique id for the file within the instance
late final int? fileId = props.ocfileid;
late final int? fileId = props.ocFileid;

/// Whether this is a collection resource type
late final bool? isCollection = props.davresourcetype != null ? props.davresourcetype!.collection != null : null;
late final bool? isCollection = props.davResourcetype != null ? props.davResourcetype!.collection != null : null;

/// Mime-type of the file
late final String? mimeType = props.davgetcontenttype;
late final String? mimeType = props.davGetcontenttype;

/// ETag of the file
late final String? etag = props.davgetetag;
late final String? etag = props.davGetetag;

/// File content length or folder size
late final int? size = props.ocsize ?? props.davgetcontentlength;
late final int? size = props.ocSize ?? props.davGetcontentlength;

/// The user id of the owner of a shared file
late final String? ownerId = props.ocownerid;
late final String? ownerId = props.ocOwnerId;

/// The display name of the owner of a shared file
late final String? ownerDisplay = props.ocownerdisplayname;
late final String? ownerDisplay = props.ocOwnerDisplayName;

/// Share note
late final String? note = props.ncnote;
late final String? note = props.ncNote;

/// Last modified date of the file.
///
/// It will throw a [FormatException] if the date is invalid.
late final tz.TZDateTime? lastModified = () {
if (props.davgetlastmodified != null) {
return parseHttpDate(props.davgetlastmodified!);
if (props.davGetlastmodified != null) {
return parseHttpDate(props.davGetlastmodified!);
}
return null;
}();

/// Upload date of the file
late final tz.TZDateTime? uploadedDate = props.ncuploadtime != null
late final tz.TZDateTime? uploadedDate = props.ncUploadTime != null
? DateTimeUtils.fromSecondsSinceEpoch(
tz.UTC,
props.ncuploadtime!,
props.ncUploadTime!,
)
: null;

/// Creation date of the file as provided by uploader
late final tz.TZDateTime? createdDate = props.nccreationtime != null
late final tz.TZDateTime? createdDate = props.ncCreationTime != null
? DateTimeUtils.fromSecondsSinceEpoch(
tz.UTC,
props.nccreationtime!,
props.ncCreationTime!,
)
: null;

/// Whether this file is marked as favorite
late final bool? favorite = props.ocfavorite == null ? null : props.ocfavorite == 1;
late final bool? favorite = props.ocFavorite == null ? null : props.ocFavorite == 1;

/// Whether this file has a preview image
late final bool? hasPreview = props.nchaspreview;
late final bool? hasPreview = props.ncHasPreview;

/// Returns the decoded name of the file / folder without the whole path
late final String name = path.name;
Expand Down

0 comments on commit 6ff2f0c

Please sign in to comment.