Script sorting

This commit is contained in:
James Magahern
2020-08-14 16:44:39 -07:00
parent 69029a3195
commit 1d3d04ffdf

View File

@@ -98,9 +98,13 @@ class ScriptPolicyViewController: UIViewController, UICollectionViewDelegate
let listLayout = UICollectionViewCompositionalLayout.list(using: listConfig)
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: listLayout)
// Allowed scripts go to the top
let allowedScripts = loadedScripts.filter { policyManager.allowedOriginsForScriptResources().contains($0) }
// Make sure host origin goes first in the list.
let otherOriginScripts = loadedScripts.subtracting([ hostOrigin ])
let originItems = [ hostOrigin ] + otherOriginScripts
let otherOriginScripts = loadedScripts.subtracting([ hostOrigin ]).subtracting(allowedScripts)
let originItems = [ hostOrigin ] + allowedScripts + otherOriginScripts
let switchCellRegistry = UICollectionView.CellRegistration<SwitchListCell, String> { [unowned self] (listCell, indexPath, item) in
var config = listCell.defaultContentConfiguration()