 
 
     var filteredIncidentsCache: FilteredIncidentsCache {
-        if let cache = _filteredIncidentsCache {
-            if cache.searchText == searchText {
-                return cache
-            }
-        }
-
-        var filteredAllIncidents   : [Incident] = []
-        var filteredOpenIncidents  : [Incident] = []
-        var filteredActiveIncidents: [Incident] = []
-
-        for incident in sortedIncidents {
-            filteredAllIncidents.append(incident)
-
-            if incident.state != IncidentState.Closed {
-                filteredOpenIncidents.append(incident)
-
-                if incident.state != IncidentState.OnHold {
-                    filteredActiveIncidents.append(incident)
+        if _filteredIncidentsCache == nil {
+            var filteredAllIncidents   : [Incident] = []
+            var filteredOpenIncidents  : [Incident] = []
+            var filteredActiveIncidents: [Incident] = []
+
+            for incident in sortedIncidents {
+                filteredAllIncidents.append(incident)
+
+                if incident.state != IncidentState.Closed {
+                    filteredOpenIncidents.append(incident)
+
+                    if incident.state != IncidentState.OnHold {
+                        filteredActiveIncidents.append(incident)
+                    }
                 }
             }
-        }
-
-        _filteredIncidentsCache = FilteredIncidentsCache(
+
+            _filteredIncidentsCache = FilteredIncidentsCache(
+                allIncidents: filteredAllIncidents,
+                openIncidents: filteredOpenIncidents,
+                activeIncidents: filteredActiveIncidents
+            )
+        }
+        return _filteredIncidentsCache!
+    }
+    private var _filteredIncidentsCache: FilteredIncidentsCache? = nil
+
+    
+    var viewableIncidents: [Incident] {
+        guard let stateFilterPopUp = stateFilterPopUp else {
+            logError("No state filter popup?")
+            return []
+        }
+        
+        let selected = stateFilterPopUp.selectedTag()
+        
+        guard let filterTag = StateFilterTag(rawValue: selected) else {
+            logError("Unknown filter tag: \(selected)")
+            return []
+        }
+        
+        let filteredIncidents: [Incident]
+        
+        switch filterTag {
+        case .All   : filteredIncidents = filteredIncidentsCache.allIncidents
+        case .Open  : filteredIncidents = filteredIncidentsCache.openIncidents
+        case .Active: filteredIncidents = filteredIncidentsCache.activeIncidents
+        }
+        
+        let searchText = self.searchText
+        
+        if searchText.characters.count == 0 { return filteredIncidents; }
+        
+        if let cache = _viewableIncidentsCache {
+            if cache.searchText == searchText && cache.filterTag == filterTag {
+                return cache.incidents
+            }
+        }
+        
+        let incidents = searchIncidents(incidents: filteredIncidents, searchText: searchText)
+
+        _viewableIncidentsCache = ViewableIncidentsCache(
             searchText: searchText,
-            allIncidents: filteredAllIncidents,
-            openIncidents: filteredOpenIncidents,
-            activeIncidents: filteredActiveIncidents
+            filterTag: filterTag,
+            incidents: incidents
         )
         
-        return _filteredIncidentsCache!
-    }
-    private var _filteredIncidentsCache: FilteredIncidentsCache? = nil
+        return incidents
+    }
+    private var _viewableIncidentsCache: ViewableIncidentsCache?
 
 
     convenience init(appDelegate: AppDelegate) {



struct FilteredIncidentsCache {
    let searchText: String
    let allIncidents: [Incident]
    let openIncidents: [Incident]
    let activeIncidents: [Incident]
}



    }


    @IBAction func updateViewedIncidents(sender: AnyObject?) {
        if let dispatchTable = self.dispatchTable {
            // Make sure UI stuff goes to the main thread
