Rename track.visible -> track.public
This commit is contained in:
parent
13b6dd8691
commit
840ecc6d6f
|
@ -55,8 +55,12 @@ const schema = new mongoose.Schema(
|
|||
// A user-provided description of the track. May contain markdown.
|
||||
description: String,
|
||||
|
||||
// Whether this track is visible in the public track list or not.
|
||||
visible: Boolean,
|
||||
// Whether this track is visible (anonymized) in the public track list or not.
|
||||
public: { type: Boolean, default: false },
|
||||
|
||||
// Whether this track should be exported to the public track database
|
||||
// (after anonymization).
|
||||
includeInPublicDatabase: { type: Boolean, default: false },
|
||||
|
||||
// The user agent string, or a part thereof, that was used to upload this
|
||||
// track. Usually contains only the OBS version, other user agents are
|
||||
|
@ -142,7 +146,7 @@ class Track extends mongoose.Model {
|
|||
}
|
||||
|
||||
isVisibleTo(user) {
|
||||
if (this.visible) {
|
||||
if (this.public) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -250,7 +254,7 @@ class Track extends mongoose.Model {
|
|||
description: this.description,
|
||||
createdAt: this.createdAt,
|
||||
updatedAt: this.updatedAt,
|
||||
visible: this.visible,
|
||||
public: this.public,
|
||||
author: this.author.toProfileJSONFor(user),
|
||||
statistics: this.statistics,
|
||||
processingStatus: this.processingStatus,
|
||||
|
|
|
@ -11,7 +11,7 @@ router.get(
|
|||
'/',
|
||||
wrapRoute(async (req, res) => {
|
||||
const trackCount = await Track.find().count();
|
||||
const publicTrackCount = await Track.find({ visible: true }).count();
|
||||
const publicTrackCount = await Track.find({ public: true }).count();
|
||||
const userCount = await User.find().count();
|
||||
|
||||
const [{ trackLength, numEvents, trackDuration }] = await Track.aggregate([
|
||||
|
|
|
@ -57,7 +57,7 @@ router.get(
|
|||
'/',
|
||||
auth.optional,
|
||||
wrapRoute(async (req, res) => {
|
||||
const query = { visible: true };
|
||||
const query = { public: true };
|
||||
let limit = 20;
|
||||
let offset = 0;
|
||||
|
||||
|
@ -183,12 +183,12 @@ router.post(
|
|||
// TODO: Stream into temporary file, then move it later.
|
||||
const { body, fileInfo } = await getMultipartOrJsonBody(req, (body) => body.track);
|
||||
|
||||
const { body: fileBody, visible, ...trackBody } = body
|
||||
const { body: fileBody, public, ...trackBody } = body
|
||||
|
||||
const track = new Track({
|
||||
...trackBody,
|
||||
author: req.user,
|
||||
visible: visible == null ? req.user.areTracksVisibleForAll : Boolean(trackBody.visible)
|
||||
public: public == null ? req.user.areTracksVisibleForAll : Boolean(trackBody.public)
|
||||
})
|
||||
track.customizedTitle = track.title != null
|
||||
track.slugify();
|
||||
|
@ -249,10 +249,10 @@ router.put(
|
|||
|
||||
let process = false
|
||||
|
||||
if (trackBody.visible != null) {
|
||||
const visible = Boolean(trackBody.visible);
|
||||
process |= visible !== track.visible
|
||||
track.visible = visible
|
||||
if (trackBody.public != null) {
|
||||
const public = Boolean(trackBody.public);
|
||||
process |= public !== track.public
|
||||
track.public = public
|
||||
}
|
||||
|
||||
if (fileBody) {
|
||||
|
|
|
@ -114,13 +114,13 @@ const TrackEditor = connect((state) => ({login: state.login}))(function TrackEdi
|
|||
<Form.Field>
|
||||
<label>Visibility</label>
|
||||
<Controller
|
||||
name="visible"
|
||||
name="public"
|
||||
control={control}
|
||||
defaultValue={track?.visible}
|
||||
defaultValue={track?.public}
|
||||
render={(props) => (
|
||||
<Checkbox
|
||||
name="visible"
|
||||
label="Make track visible in public track list"
|
||||
name="public"
|
||||
label="Make track public (in track list and details page)"
|
||||
checked={props.value}
|
||||
onChange={(_, {checked}) => props.onChange(checked)}
|
||||
/>
|
||||
|
|
|
@ -11,10 +11,10 @@ function formatDuration(seconds) {
|
|||
export default function TrackDetails({track, isAuthor}) {
|
||||
return (
|
||||
<List>
|
||||
{track.visible != null && isAuthor && (
|
||||
{track.public != null && isAuthor && (
|
||||
<List.Item>
|
||||
<List.Header>Visibility</List.Header>
|
||||
{track.visible ? 'Public' : 'Private'}
|
||||
{track.public ? 'Public' : 'Private'}
|
||||
</List.Item>
|
||||
)}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ export function TrackListItem({track, privateTracks = false}) {
|
|||
</Item.Description>
|
||||
{privateTracks && (
|
||||
<Item.Extra>
|
||||
{track.visible ? (
|
||||
{track.public ? (
|
||||
<>
|
||||
<Icon color="blue" name="eye" fitted /> Public
|
||||
</>
|
||||
|
|
|
@ -24,7 +24,7 @@ export type Track = {
|
|||
title: string
|
||||
description?: string
|
||||
createdAt: string
|
||||
visible?: boolean
|
||||
public?: boolean
|
||||
statistics?: TrackStatistics
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue