Skip to content

Commit

Permalink
Merge pull request #1578 from planetary-social/media-display-phase-1
Browse files Browse the repository at this point in the history
Enable Phase 1 of new media display by removing the feature flag
  • Loading branch information
joshuatbrown authored Oct 4, 2024
2 parents e00dd40 + cb207af commit 1ac90b7
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 219 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Release Notes
- Updated the media viewer that displays images, videos, and web pages inside of notes. [#1538](https://github.com/planetary-social/nos/issues/1538)
- Added new translations for the app so you can use it in Korean, Chinese Simplified, Swedish, and more! Thanks to alternative, 안마리 (everyscreennetwork), Andypsl8, Dženan (Dzenan), ObjectifMoon, ra5pvt1n, and everyone else who contributed translations on Crowdin!

### Internal Changes
Expand Down
24 changes: 6 additions & 18 deletions Nos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@
0373CE992C0910250027C856 /* XCTestCase+FileData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0373CE982C0910250027C856 /* XCTestCase+FileData.swift */; };
0376DF622C3DBAED00C80786 /* NostrIdentifierTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0376DF612C3DBAED00C80786 /* NostrIdentifierTests.swift */; };
0378409D2BB4A2B600E5E901 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 0378409C2BB4A2B600E5E901 /* PrivacyInfo.xcprivacy */; };
037975BB2C0E24D200ADDF37 /* CompactNoteViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 037975BA2C0E24D200ADDF37 /* CompactNoteViewTests.swift */; };
037975BD2C0E25E200ADDF37 /* FeatureFlags.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0350F12C2C0A7EF20024CC15 /* FeatureFlags.swift */; };
037975BE2C0E265E00ADDF37 /* LinkPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = C905B0762A619E99009B8A78 /* LinkPreview.swift */; };
037975BE2C0E265E00ADDF37 /* LPLinkViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C905B0762A619E99009B8A78 /* LPLinkViewRepresentable.swift */; };
037975C72C0E26FC00ADDF37 /* Font+Clarity.swift in Sources */ = {isa = PBXBuildFile; fileRef = C987F85729BA981800B44E7A /* Font+Clarity.swift */; };
037975D12C0E341500ADDF37 /* MockFeatureFlags.swift in Sources */ = {isa = PBXBuildFile; fileRef = 037975D02C0E341500ADDF37 /* MockFeatureFlags.swift */; };
037975EA2C0E695A00ADDF37 /* MockFeatureFlags.swift in Sources */ = {isa = PBXBuildFile; fileRef = 037975D02C0E341500ADDF37 /* MockFeatureFlags.swift */; };
Expand Down Expand Up @@ -251,7 +250,7 @@
C90352BA2C1235CD000A5993 /* NosNavigationDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = C90352B92C1235CD000A5993 /* NosNavigationDestination.swift */; };
C90352BB2C1235CD000A5993 /* NosNavigationDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = C90352B92C1235CD000A5993 /* NosNavigationDestination.swift */; };
C905B0752A619367009B8A78 /* DequeModule in Frameworks */ = {isa = PBXBuildFile; productRef = C905B0742A619367009B8A78 /* DequeModule */; };
C905B0772A619E99009B8A78 /* LinkPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = C905B0762A619E99009B8A78 /* LinkPreview.swift */; };
C905B0772A619E99009B8A78 /* LPLinkViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C905B0762A619E99009B8A78 /* LPLinkViewRepresentable.swift */; };
C90862BE29E9804B00C35A71 /* NosPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C90862BD29E9804B00C35A71 /* NosPerformanceTests.swift */; };
C90B16B82AFED96300CB4B85 /* URLExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C90B16B72AFED96300CB4B85 /* URLExtensionTests.swift */; };
C913DA0A2AEAF52B003BDD6D /* NoteWarningController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C913DA092AEAF52B003BDD6D /* NoteWarningController.swift */; };
Expand Down Expand Up @@ -644,7 +643,6 @@
0373CE982C0910250027C856 /* XCTestCase+FileData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTestCase+FileData.swift"; sourceTree = "<group>"; };
0376DF612C3DBAED00C80786 /* NostrIdentifierTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NostrIdentifierTests.swift; sourceTree = "<group>"; };
0378409C2BB4A2B600E5E901 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
037975BA2C0E24D200ADDF37 /* CompactNoteViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompactNoteViewTests.swift; sourceTree = "<group>"; };
037975D02C0E341500ADDF37 /* MockFeatureFlags.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockFeatureFlags.swift; sourceTree = "<group>"; };
038196F62CA36797002A94E3 /* elmo-animated.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = "elmo-animated.webp"; sourceTree = "<group>"; };
038196F82CA367C4002A94E3 /* ImageAnimatedTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageAnimatedTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -782,7 +780,7 @@
A3B943D4299D514800A15A08 /* Follow+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Follow+CoreDataClass.swift"; sourceTree = "<group>"; };
C9032C2D2BAE31ED001F4EC6 /* ProfileFeedType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileFeedType.swift; sourceTree = "<group>"; };
C90352B92C1235CD000A5993 /* NosNavigationDestination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NosNavigationDestination.swift; sourceTree = "<group>"; };
C905B0762A619E99009B8A78 /* LinkPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkPreview.swift; sourceTree = "<group>"; };
C905B0762A619E99009B8A78 /* LPLinkViewRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LPLinkViewRepresentable.swift; sourceTree = "<group>"; };
C90862BB29E9804B00C35A71 /* NosPerformanceTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NosPerformanceTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C90862BD29E9804B00C35A71 /* NosPerformanceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NosPerformanceTests.swift; sourceTree = "<group>"; };
C90B16B72AFED96300CB4B85 /* URLExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLExtensionTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1194,7 +1192,6 @@
children = (
035729BB2BE416BD005FEE85 /* EventObservationTests.swift */,
038196F32CA36773002A94E3 /* Components */,
03618C8C2C826A6E00BCBC55 /* Note */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -1341,14 +1338,6 @@
path = Event;
sourceTree = "<group>";
};
03618C8C2C826A6E00BCBC55 /* Note */ = {
isa = PBXGroup;
children = (
037975BA2C0E24D200ADDF37 /* CompactNoteViewTests.swift */,
);
path = Note;
sourceTree = "<group>";
};
03618C8D2C826AB300BCBC55 /* CoreData */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1432,8 +1421,8 @@
03E181382C75467C00886CC6 /* GalleryView.swift */,
03E1812E2C753C9B00886CC6 /* ImageButton.swift */,
03C8B4952C6D065900A07CCD /* ImageViewer.swift */,
C905B0762A619E99009B8A78 /* LinkPreview.swift */,
03E181462C754BA300886CC6 /* LinkView.swift */,
C905B0762A619E99009B8A78 /* LPLinkViewRepresentable.swift */,
C92DF80729C25FA900400561 /* SquareImage.swift */,
038863DD2C6FF51500B09797 /* ZoomableContainer.swift */,
);
Expand Down Expand Up @@ -2572,7 +2561,7 @@
508B2B612C9EF65300C14034 /* NSPersistentContainer+Nos.swift in Sources */,
5B79F6552BA123D4002DA9BE /* WizardSheetBadgeText.swift in Sources */,
C9DEC04D29894BED0078B43A /* Author+CoreDataClass.swift in Sources */,
C905B0772A619E99009B8A78 /* LinkPreview.swift in Sources */,
C905B0772A619E99009B8A78 /* LPLinkViewRepresentable.swift in Sources */,
C95D68A7299E6FF000429F86 /* KeyFixture.swift in Sources */,
0304D0B22C9B731F001D16C7 /* MockOpenGraphService.swift in Sources */,
C94437E629B0DB83004D8C86 /* NotificationsView.swift in Sources */,
Expand All @@ -2588,7 +2577,7 @@
C993148E2C5BD8FC00224BA6 /* NoteEditorController.swift in Sources */,
035729CB2BE41770005FEE85 /* ContentWarningController.swift in Sources */,
CD09A76229A5220E0063464F /* AppController.swift in Sources */,
037975BE2C0E265E00ADDF37 /* LinkPreview.swift in Sources */,
037975BE2C0E265E00ADDF37 /* LPLinkViewRepresentable.swift in Sources */,
031D0BB42C826F8400D95342 /* EventProcessorIntegrationTests+InlineMetadata.swift in Sources */,
C9A0DAF929C92F4500466635 /* UNSAPI.swift in Sources */,
03A3AA3B2C5028FF008FE153 /* PublicKeyTests.swift in Sources */,
Expand Down Expand Up @@ -2750,7 +2739,6 @@
C992B32B2B3613CC00704A9C /* SubscriptionCancellable.swift in Sources */,
C92E7F6E2C4EFF9B00B80638 /* WebSocketState.swift in Sources */,
C973AB5C2A323167002AED16 /* Follow+CoreDataProperties.swift in Sources */,
037975BB2C0E24D200ADDF37 /* CompactNoteViewTests.swift in Sources */,
0376DF622C3DBAED00C80786 /* NostrIdentifierTests.swift in Sources */,
659B27312BD9D6FE00BEA6CC /* VerifiableEvent.swift in Sources */,
C90352BB2C1235CD000A5993 /* NosNavigationDestination.swift in Sources */,
Expand Down
4 changes: 0 additions & 4 deletions Nos/Service/FeatureFlags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import SwiftUI

