Skip to content

Commit

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

# 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>
  • Loading branch information
bors[bot] and myConsciousness committed Dec 27, 2022
2 parents 3ec6bdc + 153926f commit 9d56700
Show file tree
Hide file tree
Showing 10 changed files with 946 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
- Supported `suggestions API methods`. ([#21](https://github.com/mastodon-dart/mastodon-api/issues/21))
- `GET /api/v2/suggestions`
- `DELETE /api/v1/suggestions/:account_id`
- Supported `conversations API methods`. ([#28](https://github.com/mastodon-dart/mastodon-api/issues/28))
- `GET /api/v1/conversations`
- `DELETE /api/v1/conversations/:id`
- `POST /api/v1/conversations/:id/read`

## v0.2.2

Expand Down
1 change: 1 addition & 0 deletions lib/mastodon_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export 'package:mastodon_api/src/service/entities/announcement_status.dart';
export 'package:mastodon_api/src/service/entities/application.dart';
export 'package:mastodon_api/src/service/entities/block_severity.dart';
export 'package:mastodon_api/src/service/entities/blocked_domain.dart';
export 'package:mastodon_api/src/service/entities/conversation.dart';
export 'package:mastodon_api/src/service/entities/display_media_setting.dart';
export 'package:mastodon_api/src/service/entities/emoji.dart';
export 'package:mastodon_api/src/service/entities/emoji_reaction.dart';
Expand Down
35 changes: 35 additions & 0 deletions lib/src/service/entities/conversation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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 'account.dart';
import 'status.dart';

part 'conversation.freezed.dart';
part 'conversation.g.dart';

@freezed
class Conversation with _$Conversation {
@JsonSerializable(includeIfNull: false)
const factory Conversation({
/// The ID of the conversation in the database.
required String id,

/// Is the conversation currently marked as unread?
@JsonKey(name: 'unread') required bool isUnread,

/// Participants in the conversation.
required List<Account> accounts,

/// The last status in the conversation.
Status? lastStatus,
}) = _Conversation;

factory Conversation.fromJson(Map<String, Object?> json) =>
_$ConversationFromJson(json);
}
268 changes: 268 additions & 0 deletions lib/src/service/entities/conversation.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
// 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

part of 'conversation.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');

Conversation _$ConversationFromJson(Map<String, dynamic> json) {
return _Conversation.fromJson(json);
}

/// @nodoc
mixin _$Conversation {
/// The ID of the conversation in the database.
String get id => throw _privateConstructorUsedError;

/// Is the conversation currently marked as unread?
@JsonKey(name: 'unread')
bool get isUnread => throw _privateConstructorUsedError;

/// Participants in the conversation.
List<Account> get accounts => throw _privateConstructorUsedError;

/// The last status in the conversation.
Status? get lastStatus => throw _privateConstructorUsedError;

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

/// @nodoc
abstract class $ConversationCopyWith<$Res> {
factory $ConversationCopyWith(
Conversation value, $Res Function(Conversation) then) =
_$ConversationCopyWithImpl<$Res, Conversation>;
@useResult
$Res call(
{String id,
@JsonKey(name: 'unread') bool isUnread,
List<Account> accounts,
Status? lastStatus});

$StatusCopyWith<$Res>? get lastStatus;
}

/// @nodoc
class _$ConversationCopyWithImpl<$Res, $Val extends Conversation>
implements $ConversationCopyWith<$Res> {
_$ConversationCopyWithImpl(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? id = null,
Object? isUnread = null,
Object? accounts = null,
Object? lastStatus = freezed,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
isUnread: null == isUnread
? _value.isUnread
: isUnread // ignore: cast_nullable_to_non_nullable
as bool,
accounts: null == accounts
? _value.accounts
: accounts // ignore: cast_nullable_to_non_nullable
as List<Account>,
lastStatus: freezed == lastStatus
? _value.lastStatus
: lastStatus // ignore: cast_nullable_to_non_nullable
as Status?,
) as $Val);
}

@override
@pragma('vm:prefer-inline')
$StatusCopyWith<$Res>? get lastStatus {
if (_value.lastStatus == null) {
return null;
}

return $StatusCopyWith<$Res>(_value.lastStatus!, (value) {
return _then(_value.copyWith(lastStatus: value) as $Val);
});
}
}

/// @nodoc
abstract class _$$_ConversationCopyWith<$Res>
implements $ConversationCopyWith<$Res> {
factory _$$_ConversationCopyWith(
_$_Conversation value, $Res Function(_$_Conversation) then) =
__$$_ConversationCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String id,
@JsonKey(name: 'unread') bool isUnread,
List<Account> accounts,
Status? lastStatus});

@override
$StatusCopyWith<$Res>? get lastStatus;
}

/// @nodoc
class __$$_ConversationCopyWithImpl<$Res>
extends _$ConversationCopyWithImpl<$Res, _$_Conversation>
implements _$$_ConversationCopyWith<$Res> {
__$$_ConversationCopyWithImpl(
_$_Conversation _value, $Res Function(_$_Conversation) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? isUnread = null,
Object? accounts = null,
Object? lastStatus = freezed,
}) {
return _then(_$_Conversation(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
isUnread: null == isUnread
? _value.isUnread
: isUnread // ignore: cast_nullable_to_non_nullable
as bool,
accounts: null == accounts
? _value._accounts
: accounts // ignore: cast_nullable_to_non_nullable
as List<Account>,
lastStatus: freezed == lastStatus
? _value.lastStatus
: lastStatus // ignore: cast_nullable_to_non_nullable
as Status?,
));
}
}

/// @nodoc
@JsonSerializable(includeIfNull: false)
class _$_Conversation implements _Conversation {
const _$_Conversation(
{required this.id,
@JsonKey(name: 'unread') required this.isUnread,
required final List<Account> accounts,
this.lastStatus})
: _accounts = accounts;

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

/// The ID of the conversation in the database.
@override
final String id;

/// Is the conversation currently marked as unread?
@override
@JsonKey(name: 'unread')
final bool isUnread;

/// Participants in the conversation.
final List<Account> _accounts;

/// Participants in the conversation.
@override
List<Account> get accounts {
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_accounts);
}

/// The last status in the conversation.
@override
final Status? lastStatus;

@override
String toString() {
return 'Conversation(id: $id, isUnread: $isUnread, accounts: $accounts, lastStatus: $lastStatus)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_Conversation &&
(identical(other.id, id) || other.id == id) &&
(identical(other.isUnread, isUnread) ||
other.isUnread == isUnread) &&
const DeepCollectionEquality().equals(other._accounts, _accounts) &&
(identical(other.lastStatus, lastStatus) ||
other.lastStatus == lastStatus));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, id, isUnread,
const DeepCollectionEquality().hash(_accounts), lastStatus);

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

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

abstract class _Conversation implements Conversation {
const factory _Conversation(
{required final String id,
@JsonKey(name: 'unread') required final bool isUnread,
required final List<Account> accounts,
final Status? lastStatus}) = _$_Conversation;

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

@override

/// The ID of the conversation in the database.
String get id;
@override

/// Is the conversation currently marked as unread?
@JsonKey(name: 'unread')
bool get isUnread;
@override

/// Participants in the conversation.
List<Account> get accounts;
@override

/// The last status in the conversation.
Status? get lastStatus;
@override
@JsonKey(ignore: true)
_$$_ConversationCopyWith<_$_Conversation> get copyWith =>
throw _privateConstructorUsedError;
}
50 changes: 50 additions & 0 deletions lib/src/service/entities/conversation.g.dart

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

0 comments on commit 9d56700

Please sign in to comment.