Refactoring and tidy up.

Make the preview manager a singleton (passing in the MXSession to functions). Fix tests.

PreviewManager → URLPreviewManager
URLPreviewViewData → URLPreviewData
URLPreviewCache → URLPreviewStore
This commit is contained in:
Doug
2021-09-01 12:28:56 +01:00
parent 4331994d72
commit 882fcab738
15 changed files with 217 additions and 210 deletions
@@ -1071,7 +1071,7 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
}
// Check that the preview hasn't been dismissed already.
if ([LegacyAppDelegate.theDelegate.previewManager hasClosedPreviewFrom:lastComponent.event])
if ([URLPreviewManager.shared hasClosedPreviewFrom:lastComponent.event])
{
return;
}
@@ -1079,7 +1079,10 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
// Set the preview data.
MXWeakify(self);
[LegacyAppDelegate.theDelegate.previewManager previewFor:lastComponent.link and:lastComponent.event success:^(URLPreviewViewData * _Nonnull urlPreviewData) {
[URLPreviewManager.shared previewFor:lastComponent.link
and:lastComponent.event
with:self.mxSession
success:^(URLPreviewData * _Nonnull urlPreviewData) {
MXStrongifyAndReturnIfNil(self);
// Update the preview data and send a notification for refresh