/// Feature flags for enabling experimental or beta features.
enum FeatureFlag {
/// Whether the new media display should be enabled or not.
/// - Note: See [#1177](https://github.com/planetary-social/nos/issues/1177) for details on the new media display.
case newMediaDisplay
/// Whether the new moderation flow should be enabled or not.
/// - Note: See [#1489](https://github.com/planetary-social/nos/issues/1489) for details on the new moderation flow.
case newModerationFlow
Expand Down Expand Up @@ -36,7 +33,6 @@ protocol FeatureFlags {

/// Feature flags and their values.
private var featureFlags: [FeatureFlag: Bool] = [
.newMediaDisplay: false,
.newModerationFlow: false,
.deleteAccount: false
]
Expand Down
27 changes: 27 additions & 0 deletions Nos/Views/Components/Media/LPLinkViewRepresentable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import SwiftUI
import LinkPresentation

/// A view that displays an Open Graph Protocol preview of the given URL.
struct LPLinkViewRepresentable: UIViewRepresentable {

/// The URL of the content to display.
let url: URL

func makeUIView(context: Context) -> LPLinkView {
let linkView = LPLinkView(url: url)
linkView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
linkView.setContentCompressionResistancePriority(.defaultLow, for: .vertical)
linkView.sizeToFit()
return linkView
}

func updateUIView(_ uiView: LPLinkView, context: Context) {
let provider = LPMetadataProvider()
provider.startFetchingMetadata(for: url) { metadata, error in
guard let metadata = metadata, error == nil else { return }
DispatchQueue.main.async {
uiView.metadata = metadata
}
}
}
}
141 changes: 0 additions & 141 deletions Nos/Views/Components/Media/LinkPreview.swift

This file was deleted.

6 changes: 1 addition & 5 deletions Nos/Views/Note/CompactNoteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ struct CompactNoteView: View {
.allowsHitTesting(!note.isPreview)
}
if note.kind == EventKind.text.rawValue, showLinkPreviews, !note.contentLinks.isEmpty {
if featureFlags.isEnabled(.newMediaDisplay) {
GalleryView(urls: note.contentLinks, metadata: note.inlineMetadata)
} else {
LinkPreviewCarousel(links: note.contentLinks)
}
GalleryView(urls: note.contentLinks, metadata: note.inlineMetadata)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down
15 changes: 0 additions & 15 deletions Nos/Views/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,6 @@ struct SettingsView: View {
// DEBUG builds will have everything that's in STAGING builds and more.
#if STAGING || DEBUG
extension SettingsView {
/// Whether the new media display is enabled.
private var isNewMediaDisplayEnabled: Binding<Bool> {
Binding<Bool>(
get: { featureFlags.isEnabled(.newMediaDisplay) },
set: { featureFlags.setFeature(.newMediaDisplay, enabled: $0) }
)
}

/// A toggle for the new media display that allows the user to turn the feature on or off.
private var newMediaFeatureToggle: some View {
NosToggle(isOn: isNewMediaDisplayEnabled, labelText: .localizable.enableNewMediaDisplay)
}

/// Whether the new moderation flow is enabled.
private var isNewModerationFlowEnabled: Binding<Bool> {
Binding<Bool>(
Expand Down Expand Up @@ -322,7 +309,6 @@ extension SettingsView {
/// Controls that will appear when the app is built for STAGING.
@MainActor private var stagingControls: some View {
Group {
newMediaFeatureToggle
newModerationFlowToggle
deleteAccountToggle
}
Expand All @@ -335,7 +321,6 @@ extension SettingsView {
/// Controls that will appear when the app is built for DEBUG.
@MainActor private var debugControls: some View {
Group {
newMediaFeatureToggle
newModerationFlowToggle
deleteAccountToggle
Text(.localizable.sampleDataInstructions)
Expand Down
4 changes: 2 additions & 2 deletions NosTests/Service/MockFeatureFlags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
class MockFeatureFlags: FeatureFlags {
/// Mock feature flags and their values.
private var featureFlags: [FeatureFlag: Bool] = [
.newMediaDisplay: false,
.newModerationFlow: false
.newModerationFlow: false,
.deleteAccount: false
]

func isEnabled(_ feature: FeatureFlag) -> Bool {
Expand Down
34 changes: 0 additions & 34 deletions NosTests/Views/Note/CompactNoteViewTests.swift

This file was deleted.

0 comments on commit 1ac90b7

Please sign in to comment.