Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ disabled_rules:

excluded:
- build
- .build
# TODO: Refactor these files and remove the temporary lint exclusion.
- BitDream/Transmission/TransmissionFunctions.swift
- BitDream/TransmissionStore.swift
Expand Down
22 changes: 5 additions & 17 deletions BitDream.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
4B1DADE8295E6C450037E9FB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B1DADE7295E6C450037E9FB /* Assets.xcassets */; };
4B1DADEC295E6C450037E9FB /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B1DADEB295E6C450037E9FB /* Preview Assets.xcassets */; };
4B1DADFE295E6F390037E9FB /* TransmissionTorrentModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1DADFD295E6F390037E9FB /* TransmissionTorrentModels.swift */; };
4B1DAE00295E6F600037E9FB /* TransmissionFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1DADFF295E6F600037E9FB /* TransmissionFunctions.swift */; };
4B1DAE02295E6FA30037E9FB /* AddTorrent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1DAE01295E6FA30037E9FB /* AddTorrent.swift */; };
4B1DAE06295E6FC80037E9FB /* TorrentDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1DAE05295E6FC80037E9FB /* TorrentDetail.swift */; };
4B1DAE0A295E6FE10037E9FB /* ServerDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1DAE09295E6FE10037E9FB /* ServerDetail.swift */; };
Expand Down Expand Up @@ -100,7 +99,6 @@
4F8000044000000000A1B2C3 /* macOSContentSidebar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8000014000000000A1B2C3 /* macOSContentSidebar.swift */; };
4F8000054000000000A1B2C3 /* macOSContentDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8000024000000000A1B2C3 /* macOSContentDetail.swift */; };
4F8000064000000000A1B2C3 /* macOSContentToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8000034000000000A1B2C3 /* macOSContentToolbar.swift */; };
4FA9A0024100000000A1B2C3 /* TorrentActionExecutor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FA9A0014100000000A1B2C3 /* TorrentActionExecutor.swift */; };
5A1000014100000000A1B2C3 /* TransmissionModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A1000064100000000A1B2C3 /* TransmissionModels.swift */; };
5A1000214100000000A1B2C3 /* TransmissionTransport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A1000224100000000A1B2C3 /* TransmissionTransport.swift */; };
5A1000234100000000A1B2C3 /* TransmissionConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A1000244100000000A1B2C3 /* TransmissionConnection.swift */; };
Expand All @@ -111,8 +109,7 @@
7B1000014300000000A1B2C3 /* Formatting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1000024300000000A1B2C3 /* Formatting.swift */; };
7B1000034300000000A1B2C3 /* Sorting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1000044300000000A1B2C3 /* Sorting.swift */; };
7B1000054300000000A1B2C3 /* TransmissionReadSnapshots.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1000064300000000A1B2C3 /* TransmissionReadSnapshots.swift */; };
7B1000074300000000A1B2C3 /* TransmissionLegacyConnectionInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1000084300000000A1B2C3 /* TransmissionLegacyConnectionInfo.swift */; };
7B1000094300000000A1B2C3 /* TransmissionLegacyUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B10000A4300000000A1B2C3 /* TransmissionLegacyUI.swift */; };
7B1000094300000000A1B2C3 /* TransmissionActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B10000A4300000000A1B2C3 /* TransmissionActions.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -153,7 +150,6 @@
4B1DADE9295E6C450037E9FB /* BitDream.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = BitDream.entitlements; sourceTree = "<group>"; };
4B1DADEB295E6C450037E9FB /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
4B1DADFD295E6F390037E9FB /* TransmissionTorrentModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransmissionTorrentModels.swift; sourceTree = "<group>"; };
4B1DADFF295E6F600037E9FB /* TransmissionFunctions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransmissionFunctions.swift; sourceTree = "<group>"; };
4B1DAE01295E6FA30037E9FB /* AddTorrent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTorrent.swift; sourceTree = "<group>"; };
4B1DAE05295E6FC80037E9FB /* TorrentDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TorrentDetail.swift; sourceTree = "<group>"; };
4B1DAE09295E6FE10037E9FB /* ServerDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerDetail.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -239,7 +235,6 @@
4F8000014000000000A1B2C3 /* macOSContentSidebar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = macOSContentSidebar.swift; sourceTree = "<group>"; };
4F8000024000000000A1B2C3 /* macOSContentDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = macOSContentDetail.swift; sourceTree = "<group>"; };
4F8000034000000000A1B2C3 /* macOSContentToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = macOSContentToolbar.swift; sourceTree = "<group>"; };
4FA9A0014100000000A1B2C3 /* TorrentActionExecutor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TorrentActionExecutor.swift; sourceTree = "<group>"; };
5A1000064100000000A1B2C3 /* TransmissionModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransmissionModels.swift; sourceTree = "<group>"; };
5A1000074100000000A1B2C3 /* BitDreamTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BitDreamTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5A1000224100000000A1B2C3 /* TransmissionTransport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransmissionTransport.swift; sourceTree = "<group>"; };
Expand All @@ -251,8 +246,7 @@
7B1000024300000000A1B2C3 /* Formatting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Formatting.swift; sourceTree = "<group>"; };
7B1000044300000000A1B2C3 /* Sorting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sorting.swift; sourceTree = "<group>"; };
7B1000064300000000A1B2C3 /* TransmissionReadSnapshots.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransmissionReadSnapshots.swift; sourceTree = "<group>"; };
7B1000084300000000A1B2C3 /* TransmissionLegacyConnectionInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransmissionLegacyConnectionInfo.swift; sourceTree = "<group>"; };
7B10000A4300000000A1B2C3 /* TransmissionLegacyUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransmissionLegacyUI.swift; sourceTree = "<group>"; };
7B10000A4300000000A1B2C3 /* TransmissionActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransmissionActions.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
Expand Down Expand Up @@ -345,13 +339,13 @@
children = (
4B908AED2E6EBAC700C2DA5C /* Info.plist */,
4B7EF5702E6E9F0C00C1C281 /* AppConfig.swift */,
4B1DAE0F295E702B0037E9FB /* TransmissionStore.swift */,
4D1000033B00000000B1C2D3 /* AppUpdater.swift */,
4B1DADDE295E6C440037E9FB /* BitDreamApp.swift */,
7B1000024300000000A1B2C3 /* Formatting.swift */,
4D3A00043C00000000E1F1A1 /* KeychainService.swift */,
7B1000044300000000A1B2C3 /* Sorting.swift */,
4BD938E92D82AF6F006CE97C /* ThemeManager.swift */,
4B1DAE0F295E702B0037E9FB /* TransmissionStore.swift */,
4B0349D52F56EB81008ED58D /* AppIcon */,
4B73985B2E70097C00D06E5D /* Delegates */,
4D3A00073C00000000E1F1A1 /* Models */,
Expand Down Expand Up @@ -388,8 +382,6 @@
4B1DADFC295E6F0F0037E9FB /* Transmission */ = {
isa = PBXGroup;
children = (
4B1DADFF295E6F600037E9FB /* TransmissionFunctions.swift */,
7B1000084300000000A1B2C3 /* TransmissionLegacyConnectionInfo.swift */,
5A1000064100000000A1B2C3 /* TransmissionModels.swift */,
5A1000224100000000A1B2C3 /* TransmissionTransport.swift */,
5A1000244100000000A1B2C3 /* TransmissionConnection.swift */,
Expand Down Expand Up @@ -474,8 +466,7 @@
4B1DAE09295E6FE10037E9FB /* ServerDetail.swift */,
4B1DAE0B295E6FEF0037E9FB /* ServerList.swift */,
4B1DAE05295E6FC80037E9FB /* TorrentDetail.swift */,
4FA9A0014100000000A1B2C3 /* TorrentActionExecutor.swift */,
7B10000A4300000000A1B2C3 /* TransmissionLegacyUI.swift */,
7B10000A4300000000A1B2C3 /* TransmissionActions.swift */,
4B6F1EBF2D86D52A003D8F6E /* TorrentFileDetail.swift */,
4B6F1EB12D82DB21003D8F6E /* TorrentListRow.swift */,
4BF593B82E89BF6300A8C1FC /* TorrentPeerDetail.swift */,
Expand Down Expand Up @@ -751,13 +742,11 @@
4B6F1EB02D82D340003D8F6E /* iOSSettingsView.swift in Sources */,
4BC6F24B2E89F8510037DFDF /* PiecesGridView.swift in Sources */,
4B6F1EBC2D86C908003D8F6E /* macOSTorrentFileDetail.swift in Sources */,
4B1DAE00295E6F600037E9FB /* TransmissionFunctions.swift in Sources */,
5A1000014100000000A1B2C3 /* TransmissionModels.swift in Sources */,
5A1000214100000000A1B2C3 /* TransmissionTransport.swift in Sources */,
5A1000234100000000A1B2C3 /* TransmissionConnection.swift in Sources */,
7B1000054300000000A1B2C3 /* TransmissionReadSnapshots.swift in Sources */,
6A1000014200000000A1B2C3 /* TransmissionConnectionFactory.swift in Sources */,
7B1000074300000000A1B2C3 /* TransmissionLegacyConnectionInfo.swift in Sources */,
6A1000034200000000A1B2C3 /* TransmissionTorrents.swift in Sources */,
6A1000054200000000A1B2C3 /* TransmissionSession.swift in Sources */,
6A1000074200000000A1B2C3 /* TransmissionErrorPresentation.swift in Sources */,
Expand All @@ -775,7 +764,6 @@
4B1DAE0C295E6FEF0037E9FB /* ServerList.swift in Sources */,
4E2000024000000000C1D2E3 /* NetworkSettings.swift in Sources */,
4E2000014000000000C1D2E3 /* SpeedLimitsSettings.swift in Sources */,
4FA9A0024100000000A1B2C3 /* TorrentActionExecutor.swift in Sources */,
4B6F1EB22D82DB21003D8F6E /* TorrentListRow.swift in Sources */,
4B1DAE06295E6FC80037E9FB /* TorrentDetail.swift in Sources */,
4E2000034000000000C1D2E3 /* TorrentSettings.swift in Sources */,
Expand All @@ -786,7 +774,7 @@
4BCF27502E774EDC00F6BF76 /* DataModels.swift in Sources */,
4B9CAC562D7E83460094CD03 /* iOSAddTorrent.swift in Sources */,
4BE364BA2E6E75B300CF1A33 /* SharedComponents.swift in Sources */,
7B1000094300000000A1B2C3 /* TransmissionLegacyUI.swift in Sources */,
7B1000094300000000A1B2C3 /* TransmissionActions.swift in Sources */,
4BF593B72E89BF5500A8C1FC /* macOSTorrentPeerDetail.swift in Sources */,
4BF593B92E89BF6300A8C1FC /* TorrentPeerDetail.swift in Sources */,
4BC5C2AA2D7D20B500D80AB4 /* iOSContentView.swift in Sources */,
Expand Down
95 changes: 69 additions & 26 deletions BitDream/BitDreamApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,34 @@ struct BitDreamApp: App {
#endif
}

var body: some Scene {
#if os(macOS)
macOSScenes
#else
iOSScene
#endif
}
}

private extension BitDreamApp {
#if os(macOS)
private func syncMenuBarStatusItem(isEnabled: Bool? = nil) {
func syncMenuBarStatusItem(isEnabled: Bool? = nil) {
menuBarStatusItemController.configure(
isEnabled: isEnabled ?? menuBarTransferWidgetEnabled,
store: store
)
}
#endif

var body: some Scene {
#if os(macOS)
@SceneBuilder
var macOSScenes: some Scene {
mainWindowScene
connectionInfoScene
statisticsScene
aboutScene
settingsScene
}

var mainWindowScene: some Scene {
Window("BitDream", id: "main") {
ContentView()
.environmentObject(store) // Pass the shared store to the ContentView
Expand Down Expand Up @@ -127,11 +144,29 @@ struct BitDreamApp: App {
) { result in
switch result {
case .success(let urls):
guard store.host != nil else {
presentAddTorrentStoreError(
detail: addTorrentNoServerConfiguredMessage,
store: store
)
return
}
var failures: [(String, String)] = []
for url in urls {
do {
let data = try Data(contentsOf: url)
addTorrentFromFileData(data, store: store)
performTransmissionAction(
operation: {
try await store.addTorrent(
fileData: data,
saveLocation: store.defaultDownloadDir
)
},
onSuccess: { (_: TransmissionTorrentAddOutcome) in },
onError: { message in
presentAddTorrentStoreError(detail: message, store: store)
}
)
} catch {
failures.append((url.lastPathComponent, error.localizedDescription))
}
Expand All @@ -155,7 +190,6 @@ struct BitDreamApp: App {
store.showGlobalAlert = true
}
}
#if os(macOS)
.sheet(isPresented: $store.showGlobalRenameDialog) {
// Resolve target torrent using the stored ID
if let targetId = store.globalRenameTargetId,
Expand All @@ -176,24 +210,25 @@ struct BitDreamApp: App {
store.showGlobalAlert = true
return
}
renameTorrentRoot(torrent: targetTorrent, to: newName, store: store) { error in
if let error = error {
store.globalAlertTitle = "Rename Error"
store.globalAlertMessage = error
store.showGlobalAlert = true
} else {
performTransmissionAction(
operation: { try await store.renameTorrentRoot(targetTorrent, to: newName) },
onSuccess: { (_: TorrentRenameResponseArgs) in
store.showGlobalRenameDialog = false
store.globalRenameInput = ""
store.globalRenameTargetId = nil
},
onError: { message in
store.globalAlertTitle = "Rename Error"
store.globalAlertMessage = message
store.showGlobalAlert = true
}
}
)
}
)
.frame(width: 420)
.padding()
}
}
#endif
}
.windowResizability(.contentSize)
.commands {
Expand All @@ -213,6 +248,9 @@ struct BitDreamApp: App {
)
}
.modelContainer(persistenceController.container)
}

var connectionInfoScene: some Scene {
WindowGroup("Connection Info", id: "connection-info") {
macOSConnectionInfoView()
.environmentObject(store)
Expand All @@ -223,7 +261,9 @@ struct BitDreamApp: App {
}
.windowResizability(.contentSize)
.modelContainer(persistenceController.container)
}

var statisticsScene: some Scene {
WindowGroup("Statistics", id: "statistics") {
macOSStatisticsView()
.environmentObject(store)
Expand All @@ -234,7 +274,9 @@ struct BitDreamApp: App {
}
.windowResizability(.contentSize)
.modelContainer(persistenceController.container)
}

var aboutScene: some Scene {
// About window - Using WindowGroup to prevent automatic Window menu entry
// This follows Apple's recommended pattern for auxiliary windows that shouldn't
// appear in the Window menu, as About windows are not user-managed utility windows
Expand All @@ -248,8 +290,19 @@ struct BitDreamApp: App {
.windowResizability(.contentSize)
.defaultPosition(.center)
.modelContainer(persistenceController.container)
}

#else
var settingsScene: some Scene {
Settings {
SettingsView(store: store) // Use the same store instance
.frame(minWidth: 500, idealWidth: 550, maxWidth: 650)
.environmentObject(appUpdater)
.environmentObject(themeManager) // Pass the ThemeManager to the Settings view
.immediateTheme(manager: themeManager)
}
}
#else
var iOSScene: some Scene {
WindowGroup {
ContentView()
.environmentObject(store) // Pass the shared store to the ContentView
Expand All @@ -268,18 +321,8 @@ struct BitDreamApp: App {
}
}
.modelContainer(persistenceController.container)
#endif

#if os(macOS)
Settings {
SettingsView(store: store) // Use the same store instance
.frame(minWidth: 500, idealWidth: 550, maxWidth: 650)
.environmentObject(appUpdater)
.environmentObject(themeManager) // Pass the ThemeManager to the Settings view
.immediateTheme(manager: themeManager)
}
#endif
}
#endif
}

// TODO(swiftdata-cutover): Remove this function entirely after the migration
Expand Down
13 changes: 12 additions & 1 deletion BitDream/Delegates/AppFileOpenDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,18 @@ final class AppFileOpenDelegate: NSObject, NSApplicationDelegate, ObservableObje
case .magnet(let magnetString):
store.enqueueMagnet(magnetString)
case .torrentData(let data):
addTorrentFromFileData(data, store: store)
performTransmissionAction(
operation: {
try await store.addTorrent(
fileData: data,
saveLocation: store.defaultDownloadDir
)
},
onSuccess: { (_: TransmissionTorrentAddOutcome) in },
onError: { message in
presentAddTorrentStoreError(detail: message, store: store)
}
)
}
}

Expand Down
Loading