Skip to content

Commit 4cd3ecf

Browse files
committed
frontend: CollectionPage: don't try to pass ViewType.Auto in URL (was an error)
1 parent 2c26fa9 commit 4cd3ecf

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

frontend/pages/CollectionPage.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import * as React from 'react';
5656
import { browseUrl, collectionUrl } from 'generated/frontend_uiroutes';
5757

5858
enum ViewType {
59-
Auto = 'auto',
59+
Auto = 'auto', // not broadcasted in URL
6060
Thumb = 'thumb',
6161
List = 'list',
6262
}
@@ -162,7 +162,7 @@ export default class CollectionPage extends React.Component<
162162
id: coll.Id,
163163
rev: changeset.Id,
164164
path: this.props.pathBase64,
165-
view: this.props.view,
165+
view: viewTypeToString(this.props.view),
166166
})}>
167167
{changeset.Id}
168168
</a>
@@ -179,6 +179,7 @@ export default class CollectionPage extends React.Component<
179179
const metadataKv = metadataKvsToKv(coll.Metadata);
180180

181181
const dirInheritedType = directoryInheritedType(directoryOutput);
182+
// TODO: lint
182183
const imdbIdExpectedButMissing =
183184
dirInheritedType === DirectoryType.Movies && !(MetadataImdbId in metadataKv);
184185

@@ -397,7 +398,7 @@ export default class CollectionPage extends React.Component<
397398
id: this.props.id,
398399
rev: this.props.rev,
399400
path: btoa(subDir),
400-
view: this.props.view,
401+
view: viewTypeToString(this.props.view),
401402
})}>
402403
{filenameFromPath(subDir)}/
403404
</a>
@@ -592,7 +593,7 @@ export default class CollectionPage extends React.Component<
592593
id: this.props.id,
593594
rev: this.props.rev,
594595
path: btoa(pd),
595-
view: this.props.view,
596+
view: viewTypeToString(this.props.view),
596597
}),
597598
};
598599
};
@@ -617,7 +618,7 @@ export default class CollectionPage extends React.Component<
617618
url: collectionUrl({
618619
id: this.props.id,
619620
rev: this.props.rev,
620-
view: this.props.view,
621+
view: viewTypeToString(this.props.view),
621622
}),
622623
});
623624
}
@@ -764,6 +765,11 @@ function makeThumbPath(sha256: string): string {
764765
return '.sto/thumb/' + sha256.substr(0, 10) + '.jpg';
765766
}
766767

768+
// for prettiness' sake, ViewType=auto is not passed around in the URL
769+
function viewTypeToString(viewType: ViewType): string | undefined {
770+
return viewType !== ViewType.Auto ? viewType : undefined;
771+
}
772+
767773
// this is needed until we can pass enums in URL parameters
768774
export function viewTypeFromString(str: string | undefined): ViewType {
769775
switch (str) {

0 commit comments

Comments
 (0)