Skip to content

Commit

Permalink
Fix errors with new layers
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Sep 10, 2024
1 parent 41974a4 commit 354b329
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 417 deletions.
15 changes: 15 additions & 0 deletions api/lib/src/models/page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:collection/collection.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

Expand Down Expand Up @@ -44,6 +46,19 @@ sealed class DocumentPage with _$DocumentPage {
return layers.any((e) =>
e.content.whereType<SourcedElement>().any((e) => e.source == source));
}

DocumentPage mapLayers(DocumentLayer Function(DocumentLayer) mapper) {
final newLayers = layers.map(mapper).toList();
return copyWith(layers: newLayers);
}

Future<DocumentPage> mapLayersAsync(
FutureOr<DocumentLayer> Function(DocumentLayer) mapper) {
return Future.wait(layers.map((e) => Future.value(mapper(e))))
.then((newLayers) {
return copyWith(layers: newLayers.toList());
});
}
}

@freezed
Expand Down
Empty file added api/lib/src/models/painter.dart
Empty file.
4 changes: 0 additions & 4 deletions api/lib/src/protocol/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ class DocumentEvent extends ReplayEvent with _$DocumentEvent {
String newName,
) = LayerRenamed;

const factory DocumentEvent.layerRemoved(
String name,
) = LayerRemoved;

const factory DocumentEvent.layerElementsRemoved(
String name,
) = LayerElementsRemoved;
Expand Down
100 changes: 0 additions & 100 deletions api/lib/src/protocol/event.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ DocumentEvent _$DocumentEventFromJson(Map<String, dynamic> json) {
return WaypointReordered.fromJson(json);
case 'layerRenamed':
return LayerRenamed.fromJson(json);
case 'layerRemoved':
return LayerRemoved.fromJson(json);
case 'layerElementsRemoved':
return LayerElementsRemoved.fromJson(json);
case 'layerVisibilityChanged':
Expand Down Expand Up @@ -2771,104 +2769,6 @@ abstract class LayerRenamed extends DocumentEvent {
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class _$$LayerRemovedImplCopyWith<$Res> {
factory _$$LayerRemovedImplCopyWith(
_$LayerRemovedImpl value, $Res Function(_$LayerRemovedImpl) then) =
__$$LayerRemovedImplCopyWithImpl<$Res>;
@useResult
$Res call({String name});
}

/// @nodoc
class __$$LayerRemovedImplCopyWithImpl<$Res>
extends _$DocumentEventCopyWithImpl<$Res, _$LayerRemovedImpl>
implements _$$LayerRemovedImplCopyWith<$Res> {
__$$LayerRemovedImplCopyWithImpl(
_$LayerRemovedImpl _value, $Res Function(_$LayerRemovedImpl) _then)
: super(_value, _then);

/// Create a copy of DocumentEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
}) {
return _then(_$LayerRemovedImpl(
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
));
}
}

/// @nodoc
@JsonSerializable()
class _$LayerRemovedImpl extends LayerRemoved {
const _$LayerRemovedImpl(this.name, {final String? $type})
: $type = $type ?? 'layerRemoved',
super._();

factory _$LayerRemovedImpl.fromJson(Map<String, dynamic> json) =>
_$$LayerRemovedImplFromJson(json);

@override
final String name;

@JsonKey(name: 'type')
final String $type;

@override
String toString() {
return 'DocumentEvent.layerRemoved(name: $name)';
}

@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LayerRemovedImpl &&
(identical(other.name, name) || other.name == name));
}

@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, name);

/// Create a copy of DocumentEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$LayerRemovedImplCopyWith<_$LayerRemovedImpl> get copyWith =>
__$$LayerRemovedImplCopyWithImpl<_$LayerRemovedImpl>(this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$LayerRemovedImplToJson(
this,
);
}
}

abstract class LayerRemoved extends DocumentEvent {
const factory LayerRemoved(final String name) = _$LayerRemovedImpl;
const LayerRemoved._() : super._();

factory LayerRemoved.fromJson(Map<String, dynamic> json) =
_$LayerRemovedImpl.fromJson;

String get name;

/// Create a copy of DocumentEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$LayerRemovedImplCopyWith<_$LayerRemovedImpl> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class _$$LayerElementsRemovedImplCopyWith<$Res> {
factory _$$LayerElementsRemovedImplCopyWith(_$LayerElementsRemovedImpl value,
Expand Down
11 changes: 0 additions & 11 deletions api/lib/src/protocol/event.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 354b329

Please sign in to comment.