Skip to content

Commit

Permalink
Merge #96
Browse files Browse the repository at this point in the history
96: feat: fixed for the issue (#30) r=myConsciousness a=myConsciousness

Co-authored-by: myConsciousness <contact@shinyakato.dev>

# 1. Description

<!-- Provide a description of what this PR is doing.
If you're modifying existing behavior, describe the existing behavior, how this PR is changing it,
and what motivated the change. If this is a breaking change, specify explicitly which APIs have been
changed. -->

## 1.1. Checklist

<!-- Before you create this PR confirm that it meets all requirements listed below by checking the
relevant checkboxes (`[x]`). This will ensure a smooth and quick review process. -->

- [x] The title of my PR starts with a [Conventional Commit] prefix (`fix:`, `feat:`, `docs:` etc).
- [x] I have read the [Contributor Guide] and followed the process outlined for submitting PRs.
- [x] I have updated/added tests for ALL new/updated/fixed functionality.
- [x] I have updated/added relevant documentation in `docs` and added dartdoc comments with `///`.
- [x] I have updated/added relevant examples in `examples`.

## 1.2. Breaking Change

<!-- Does your PR require users to manually update their apps to accommodate your change?

If the PR is a breaking change this should be indicated with suffix "!"  (for example, `feat!:`, `fix!:`). See [Conventional Commit] for details.
-->

- [ ] Yes, this is a breaking change.
- [x] No, this is _not_ a breaking change.

## 1.3. Related Issues

<!-- Provide a list of issues related to this PR from the [issue database].
Indicate which of these issues are resolved or fixed by this PR, i.e. Fixes #xxxx* !-->

<!-- Links -->

[issue database]: https://github.com/mastodon-dart/mastodon-api/issues
[contributor guide]: https://github.com/mastodon-dart/mastodon-api/blob/main/CONTRIBUTING.md
[style guide]: https://github.com/mastodon-dart/mastodon-api/blob/main/STYLEGUIDE.md
[conventional commit]: https://conventionalcommits.org


Co-authored-by: myConsciousness <contact@shinyakato.dev>
Co-authored-by: Shinya Kato / 加藤 真也 <kato.shinya.dev@gmail.com>
  • Loading branch information
3 people committed Dec 31, 2022
2 parents ae4ec2b + 3f8da20 commit 1a89a97
Show file tree
Hide file tree
Showing 17 changed files with 1,163 additions and 0 deletions.
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

0 comments on commit 1a89a97

Please sign in to comment.