BlogEntry.fromLegacyPost constructor
BlogEntry.fromLegacyPost(
- dynamic post, {
- String titleDivider = '|||TITLE|||',
Crea un BlogEntry a partir de un Post de tipo blogEntry (para migración).
Implementation
factory BlogEntry.fromLegacyPost(dynamic post, {String titleDivider = '|||TITLE|||'}) {
String title = '';
String content = '';
// Parsear el caption que contiene título y contenido separados por divider
final caption = post.caption ?? '';
if (caption.contains(titleDivider)) {
final parts = caption.split(titleDivider);
title = parts[0].trim();
content = parts.length > 1 ? parts[1].trim() : '';
} else {
content = caption;
}
return BlogEntry(
id: '', // Se generará nuevo ID
ownerId: post.ownerId ?? '',
profileName: post.profileName ?? '',
profileImgUrl: post.profileImgUrl ?? '',
title: title,
content: content,
thumbnailUrl: post.thumbnailUrl ?? '',
hashtags: List<String>.from(post.hashtags ?? []),
createdTime: post.createdTime ?? 0,
modifiedTime: post.modifiedTime ?? 0,
publishedTime: (post.isDraft ?? true) ? 0 : (post.createdTime ?? 0),
position: post.position,
location: post.location ?? '',
isDraft: post.isDraft ?? true,
isHidden: post.isHidden ?? false,
isCommentEnabled: post.isCommentEnabled ?? true,
themeMode: 'dark',
savedByProfiles: List<String>.from(post.savedByProfiles ?? []),
viewCount: 0,
verificationLevel: post.verificationLevel,
legacyPostId: post.id,
);
}