 			picker.show(relativeTo: (self.shareButton?.bounds)!, of: self.shareButton!, preferredEdge: .maxY)
 		}
 	}
-
-	// load the images into the popup
-	func adjustImagePopup() {
-		imagePopup?.removeAllItems()
-		guard let images = allImages?.value, images.count > 0 else { return }
-		var currentBatch = images[0].batchId
-		for anImage in images {
-			if anImage.batchId != currentBatch {
-				imagePopup?.menu?.addItem(NSMenuItem.separator())
-				currentBatch = anImage.batchId
-			}
-			let item = NSMenuItem(title: anImage.name, action: #selector(selectImage(_:)), keyEquivalent: "")
-			item.tag = anImage.id
-			item.target = self
-			item.toolTip = anImage.name
-			item.representedObject = anImage
-			imagePopup?.menu?.addItem(item)
-		}
-	}
-	
-	@objc func selectImage(_ sender: Any?) {
+	
+	@IBAction func selectImage(_ sender: Any?) {
 		guard let menuItem = sender as? NSMenuItem, let image = menuItem.representedObject as? SessionImage else { return }
 		display(image: image)
 	}
-	
+}
+
+// MARK: - NSPageControllerDelegate
+extension ImageOutputController: NSPageControllerDelegate {
 	func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, sharingServicesForItems items: [Any], proposedSharingServices proposedServices: [NSSharingService]) -> [NSSharingService]
 	{
 		return myShareServices + proposedServices

	}
}

class ImageViewController: NSViewController {
	var didAddConstraints = false
	var imageLoadDisposable: Disposable?

	fileprivate let emptyObject: Any = 1 as Any
	var selectedImageId: Int { return selectedImage?.id ?? 0 }
	
	// MARK: - methods
	override func viewDidLoad() {
		super.viewDidLoad()
		pageController = NSPageController()
