Fix display reshares as reshared user and indicate with icon

merge-requests/67/merge
Hank Grabowski 2022-12-26 22:32:14 -05:00
rodzic 6026249d75
commit 8f0a7e29d9
3 zmienionych plików z 91 dodań i 67 usunięć

Wyświetl plik

@ -28,8 +28,9 @@ class StatusHeaderControl extends StatelessWidget {
@override
Widget build(BuildContext context) {
final authorId = entry.isReshare ? entry.reshareAuthorId : entry.authorId;
final author = getIt<ConnectionsManager>()
.getById(entry.authorId)
.getById(authorId)
.getValueOrElse(() => Connection());
return Row(
mainAxisAlignment: MainAxisAlignment.start,
@ -74,6 +75,7 @@ class StatusHeaderControl extends StatelessWidget {
// ),
],
),
if (entry.isReshare) const Icon(Icons.repeat),
if (showOpenControl) ...[
const Expanded(child: SizedBox()),
buildActionBar(context),

Wyświetl plik

@ -14,6 +14,10 @@ class TimelineEntry {
final String parentAuthorId;
final String reshareAuthor;
final String reshareAuthorId;
final int creationTimestamp;
final int backdatedTimestamp;
@ -65,6 +69,8 @@ class TimelineEntry {
this.authorId = '',
this.parentAuthor = '',
this.parentAuthorId = '',
this.reshareAuthor = '',
this.reshareAuthorId = '',
this.externalLink = '',
this.locationData = const LocationData(),
this.isFavorited = false,
@ -76,22 +82,12 @@ class TimelineEntry {
});
TimelineEntry.randomBuilt()
: creationTimestamp = DateTime
.now()
.millisecondsSinceEpoch,
backdatedTimestamp = DateTime
.now()
.millisecondsSinceEpoch,
modificationTimestamp = DateTime
.now()
.millisecondsSinceEpoch,
: creationTimestamp = DateTime.now().millisecondsSinceEpoch,
backdatedTimestamp = DateTime.now().millisecondsSinceEpoch,
modificationTimestamp = DateTime.now().millisecondsSinceEpoch,
id = randomId(),
isReshare = DateTime
.now()
.second ~/ 2 == 0 ? true : false,
isPublic = DateTime
.now()
.second ~/ 2 == 0 ? true : false,
isReshare = DateTime.now().second ~/ 2 == 0 ? true : false,
isPublic = DateTime.now().second ~/ 2 == 0 ? true : false,
parentId = randomId(),
externalLink = 'Random external link ${randomId()}',
body = 'Random post text ${randomId()}',
@ -101,43 +97,46 @@ class TimelineEntry {
authorId = 'Random authorId ${randomId()}',
parentAuthor = 'Random parent author ${randomId()}',
parentAuthorId = 'Random parent author id ${randomId()}',
reshareAuthor = 'Random parent author ${randomId()}',
reshareAuthorId = 'Random parent author id ${randomId()}',
locationData = LocationData.randomBuilt(),
isFavorited = DateTime
.now()
.second ~/ 2 == 0 ? true : false,
isFavorited = DateTime.now().second ~/ 2 == 0 ? true : false,
links = [],
likes = [],
dislikes = [],
mediaAttachments = [],
engagementSummary = const EngagementSummary();
TimelineEntry copy({int? creationTimestamp,
int? backdatedTimestamp,
int? modificationTimestamp,
bool? isReshare,
bool? isPublic,
String? id,
String? parentId,
String? externalLink,
String? body,
String? title,
String? spoilerText,
String? author,
String? authorId,
String? parentAuthor,
String? parentAuthorId,
LocationData? locationData,
bool? isFavorited,
List<LinkData>? links,
List<Connection>? likes,
List<Connection>? dislikes,
List<MediaAttachment>? mediaAttachments,
EngagementSummary? engagementSummary}) {
TimelineEntry copy(
{int? creationTimestamp,
int? backdatedTimestamp,
int? modificationTimestamp,
bool? isReshare,
bool? isPublic,
String? id,
String? parentId,
String? externalLink,
String? body,
String? title,
String? spoilerText,
String? author,
String? authorId,
String? parentAuthor,
String? parentAuthorId,
String? reshareAuthor,
String? reshareAuthorId,
LocationData? locationData,
bool? isFavorited,
List<LinkData>? links,
List<Connection>? likes,
List<Connection>? dislikes,
List<MediaAttachment>? mediaAttachments,
EngagementSummary? engagementSummary}) {
return TimelineEntry(
creationTimestamp: creationTimestamp ?? this.creationTimestamp,
backdatedTimestamp: backdatedTimestamp ?? this.backdatedTimestamp,
modificationTimestamp:
modificationTimestamp ?? this.modificationTimestamp,
modificationTimestamp ?? this.modificationTimestamp,
id: id ?? this.id,
isReshare: isReshare ?? this.isReshare,
isPublic: isPublic ?? this.isPublic,
@ -150,6 +149,8 @@ class TimelineEntry {
authorId: authorId ?? this.authorId,
parentAuthor: parentAuthor ?? this.parentAuthor,
parentAuthorId: parentAuthorId ?? this.parentAuthorId,
reshareAuthor: parentAuthor ?? this.reshareAuthor,
reshareAuthorId: parentAuthorId ?? this.reshareAuthorId,
locationData: locationData ?? this.locationData,
isFavorited: isFavorited ?? this.isFavorited,
links: links ?? this.links,
@ -172,30 +173,32 @@ class TimelineEntry {
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TimelineEntry &&
runtimeType == other.runtimeType &&
id == other.id &&
parentId == other.parentId &&
parentAuthor == other.parentAuthor &&
parentAuthorId == other.parentAuthorId &&
creationTimestamp == other.creationTimestamp &&
backdatedTimestamp == other.backdatedTimestamp &&
modificationTimestamp == other.modificationTimestamp &&
body == other.body &&
title == other.title &&
spoilerText == other.spoilerText &&
isReshare == other.isReshare &&
isPublic == other.isPublic &&
author == other.author &&
authorId == other.authorId &&
externalLink == other.externalLink &&
locationData == other.locationData &&
isFavorited == other.isFavorited &&
links == other.links &&
likes == other.likes &&
dislikes == other.dislikes &&
mediaAttachments == other.mediaAttachments &&
engagementSummary == other.engagementSummary;
other is TimelineEntry &&
runtimeType == other.runtimeType &&
id == other.id &&
parentId == other.parentId &&
parentAuthor == other.parentAuthor &&
parentAuthorId == other.parentAuthorId &&
reshareAuthor == other.reshareAuthor &&
reshareAuthorId == other.reshareAuthorId &&
creationTimestamp == other.creationTimestamp &&
backdatedTimestamp == other.backdatedTimestamp &&
modificationTimestamp == other.modificationTimestamp &&
body == other.body &&
title == other.title &&
spoilerText == other.spoilerText &&
isReshare == other.isReshare &&
isPublic == other.isPublic &&
author == other.author &&
authorId == other.authorId &&
externalLink == other.externalLink &&
locationData == other.locationData &&
isFavorited == other.isFavorited &&
links == other.links &&
likes == other.likes &&
dislikes == other.dislikes &&
mediaAttachments == other.mediaAttachments &&
engagementSummary == other.engagementSummary;
@override
int get hashCode =>
@ -203,6 +206,8 @@ class TimelineEntry {
parentId.hashCode ^
parentAuthor.hashCode ^
parentAuthorId.hashCode ^
reshareAuthor.hashCode ^
reshareAuthorId.hashCode ^
creationTimestamp.hashCode ^
backdatedTimestamp.hashCode ^
modificationTimestamp.hashCode ^

Wyświetl plik

@ -54,8 +54,23 @@ extension TimelineEntryMastodonExtensions on TimelineEntry {
repliesCount: repliesCount,
);
final connectionManager = getIt<ConnectionsManager>();
final connection = ConnectionMastodonExtensions.fromJson(json['account']);
getIt<ConnectionsManager>().addConnection(connection);
connectionManager.addConnection(connection);
late final String reshareAuthor;
late final String reshareAuthorId;
if (isReshare) {
final rebloggedUser =
ConnectionMastodonExtensions.fromJson(json['reblog']['account']);
connectionManager.addConnection(rebloggedUser);
reshareAuthor = rebloggedUser.name;
reshareAuthorId = rebloggedUser.id;
} else {
reshareAuthorId = '';
reshareAuthor = '';
}
return TimelineEntry(
creationTimestamp: timestamp,
modificationTimestamp: modificationTimestamp,
@ -68,6 +83,8 @@ extension TimelineEntryMastodonExtensions on TimelineEntry {
id: id,
parentId: parentId,
parentAuthorId: parentAuthorId,
reshareAuthor: reshareAuthor,
reshareAuthorId: reshareAuthorId,
isFavorited: isFavorited,
externalLink: externalLink,
author: author,