mirror of
https://gitlab.com/mysocialportal/fediverse-archiving-tools.git
synced 2024-10-18 08:53:31 +00:00
Change text on "posts" to be HtmlWidget and add images
This commit is contained in:
parent
dc3672a58d
commit
eb9ecd39e5
16 changed files with 138 additions and 82 deletions
|
@ -1,12 +1,12 @@
|
|||
import 'dart:ui';
|
||||
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_post.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_timeline_entry.dart';
|
||||
import 'package:latlng/latlng.dart';
|
||||
import 'package:map/map.dart';
|
||||
|
||||
import 'marker_data.dart';
|
||||
|
||||
extension GeoSpatialPostExtensions on FriendicaPost {
|
||||
extension GeoSpatialPostExtensions on FriendicaTimelineEntry {
|
||||
MarkerData toMarkerData(MapTransformer transformer, Color color) {
|
||||
final latLon = LatLng(locationData.latitude, locationData.longitude);
|
||||
final offset = transformer.fromLatLngToXYCoords(latLon);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import 'dart:ui';
|
||||
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_post.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_timeline_entry.dart';
|
||||
|
||||
class MarkerData {
|
||||
final List<FriendicaPost> posts;
|
||||
final List<FriendicaTimelineEntry> posts;
|
||||
final Offset pos;
|
||||
final Color color;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:friendica_archive_browser/src/friendica/models/friendica_media_attachment.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/screens/media_slideshow_screen.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/services/path_mapping_service.dart';
|
||||
import 'package:friendica_archive_browser/src/services/friendica_archive_service.dart';
|
||||
import 'package:friendica_archive_browser/src/settings/settings_controller.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
@ -28,6 +29,7 @@ class MediaTimelineComponent extends StatelessWidget {
|
|||
final double threeAcrossWidth = MediaQuery.of(context).size.width / 3.0;
|
||||
final double preferredMultiWidth = min(threeAcrossWidth, _maxHeightWidth);
|
||||
final pathMapper = Provider.of<PathMappingService>(context);
|
||||
final archiveService = Provider.of<FriendicaArchiveService>(context);
|
||||
final settingsController = Provider.of<SettingsController>(context);
|
||||
|
||||
return Container(
|
||||
|
@ -46,7 +48,8 @@ class MediaTimelineComponent extends StatelessWidget {
|
|||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: settingsController),
|
||||
Provider.value(value: pathMapper)
|
||||
Provider.value(value: pathMapper),
|
||||
ChangeNotifierProvider.value(value: archiveService),
|
||||
],
|
||||
child: MediaSlideShowScreen(
|
||||
mediaAttachments: mediaAttachments,
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'dart:io';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_media_attachment.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/services/path_mapping_service.dart';
|
||||
import 'package:friendica_archive_browser/src/services/friendica_archive_service.dart';
|
||||
import 'package:friendica_archive_browser/src/settings/settings_controller.dart';
|
||||
import 'package:friendica_archive_browser/src/utils/snackbar_status_builder.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
@ -28,22 +29,20 @@ class MediaWrapperComponent extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final settingsController = Provider.of<SettingsController>(context);
|
||||
final pathMapper = Provider.of<PathMappingService>(context);
|
||||
final archiveService = Provider.of<FriendicaArchiveService>(context);
|
||||
final videoPlayerCommand = settingsController.videoPlayerCommand;
|
||||
final path = mediaAttachment.uri.scheme.startsWith('http')
|
||||
? mediaAttachment.uri.toString()
|
||||
: pathMapper.toFullPath(mediaAttachment.uri.path);
|
||||
final path = _calculatePath(pathMapper, archiveService);
|
||||
final width =
|
||||
preferredWidth > 0 ? preferredWidth : MediaQuery.of(context).size.width;
|
||||
final height = preferredHeight > 0
|
||||
? preferredHeight
|
||||
: MediaQuery.of(context).size.height;
|
||||
|
||||
if (mediaAttachment.estimatedType() ==
|
||||
FriendicaAttachmentMediaType.unknown) {
|
||||
if (mediaAttachment.explicitType == FriendicaAttachmentMediaType.unknown) {
|
||||
return Text('Unable to resolve type for ${mediaAttachment.uri.path}');
|
||||
}
|
||||
|
||||
if (mediaAttachment.estimatedType() == FriendicaAttachmentMediaType.video) {
|
||||
if (mediaAttachment.explicitType == FriendicaAttachmentMediaType.video) {
|
||||
final title = "Video (click to play): " + mediaAttachment.title;
|
||||
final thumbnailImageResult = _uriToImage(
|
||||
mediaAttachment.thumbnailUri, pathMapper,
|
||||
|
@ -75,7 +74,7 @@ class MediaWrapperComponent extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
if (mediaAttachment.estimatedType() == FriendicaAttachmentMediaType.image) {
|
||||
if (mediaAttachment.explicitType == FriendicaAttachmentMediaType.image) {
|
||||
final imageResult = _uriToImage(mediaAttachment.uri, pathMapper);
|
||||
if (imageResult.image == null) {
|
||||
final errorPath = imageResult.path.isNotEmpty
|
||||
|
@ -172,6 +171,24 @@ class MediaWrapperComponent extends StatelessWidget {
|
|||
|
||||
return InkWell(onTap: onTap, child: imageWidget);
|
||||
}
|
||||
|
||||
String _calculatePath(
|
||||
PathMappingService pathMapper, FriendicaArchiveService archiveService) {
|
||||
final url = mediaAttachment.uri.toString();
|
||||
String basePath = '';
|
||||
if (url.startsWith('http')) {
|
||||
final localCacheFile = archiveService.getImageByUrl(url);
|
||||
if (localCacheFile.isFailure) {
|
||||
return url;
|
||||
}
|
||||
|
||||
basePath = localCacheFile.value.localFilename;
|
||||
} else {
|
||||
basePath = mediaAttachment.uri.path;
|
||||
}
|
||||
|
||||
return pathMapper.toFullPath(basePath);
|
||||
}
|
||||
}
|
||||
|
||||
class _ImageAndPathResult {
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_post.dart';
|
||||
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_timeline_entry.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/location_data.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/services/path_mapping_service.dart';
|
||||
import 'package:friendica_archive_browser/src/settings/settings_controller.dart';
|
||||
import 'package:friendica_archive_browser/src/utils/clipboard_helper.dart';
|
||||
import 'package:friendica_archive_browser/src/utils/snackbar_status_builder.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'link_elements_component.dart';
|
||||
import 'media_timeline_component.dart';
|
||||
|
||||
class PostCard extends StatelessWidget {
|
||||
final FriendicaPost post;
|
||||
static final _logger = Logger("$PostCard");
|
||||
final FriendicaTimelineEntry post;
|
||||
|
||||
const PostCard({Key? key, required this.post}) : super(key: key);
|
||||
|
||||
|
@ -62,22 +67,25 @@ class PostCard extends StatelessWidget {
|
|||
icon: const Icon(Icons.copy)),
|
||||
),
|
||||
]),
|
||||
Wrap(
|
||||
direction: Axis.horizontal,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'By: ',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(post.author)
|
||||
],
|
||||
),
|
||||
if (post.post.isNotEmpty) ...[
|
||||
const SizedBox(height: spacingHeight),
|
||||
Text(post.post)
|
||||
HtmlWidget(
|
||||
post.post,
|
||||
onTapUrl: (url) async {
|
||||
bool canLaunchResult = await canLaunch(url);
|
||||
if (!canLaunchResult) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool launched = await launch(url);
|
||||
if (!launched) {
|
||||
final message = 'Failed to launch: $url';
|
||||
_logger.info(message);
|
||||
SnackBarStatusBuilder.buildSnackbar(context, message);
|
||||
}
|
||||
return launched;
|
||||
},
|
||||
)
|
||||
],
|
||||
if (post.locationData.hasData())
|
||||
post.locationData.toWidget(spacingHeight),
|
||||
|
|
|
@ -115,12 +115,12 @@ class FriendicaComment {
|
|||
|
||||
bool hasImages() => mediaAttachments
|
||||
.where((element) =>
|
||||
element.estimatedType() == FriendicaAttachmentMediaType.image)
|
||||
element.explicitType == FriendicaAttachmentMediaType.image)
|
||||
.isNotEmpty;
|
||||
|
||||
bool hasVideos() => mediaAttachments
|
||||
.where((element) =>
|
||||
element.estimatedType() == FriendicaAttachmentMediaType.video)
|
||||
element.explicitType == FriendicaAttachmentMediaType.video)
|
||||
.isNotEmpty;
|
||||
|
||||
static FriendicaComment fromInnerCommentJson(
|
||||
|
|
|
@ -21,6 +21,8 @@ class FriendicaMediaAttachment {
|
|||
|
||||
final List<FriendicaComment> comments;
|
||||
|
||||
final FriendicaAttachmentMediaType explicitType;
|
||||
|
||||
final Uri thumbnailUri;
|
||||
|
||||
final String title;
|
||||
|
@ -33,6 +35,7 @@ class FriendicaMediaAttachment {
|
|||
required this.metadata,
|
||||
required this.thumbnailUri,
|
||||
required this.title,
|
||||
required this.explicitType,
|
||||
required this.description,
|
||||
required this.comments});
|
||||
|
||||
|
@ -42,6 +45,7 @@ class FriendicaMediaAttachment {
|
|||
title = 'Random title ${randomId()}',
|
||||
thumbnailUri = Uri.parse('${randomId()}.jpg'),
|
||||
description = 'Random description ${randomId()}',
|
||||
explicitType = FriendicaAttachmentMediaType.image,
|
||||
comments = [
|
||||
FriendicaComment.randomBuilt(),
|
||||
FriendicaComment.randomBuilt()
|
||||
|
@ -52,6 +56,7 @@ class FriendicaMediaAttachment {
|
|||
: creationTimestamp = 0,
|
||||
thumbnailUri = Uri.file(''),
|
||||
title = '',
|
||||
explicitType = mediaTypeFromString(uri.path),
|
||||
description = '',
|
||||
comments = [],
|
||||
metadata = {};
|
||||
|
@ -59,6 +64,7 @@ class FriendicaMediaAttachment {
|
|||
FriendicaMediaAttachment.fromUriAndTime(this.uri, this.creationTimestamp)
|
||||
: thumbnailUri = Uri.file(''),
|
||||
title = '',
|
||||
explicitType = mediaTypeFromString(uri.path),
|
||||
description = '',
|
||||
comments = [],
|
||||
metadata = {};
|
||||
|
@ -67,6 +73,7 @@ class FriendicaMediaAttachment {
|
|||
: uri = Uri(),
|
||||
creationTimestamp = 0,
|
||||
thumbnailUri = Uri.file(''),
|
||||
explicitType = FriendicaAttachmentMediaType.unknown,
|
||||
title = '',
|
||||
description = '',
|
||||
comments = [],
|
||||
|
@ -74,7 +81,7 @@ class FriendicaMediaAttachment {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return 'FacebookMediaAttachment{uri: $uri, creationTimestamp: $creationTimestamp, metadata: $metadata, title: $title, description: $description, comments: $comments}';
|
||||
return 'FacebookMediaAttachment{uri: $uri, creationTimestamp: $creationTimestamp, type: $explicitType, metadata: $metadata, title: $title, description: $description, comments: $comments}';
|
||||
}
|
||||
|
||||
String toHumanString(PathMappingService mapper) {
|
||||
|
@ -85,24 +92,26 @@ class FriendicaMediaAttachment {
|
|||
return mapper.toFullPath(uri.toString());
|
||||
}
|
||||
|
||||
FriendicaAttachmentMediaType estimatedType() => mediaTypeFromString(uri.path);
|
||||
|
||||
FriendicaMediaAttachment.fromJson(Map<String, dynamic> json)
|
||||
: uri = Uri.parse(json['uri']),
|
||||
creationTimestamp = json['creationTimestamp'],
|
||||
: uri = Uri.parse(json['url']),
|
||||
creationTimestamp = 0,
|
||||
metadata = (json['metadata'] as Map<String, dynamic>? ?? {})
|
||||
.map((key, value) => MapEntry(key, value.toString())),
|
||||
comments = (json['comments'] as List<dynamic>? ?? [])
|
||||
.map((j) => FriendicaComment.fromJson(j))
|
||||
.toList(),
|
||||
thumbnailUri = Uri.parse(json['thumbnailUri'] ?? ''),
|
||||
title = json['title'] ?? '',
|
||||
description = json['description'] ?? '';
|
||||
explicitType = (json['mimetype'] ?? '').startsWith('image')
|
||||
? FriendicaAttachmentMediaType.image
|
||||
: (json['mimetype'] ?? '').startsWith('video')
|
||||
? FriendicaAttachmentMediaType.video
|
||||
: FriendicaAttachmentMediaType.unknown,
|
||||
comments = [],
|
||||
thumbnailUri = Uri(),
|
||||
title = '',
|
||||
description = '';
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'uri': uri.toString(),
|
||||
'creationTimestamp': creationTimestamp,
|
||||
'metadata': metadata,
|
||||
'type': explicitType,
|
||||
'comments': comments.map((c) => c.toJson()).toList(),
|
||||
'thumbnailUri': thumbnailUri.toString(),
|
||||
'title': title,
|
||||
|
@ -119,7 +128,7 @@ class FriendicaMediaAttachment {
|
|||
final thumbnailUri = thumbnailUrlString.startsWith('http')
|
||||
? Uri.parse(thumbnailUrlString)
|
||||
: Uri.file(thumbnailUrlString);
|
||||
json['media_metadata']?.forEach((key, value) {
|
||||
final mediaType = json['media_metadata']?.forEach((key, value) {
|
||||
if (key == 'photo_metadata' || key == 'video_metadata') {
|
||||
final exifData = value['exif_data'] ?? [];
|
||||
for (final exif in exifData) {
|
||||
|
@ -140,6 +149,7 @@ class FriendicaMediaAttachment {
|
|||
uri: uri,
|
||||
creationTimestamp: timestamp,
|
||||
metadata: metadata,
|
||||
explicitType: mediaType,
|
||||
thumbnailUri: thumbnailUri,
|
||||
title: title,
|
||||
comments: comments,
|
||||
|
|
|
@ -8,8 +8,8 @@ import 'location_data.dart';
|
|||
import 'model_utils.dart';
|
||||
import 'timeline_type.dart';
|
||||
|
||||
class FriendicaPost {
|
||||
static final _logger = Logger('$FriendicaPost');
|
||||
class FriendicaTimelineEntry {
|
||||
static final _logger = Logger('$FriendicaTimelineEntry');
|
||||
|
||||
final int creationTimestamp;
|
||||
|
||||
|
@ -31,7 +31,7 @@ class FriendicaPost {
|
|||
|
||||
final TimelineType timelineType;
|
||||
|
||||
FriendicaPost(
|
||||
FriendicaTimelineEntry(
|
||||
{this.creationTimestamp = 0,
|
||||
this.backdatedTimestamp = 0,
|
||||
this.modificationTimestamp = 0,
|
||||
|
@ -45,7 +45,7 @@ class FriendicaPost {
|
|||
: mediaAttachments = mediaAttachments ?? <FriendicaMediaAttachment>[],
|
||||
links = links ?? <Uri>[];
|
||||
|
||||
FriendicaPost.randomBuilt()
|
||||
FriendicaTimelineEntry.randomBuilt()
|
||||
: creationTimestamp = DateTime.now().millisecondsSinceEpoch,
|
||||
backdatedTimestamp = DateTime.now().millisecondsSinceEpoch,
|
||||
modificationTimestamp = DateTime.now().millisecondsSinceEpoch,
|
||||
|
@ -63,7 +63,7 @@ class FriendicaPost {
|
|||
FriendicaMediaAttachment.randomBuilt()
|
||||
];
|
||||
|
||||
FriendicaPost copy(
|
||||
FriendicaTimelineEntry copy(
|
||||
{int? creationTimestamp,
|
||||
int? backdatedTimestamp,
|
||||
int? modificationTimestamp,
|
||||
|
@ -74,7 +74,7 @@ class FriendicaPost {
|
|||
List<FriendicaMediaAttachment>? mediaAttachments,
|
||||
TimelineType? timelineType,
|
||||
List<Uri>? links}) {
|
||||
return FriendicaPost(
|
||||
return FriendicaTimelineEntry(
|
||||
creationTimestamp: creationTimestamp ?? this.creationTimestamp,
|
||||
backdatedTimestamp: backdatedTimestamp ?? this.backdatedTimestamp,
|
||||
modificationTimestamp:
|
||||
|
@ -115,15 +115,15 @@ class FriendicaPost {
|
|||
|
||||
bool hasImages() => mediaAttachments
|
||||
.where((element) =>
|
||||
element.estimatedType() == FriendicaAttachmentMediaType.image)
|
||||
element.explicitType == FriendicaAttachmentMediaType.image)
|
||||
.isNotEmpty;
|
||||
|
||||
bool hasVideos() => mediaAttachments
|
||||
.where((element) =>
|
||||
element.estimatedType() == FriendicaAttachmentMediaType.video)
|
||||
element.explicitType == FriendicaAttachmentMediaType.video)
|
||||
.isNotEmpty;
|
||||
|
||||
static FriendicaPost fromJson(
|
||||
static FriendicaTimelineEntry fromJson(
|
||||
Map<String, dynamic> json, TimelineType timelineType) {
|
||||
final int timestamp = json.containsKey('created_at')
|
||||
? OffsetDateTimeUtils.epochSecTimeFromFriendicaString(
|
||||
|
@ -135,16 +135,18 @@ class FriendicaPost {
|
|||
return 0;
|
||||
})
|
||||
: 0;
|
||||
final post = json['text'] ?? '';
|
||||
final post = json['friendica_html'] ?? '';
|
||||
final author = json['user']['name'];
|
||||
final title = json['friendica_title'] ?? '';
|
||||
final actualLocationData = LocationData();
|
||||
final modificationTimestamp = timestamp;
|
||||
final backdatedTimestamp = timestamp;
|
||||
final links = <Uri>[];
|
||||
final mediaAttachments = <FriendicaMediaAttachment>[];
|
||||
final mediaAttachments = (json['attachments'] as List<dynamic>? ?? [])
|
||||
.map((j) => FriendicaMediaAttachment.fromJson(j))
|
||||
.toList();
|
||||
|
||||
return FriendicaPost(
|
||||
return FriendicaTimelineEntry(
|
||||
creationTimestamp: timestamp,
|
||||
modificationTimestamp: modificationTimestamp,
|
||||
backdatedTimestamp: backdatedTimestamp,
|
|
@ -6,7 +6,7 @@ import 'package:friendica_archive_browser/src/friendica/components/geo/geo_exten
|
|||
import 'package:friendica_archive_browser/src/friendica/components/geo/map_bounds.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/components/geo/marker_data.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/components/post_card.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_post.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_timeline_entry.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/model_utils.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/services/facebook_archive_service.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/services/path_mapping_service.dart';
|
||||
|
@ -36,7 +36,7 @@ class GeospatialViewScreen extends StatelessWidget {
|
|||
final service = Provider.of<FacebookArchiveDataService>(context);
|
||||
final username = Provider.of<SettingsController>(context).facebookName;
|
||||
|
||||
return FutureBuilder<Result<List<FriendicaPost>, ExecError>>(
|
||||
return FutureBuilder<Result<List<FriendicaTimelineEntry>, ExecError>>(
|
||||
future: service.getPosts(),
|
||||
builder: (context, snapshot) {
|
||||
_logger.info('FacebookGeospatialViewScreen Future builder called');
|
||||
|
@ -86,7 +86,7 @@ class GeospatialViewScreen extends StatelessWidget {
|
|||
}
|
||||
|
||||
class GeospatialView extends StatefulWidget {
|
||||
final List<FriendicaPost> posts;
|
||||
final List<FriendicaTimelineEntry> posts;
|
||||
|
||||
const GeospatialView({Key? key, required this.posts}) : super(key: key);
|
||||
|
||||
|
@ -108,8 +108,8 @@ class _GeospatialViewState extends State<GeospatialView> {
|
|||
);
|
||||
|
||||
Offset? dragStart;
|
||||
final postsInList = <FriendicaPost>[];
|
||||
final postsInView = <FriendicaPost>[];
|
||||
final postsInList = <FriendicaTimelineEntry>[];
|
||||
final postsInView = <FriendicaTimelineEntry>[];
|
||||
double scaleStart = 1.0;
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/components/filter_control_component.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/components/post_card.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_post.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_timeline_entry.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/model_utils.dart';
|
||||
import 'package:friendica_archive_browser/src/screens/error_screen.dart';
|
||||
import 'package:friendica_archive_browser/src/services/friendica_archive_service.dart';
|
||||
|
@ -25,7 +25,7 @@ class PostsScreen extends StatelessWidget {
|
|||
final service = Provider.of<FriendicaArchiveService>(context);
|
||||
final username = Provider.of<SettingsController>(context).facebookName;
|
||||
|
||||
return FutureBuilder<Result<List<FriendicaPost>, ExecError>>(
|
||||
return FutureBuilder<Result<List<FriendicaTimelineEntry>, ExecError>>(
|
||||
future: service.getPosts(),
|
||||
builder: (context, snapshot) {
|
||||
_logger.info('FriendicaPostListView Future builder called');
|
||||
|
@ -83,7 +83,7 @@ class PostsScreen extends StatelessWidget {
|
|||
class _FriendicaPostsScreenWidget extends StatelessWidget {
|
||||
static final _logger = Logger('$_FriendicaPostsScreenWidget');
|
||||
|
||||
final List<FriendicaPost> posts;
|
||||
final List<FriendicaTimelineEntry> posts;
|
||||
|
||||
const _FriendicaPostsScreenWidget({Key? key, required this.posts})
|
||||
: super(key: key);
|
||||
|
@ -91,7 +91,7 @@ class _FriendicaPostsScreenWidget extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_logger.fine('Redrawing');
|
||||
return FilterControl<FriendicaPost, dynamic>(
|
||||
return FilterControl<FriendicaTimelineEntry, dynamic>(
|
||||
allItems: posts,
|
||||
imagesOnlyFilterFunction: (post) => post.hasImages(),
|
||||
videosOnlyFilterFunction: (post) => post.hasVideos(),
|
||||
|
|
|
@ -90,7 +90,7 @@ class _StatsScreenState extends State<StatsScreen> {
|
|||
onSuccess: (posts) => posts
|
||||
.where((post) => post.hasVideos())
|
||||
.expand((post) => post.mediaAttachments.where((m) =>
|
||||
m.estimatedType() == FriendicaAttachmentMediaType.video))
|
||||
m.explicitType == FriendicaAttachmentMediaType.video))
|
||||
.map((e) => TimeElement(
|
||||
timeInMS: e.creationTimestamp * 1000,
|
||||
hasImages: false,
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:friendica_archive_browser/src/friendica/models/friendica_album.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_comment.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_contact.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_post.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_timeline_entry.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/timeline_type.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/services/facebook_file_reader.dart';
|
||||
import 'package:friendica_archive_browser/src/utils/exec_error.dart';
|
||||
|
@ -40,8 +40,8 @@ class FacebookArchiveFolderReader extends ChangeNotifier {
|
|||
_logger.fine('Create new FacebookArchiveFolderReader');
|
||||
}
|
||||
|
||||
FutureResult<List<FriendicaPost>, ExecError> readPosts() async {
|
||||
final posts = <FriendicaPost>[];
|
||||
FutureResult<List<FriendicaTimelineEntry>, ExecError> readPosts() async {
|
||||
final posts = <FriendicaTimelineEntry>[];
|
||||
final errors = <ExecError>[];
|
||||
|
||||
final yourPostPath = '$rootDirectoryPath/posts/your_posts_1.json';
|
||||
|
@ -243,10 +243,11 @@ class FacebookArchiveFolderReader extends ChangeNotifier {
|
|||
return true;
|
||||
}
|
||||
|
||||
Result<List<FriendicaPost>, ExecError> _parsePostResults(
|
||||
Result<List<FriendicaTimelineEntry>, ExecError> _parsePostResults(
|
||||
List<dynamic> json, TimelineType timelineType) {
|
||||
final postsResult = runCatching(() => Result.ok(
|
||||
json.map((e) => FriendicaPost.fromJson(e, timelineType)).toList()));
|
||||
final postsResult = runCatching(() => Result.ok(json
|
||||
.map((e) => FriendicaTimelineEntry.fromJson(e, timelineType))
|
||||
.toList()));
|
||||
|
||||
postsResult.match(
|
||||
onSuccess: (value) => _logger.fine('Posts processed into PODOs'),
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:friendica_archive_browser/src/friendica/models/friendica_album.d
|
|||
import 'package:friendica_archive_browser/src/friendica/models/friendica_comment.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_contact.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_media_attachment.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_post.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_timeline_entry.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/services/path_mapping_service.dart';
|
||||
import 'package:friendica_archive_browser/src/utils/exec_error.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
@ -18,7 +18,7 @@ class FacebookArchiveDataService extends ChangeNotifier {
|
|||
final PathMappingService pathMappingService;
|
||||
final String appDataDirectory;
|
||||
final List<FriendicaAlbum> albums = [];
|
||||
final List<FriendicaPost> posts = [];
|
||||
final List<FriendicaTimelineEntry> posts = [];
|
||||
final List<FriendicaComment> comments = [];
|
||||
final List<FriendicaContact> friends = [];
|
||||
bool canUseConvoCacheFile = true;
|
||||
|
@ -40,7 +40,7 @@ class FacebookArchiveDataService extends ChangeNotifier {
|
|||
_logger.fine('clearCaches complete');
|
||||
}
|
||||
|
||||
FutureResult<List<FriendicaPost>, ExecError> getPosts() async {
|
||||
FutureResult<List<FriendicaTimelineEntry>, ExecError> getPosts() async {
|
||||
_logger.fine('Request for posts');
|
||||
if (posts.isNotEmpty) {
|
||||
_logger.fine(
|
||||
|
@ -134,8 +134,8 @@ class FacebookArchiveDataService extends ChangeNotifier {
|
|||
return Result.ok(List.unmodifiable(albums));
|
||||
}
|
||||
|
||||
FutureResult<List<FriendicaPost>, ExecError> _readAllPosts() async {
|
||||
final allPosts = <FriendicaPost>[];
|
||||
FutureResult<List<FriendicaTimelineEntry>, ExecError> _readAllPosts() async {
|
||||
final allPosts = <FriendicaTimelineEntry>[];
|
||||
bool hadSuccess = false;
|
||||
for (final topLevelDir in _topLevelDirs) {
|
||||
try {
|
||||
|
@ -258,7 +258,7 @@ class FacebookArchiveDataService extends ChangeNotifier {
|
|||
final photos = posts.value
|
||||
.map((p) => p.mediaAttachments)
|
||||
.expand((m) => m)
|
||||
.where((m) => m.estimatedType() == FriendicaAttachmentMediaType.image)
|
||||
.where((m) => m.explicitType == FriendicaAttachmentMediaType.image)
|
||||
.toList();
|
||||
photos
|
||||
.sort((p1, p2) => p1.creationTimestamp.compareTo(p2.creationTimestamp));
|
||||
|
|
|
@ -2,7 +2,7 @@ import 'dart:convert';
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_post.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/friendica_timeline_entry.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/models/timeline_type.dart';
|
||||
import 'package:friendica_archive_browser/src/friendica/services/path_mapping_service.dart';
|
||||
import 'package:friendica_archive_browser/src/models/local_image_archive_entry.dart';
|
||||
|
@ -13,7 +13,7 @@ import 'package:result_monad/result_monad.dart';
|
|||
class FriendicaArchiveService extends ChangeNotifier {
|
||||
final PathMappingService pathMappingService;
|
||||
final Map<String, ImageEntry> _imagesByRequestUrl = {};
|
||||
final List<FriendicaPost> _posts = [];
|
||||
final List<FriendicaTimelineEntry> _posts = [];
|
||||
|
||||
FriendicaArchiveService({required this.pathMappingService});
|
||||
|
||||
|
@ -22,7 +22,7 @@ class FriendicaArchiveService extends ChangeNotifier {
|
|||
_posts.clear();
|
||||
}
|
||||
|
||||
FutureResult<List<FriendicaPost>, ExecError> getPosts() async {
|
||||
FutureResult<List<FriendicaTimelineEntry>, ExecError> getPosts() async {
|
||||
if (_posts.isEmpty) {
|
||||
_loadPosts();
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ class FriendicaArchiveService extends ChangeNotifier {
|
|||
final jsonFile = File(entriesJsonPath);
|
||||
if (jsonFile.existsSync()) {
|
||||
final json = jsonDecode(jsonFile.readAsStringSync()) as List<dynamic>;
|
||||
final postEntries =
|
||||
json.map((j) => FriendicaPost.fromJson(j, TimelineType.active));
|
||||
final postEntries = json
|
||||
.map((j) => FriendicaTimelineEntry.fromJson(j, TimelineType.active));
|
||||
_posts.clear();
|
||||
_posts.addAll(postEntries);
|
||||
}
|
||||
|
|
|
@ -140,6 +140,20 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_widget_from_html_core:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_widget_from_html_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.8.4"
|
||||
fwfh_text_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fwfh_text_style
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.7.2"
|
||||
html:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -555,4 +569,4 @@ packages:
|
|||
version: "0.2.0"
|
||||
sdks:
|
||||
dart: ">=2.14.4 <3.0.0"
|
||||
flutter: ">=2.5.0"
|
||||
flutter: ">=2.6.0-0"
|
||||
|
|
|
@ -17,6 +17,7 @@ dependencies:
|
|||
charts_flutter: ^0.12.0
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
flutter_widget_from_html_core: ^0.8.4
|
||||
intl: ^0.17.0
|
||||
logging: ^1.0.2
|
||||
latlng: ^0.1.0
|
||||
|
|
Loading…
Reference in a new issue