reviewLinksForHtmlWithPlatformMediumEntity function
Future<HtmlWithPlatformMediumEntity>
reviewLinksForHtmlWithPlatformMediumEntity(
- AppModel app,
- HtmlWithPlatformMediumEntity htmlWithPlatformMediumEntity
Implementation
Future<HtmlWithPlatformMediumEntity> reviewLinksForHtmlWithPlatformMediumEntity(
AppModel app,
HtmlWithPlatformMediumEntity htmlWithPlatformMediumEntity) async {
if (htmlWithPlatformMediumEntity.htmlMedia != null) {
var html = htmlWithPlatformMediumEntity.html;
if (html != null) {
var document = parse(html);
for (var platformMedium in htmlWithPlatformMediumEntity.htmlMedia!) {
var htmlReference = platformMedium.htmlReference;
if (htmlReference != null) {
var medium = await platformMediumRepository(appId: app.documentID)!
.get(platformMedium.mediumId);
if ((medium != null) && (medium.mediumType != null)) {
document = replaceMedium(
platformMediumTypeToHtmlMediumType(medium.mediumType!),
document,
kDocumentLabelPlatform,
htmlReference,
medium.url!);
}
var newHtml = document.outerHtml;
html = newHtml;
}
}
return htmlWithPlatformMediumEntity.copyWith(html: html);
}
}
return htmlWithPlatformMediumEntity;
}