Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Added ability to collapse post in post page
- Added ability to change app language in settings
- Added ability to show/hide read posts in user settings
- Added post and comment previews to settings, and reorganized settings page

## 0.2.6 - 2023-11-22
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion lib/core/enums/local_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ enum LocalSettings {
/// -------------------------- Feed Related Settings --------------------------
// Default Listing/Sort Settings
defaultFeedListingType(name: 'setting_general_default_listing_type', label: 'Default Feed Type'),
defaultFeedSortType(name: 'setting_general_default_sort_type', label: 'Default Sort Type'),
defaultFeedSortType(name: 'setting_general_default_sort_type', label: 'Default Feed Sort Type'),

// NSFW Settings
hideNsfwPosts(name: 'setting_general_hide_nsfw_posts', label: 'Hide NSFW Posts from Feed'),
Expand Down
87 changes: 87 additions & 0 deletions lib/feed/utils/post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,90 @@ Future<PostView> createPost({required int communityId, required String name, Str

return postResponse.postView;
}

/// Creates a placeholder post from the given parameters. This is mainly used to display a preview of the post
/// with the applied settings on Settings -> Appearance -> Posts page.
Future<PostViewMedia?> createExamplePost({
String? postTitle,
String? postUrl,
String? postBody,
String? postThumbnailUrl,
bool? locked,
bool? nsfw,
bool? pinned,
String? personName,
String? personDisplayName,
String? communityName,
String? instanceUrl,
int? commentCount,
int? scoreCount,
bool? saved,
bool? read,
}) async {
PostView postView = PostView(
post: Post(
id: 1,
name: postTitle ?? 'Example Title',
url: postUrl,
body: postBody,
thumbnailUrl: postThumbnailUrl,
creatorId: 1,
communityId: 1,
removed: false,
locked: locked ?? false,
published: DateTime.now(),
deleted: false,
nsfw: nsfw ?? false,
apId: '',
local: false,
languageId: 0,
featuredCommunity: pinned ?? false,
featuredLocal: false,
),
creator: Person(
id: 1,
name: personName ?? 'Example Username',
displayName: personDisplayName ?? 'Example Name',
banned: false,
published: DateTime.now(),
actorId: '',
local: false,
deleted: false,
botAccount: false,
instanceId: 1,
),
community: Community(
id: 1,
name: communityName ?? 'Example Community',
title: '',
removed: false,
published: DateTime.now(),
deleted: false,
nsfw: false,
actorId: instanceUrl ?? 'https://thunder.lemmy',
local: false,
hidden: false,
postingRestrictedToMods: false,
instanceId: 1,
),
creatorBannedFromCommunity: false,
counts: PostAggregates(
id: 1,
postId: 1,
comments: commentCount ?? 0,
score: scoreCount ?? 0,
upvotes: 0,
downvotes: 0,
published: DateTime.now(),
),
subscribed: SubscribedType.notSubscribed,
saved: saved ?? false,
read: read ?? false,
creatorBlocked: false,
unreadComments: 0,
);

List<PostViewMedia> postViewMedias = await parsePostViews([postView]);

return Future.value(postViewMedias.firstOrNull);
}
Loading