WIP: search artifact hit opens the viewer (run #231)
This commit is contained in:
@@ -38,9 +38,14 @@ String artifactVisitIdentityOf(ArtifactGroup group, ArtifactRecord artifact) {
|
||||
/// The artifacts the viewer can page through, in gallery order: group by group,
|
||||
/// each group's images, videos and markdown/text documents in recorded order,
|
||||
/// then the visit's recorded turn documents that open in the renderer. A session
|
||||
/// export is external-only and never enters the page list. Pure: it only filters
|
||||
/// and orders records the gallery already holds.
|
||||
List<PagedArtifact> pagedArtifacts(List<ArtifactGroup> groups) {
|
||||
/// export is external-only and never enters the page list unless
|
||||
/// [includeExternalDocuments] is requested by a search result, which must still
|
||||
/// land on the exact recorded document in the full-screen viewer. Pure: it only
|
||||
/// filters and orders records the gallery already holds.
|
||||
List<PagedArtifact> pagedArtifacts(
|
||||
List<ArtifactGroup> groups, {
|
||||
bool includeExternalDocuments = false,
|
||||
}) {
|
||||
final pages = <PagedArtifact>[];
|
||||
void add(ArtifactGroup group, ArtifactRecord artifact) {
|
||||
pages.add(
|
||||
@@ -55,7 +60,10 @@ List<PagedArtifact> pagedArtifacts(List<ArtifactGroup> groups) {
|
||||
}
|
||||
for (final document in group.documents) {
|
||||
final artifact = document.record;
|
||||
if (artifact == null || !document.opensInViewer) continue;
|
||||
if (artifact == null ||
|
||||
(!document.opensInViewer && !includeExternalDocuments)) {
|
||||
continue;
|
||||
}
|
||||
add(group, artifact);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class ArtifactViewerPage extends StatefulWidget {
|
||||
super.key,
|
||||
required this.groups,
|
||||
required this.selectedIdentity,
|
||||
this.includeExternalDocuments = false,
|
||||
this.configuredEndpoint = '',
|
||||
this.fetch = fetchArtifact,
|
||||
this.markdownBuilder = defaultArtifactMarkdown,
|
||||
@@ -53,6 +54,10 @@ class ArtifactViewerPage extends StatefulWidget {
|
||||
/// [artifactVisitIdentityOf] of the row the operator selected.
|
||||
final String selectedIdentity;
|
||||
|
||||
/// Search can select a turn document that is hidden from the normal gallery,
|
||||
/// including the external-only session export.
|
||||
final bool includeExternalDocuments;
|
||||
|
||||
final String configuredEndpoint;
|
||||
final ArtifactFetch fetch;
|
||||
final ArtifactMarkdownBuilder markdownBuilder;
|
||||
@@ -71,7 +76,10 @@ class _FetchedPreview {
|
||||
}
|
||||
|
||||
class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
late final List<PagedArtifact> _pages = pagedArtifacts(widget.groups);
|
||||
late final List<PagedArtifact> _pages = pagedArtifacts(
|
||||
widget.groups,
|
||||
includeExternalDocuments: widget.includeExternalDocuments,
|
||||
);
|
||||
final Map<String, _FetchedPreview> _cache = <String, _FetchedPreview>{};
|
||||
late int _index = _initialIndex();
|
||||
int _generation = 0;
|
||||
|
||||
Reference in New Issue
Block a user