Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fixed for the issue (#30) #96

Merged
merged 4 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
- `GET /api/v1/conversations`
- `DELETE /api/v1/conversations/:id`
- `POST /api/v1/conversations/:id/read`
- Supported `markers API methods`. ([#30](https://github.com/mastodon-dart/mastodon-api/issues/30))
- `GET /api/v1/markers`
- `POST /api/v1/markers`
- Exposed objects. ([#94](https://github.com/mastodon-dart/mastodon-api/issues/94))
- `package:mastodon_api/src/service/entities/rule.dart`
- `package:mastodon_api/src/service/v1/instance/instance_v1_service.dart`
Expand Down
3 changes: 3 additions & 0 deletions lib/mastodon_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ export 'package:mastodon_api/src/service/entities/instance_usage.dart';
export 'package:mastodon_api/src/service/entities/instance_usage_users.dart';
export 'package:mastodon_api/src/service/entities/media_attachment.dart';
export 'package:mastodon_api/src/service/entities/media_attachment_type.dart';
export 'package:mastodon_api/src/service/entities/notification_snapshot.dart';
export 'package:mastodon_api/src/service/entities/poll.dart';
export 'package:mastodon_api/src/service/entities/poll_option.dart';
export 'package:mastodon_api/src/service/entities/position_marker.dart';
export 'package:mastodon_api/src/service/entities/preview_card.dart';
export 'package:mastodon_api/src/service/entities/preview_card_type.dart';
export 'package:mastodon_api/src/service/entities/rate_limit.dart';
Expand All @@ -54,6 +56,7 @@ export 'package:mastodon_api/src/service/entities/report.dart';
export 'package:mastodon_api/src/service/entities/report_category.dart';
export 'package:mastodon_api/src/service/entities/rule.dart';
export 'package:mastodon_api/src/service/entities/status.dart';
export 'package:mastodon_api/src/service/entities/status_snapshot.dart';
export 'package:mastodon_api/src/service/entities/suggested_reason.dart';
export 'package:mastodon_api/src/service/entities/suggestion.dart';
export 'package:mastodon_api/src/service/entities/tag.dart';
Expand Down
25 changes: 25 additions & 0 deletions lib/src/service/entities/notification_snapshot.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2022 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

// ignore_for_file: invalid_annotation_target

// 📦 Package imports:
import 'package:freezed_annotation/freezed_annotation.dart';

import 'position_marker.dart';

part 'notification_snapshot.freezed.dart';
part 'notification_snapshot.g.dart';

/// Represents the last read position within a user's timelines.
@freezed
class NotificationSnapshot with _$NotificationSnapshot {
const factory NotificationSnapshot({
/// Snapshot for notifications.
@JsonKey(name: 'notifications') required PositionMarker marker,
}) = _NotificationSnapshot;

factory NotificationSnapshot.fromJson(Map<String, Object?> json) =>
_$NotificationSnapshotFromJson(json);
}
176 changes: 176 additions & 0 deletions lib/src/service/entities/notification_snapshot.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark

part of 'notification_snapshot.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

NotificationSnapshot _$NotificationSnapshotFromJson(Map<String, dynamic> json) {
return _NotificationSnapshot.fromJson(json);
}

/// @nodoc
mixin _$NotificationSnapshot {
/// Snapshot for notifications.
@JsonKey(name: 'notifications')
PositionMarker get marker => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$NotificationSnapshotCopyWith<NotificationSnapshot> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $NotificationSnapshotCopyWith<$Res> {
factory $NotificationSnapshotCopyWith(NotificationSnapshot value,
$Res Function(NotificationSnapshot) then) =
_$NotificationSnapshotCopyWithImpl<$Res, NotificationSnapshot>;
@useResult
$Res call({@JsonKey(name: 'notifications') PositionMarker marker});

$PositionMarkerCopyWith<$Res> get marker;
}

/// @nodoc
class _$NotificationSnapshotCopyWithImpl<$Res,
$Val extends NotificationSnapshot>
implements $NotificationSnapshotCopyWith<$Res> {
_$NotificationSnapshotCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;

@pragma('vm:prefer-inline')
@override
$Res call({
Object? marker = null,
}) {
return _then(_value.copyWith(
marker: null == marker
? _value.marker
: marker // ignore: cast_nullable_to_non_nullable
as PositionMarker,
) as $Val);
}

@override
@pragma('vm:prefer-inline')
$PositionMarkerCopyWith<$Res> get marker {
return $PositionMarkerCopyWith<$Res>(_value.marker, (value) {
return _then(_value.copyWith(marker: value) as $Val);
});
}
}

/// @nodoc
abstract class _$$_NotificationSnapshotCopyWith<$Res>
implements $NotificationSnapshotCopyWith<$Res> {
factory _$$_NotificationSnapshotCopyWith(_$_NotificationSnapshot value,
$Res Function(_$_NotificationSnapshot) then) =
__$$_NotificationSnapshotCopyWithImpl<$Res>;
@override
@useResult
$Res call({@JsonKey(name: 'notifications') PositionMarker marker});

@override
$PositionMarkerCopyWith<$Res> get marker;
}

/// @nodoc
class __$$_NotificationSnapshotCopyWithImpl<$Res>
extends _$NotificationSnapshotCopyWithImpl<$Res, _$_NotificationSnapshot>
implements _$$_NotificationSnapshotCopyWith<$Res> {
__$$_NotificationSnapshotCopyWithImpl(_$_NotificationSnapshot _value,
$Res Function(_$_NotificationSnapshot) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? marker = null,
}) {
return _then(_$_NotificationSnapshot(
marker: null == marker
? _value.marker
: marker // ignore: cast_nullable_to_non_nullable
as PositionMarker,
));
}
}

/// @nodoc
@JsonSerializable()
class _$_NotificationSnapshot implements _NotificationSnapshot {
const _$_NotificationSnapshot(
{@JsonKey(name: 'notifications') required this.marker});

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

/// Snapshot for notifications.
@override
@JsonKey(name: 'notifications')
final PositionMarker marker;

@override
String toString() {
return 'NotificationSnapshot(marker: $marker)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_NotificationSnapshot &&
(identical(other.marker, marker) || other.marker == marker));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, marker);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_NotificationSnapshotCopyWith<_$_NotificationSnapshot> get copyWith =>
__$$_NotificationSnapshotCopyWithImpl<_$_NotificationSnapshot>(
this, _$identity);

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

abstract class _NotificationSnapshot implements NotificationSnapshot {
const factory _NotificationSnapshot(
{@JsonKey(name: 'notifications')
required final PositionMarker marker}) = _$_NotificationSnapshot;

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

@override

/// Snapshot for notifications.
@JsonKey(name: 'notifications')
PositionMarker get marker;
@override
@JsonKey(ignore: true)
_$$_NotificationSnapshotCopyWith<_$_NotificationSnapshot> get copyWith =>
throw _privateConstructorUsedError;
}
31 changes: 31 additions & 0 deletions lib/src/service/entities/notification_snapshot.g.dart

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

29 changes: 29 additions & 0 deletions lib/src/service/entities/position_marker.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2022 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

// ignore_for_file: invalid_annotation_target

// 📦 Package imports:
import 'package:freezed_annotation/freezed_annotation.dart';

part 'position_marker.freezed.dart';
part 'position_marker.g.dart';

/// Represents the last read position within a user's timelines.
@freezed
class PositionMarker with _$PositionMarker {
const factory PositionMarker({
/// The ID of the most recently viewed entity.
required String lastReadId,

/// An incrementing counter, used for locking to prevent write conflicts.
required int version,

/// The timestamp of when the marker was set.
required DateTime updatedAt,
}) = _PositionMarker;

factory PositionMarker.fromJson(Map<String, Object?> json) =>
_$PositionMarkerFromJson(json);
}
Loading