Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions ownCloud/Settings/AutoUploadSettingsSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ class AutoUploadSettingsSection: SettingsSection {
updateDynamicUI()
}
}

NotificationCenter.default.post(name: .OCBookmarkManagerListChanged, object: nil)
}

private func setupVideoAutoUpload(enabled:Bool) {
Expand All @@ -226,6 +228,8 @@ class AutoUploadSettingsSection: SettingsSection {
updateDynamicUI()
}
}

NotificationCenter.default.post(name: .OCBookmarkManagerListChanged, object: nil)
}

private func getSelectedBookmark(for mediaType:MediaType) -> OCBookmark? {
Expand Down
18 changes: 13 additions & 5 deletions ownCloud/Settings/MediaUploadSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class MediaUploadSettingsViewController: StaticTableViewController {

@objc private func reconsiderSections() {
OnMainThread {
guard let proSettingsSection = self.proPhotoSettingsSection else { return }
guard let proSettingsSection = self.proPhotoSettingsSection, let userDefaults = OCAppIdentity.shared.userDefaults else { return }

if OCBookmarkManager.shared.bookmarks.count > 0, let userDefaults = OCAppIdentity.shared.userDefaults {
if OCBookmarkManager.shared.bookmarks.count > 0 {
if self.autoUploadSection == nil {
self.autoUploadSection = AutoUploadSettingsSection(userDefaults: userDefaults)

Expand All @@ -66,15 +66,23 @@ class MediaUploadSettingsViewController: StaticTableViewController {
if let autoUploadSection = self.autoUploadSection, !autoUploadSection.attached {
self.addSection(autoUploadSection)
}
if let backgroundUploadsSection = self.backgroundUploadsSection, backgroundUploadsSection.rows.count > 0, !backgroundUploadsSection.attached {
self.addSection(backgroundUploadsSection)
if let backgroundUploadsSection = self.backgroundUploadsSection {
if !backgroundUploadsSection.attached, backgroundUploadsSection.rows.count > 0, (userDefaults.instantUploadPhotos || userDefaults.instantUploadVideos) {
if let autoUploadSection = self.autoUploadSection, let index = self.indexForSection(autoUploadSection) {
self.insertSection(backgroundUploadsSection, at: (index + 1), animated: true)
} else {
self.addSection(backgroundUploadsSection)
}
} else if !userDefaults.instantUploadPhotos, !userDefaults.instantUploadVideos {
self.removeSection(backgroundUploadsSection, animated: true)
}
}
} else {
if let autoUploadSection = self.autoUploadSection, autoUploadSection.attached {
self.removeSection(autoUploadSection)
self.autoUploadSection = nil
}
if let backgroundUploadsSection = self.backgroundUploadsSection, backgroundUploadsSection.attached {
if let backgroundUploadsSection = self.backgroundUploadsSection, backgroundUploadsSection.attached, !userDefaults.instantUploadPhotos, !userDefaults.instantUploadVideos {
self.removeSection(backgroundUploadsSection)
self.backgroundUploadsSection = nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ open class StaticTableViewController: UITableViewController, Themeable {
return nil
}

open func indexForSection(_ inSection: StaticTableViewSection) -> Int? {
return sections.index(of: inSection)
}

// MARK: - View Controller
override open func viewDidLoad() {
super.viewDidLoad()
Expand Down