From 35bd1de5ba9329bb2654249439b51b33ab2c94f1 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Mon, 11 Apr 2022 06:56:53 -0500 Subject: [PATCH] limit send to plus where appropriate (#3080) --- web/src/routes/Events.jsx | 56 ++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/web/src/routes/Events.jsx b/web/src/routes/Events.jsx index 84937a2a3..4c8423210 100644 --- a/web/src/routes/Events.jsx +++ b/web/src/routes/Events.jsx @@ -53,7 +53,12 @@ export default function Events({ path, ...props }) { }); const [uploading, setUploading] = useState([]); const [viewEvent, setViewEvent] = useState(); - const [downloadEvent, setDownloadEvent] = useState({ id: null, has_clip: false, has_snapshot: false }); + const [downloadEvent, setDownloadEvent] = useState({ + id: null, + has_clip: false, + has_snapshot: false, + plus_id: undefined, + }); const eventsFetcher = useCallback((path, params) => { params = { ...params, include_thumbnails: 0, limit: API_LIMIT }; @@ -123,7 +128,12 @@ export default function Events({ path, ...props }) { const onDownloadClick = (e, event) => { e.stopPropagation(); - setDownloadEvent((_prev) => ({ id: event.id, has_clip: event.has_clip, has_snapshot: event.has_snapshot })); + setDownloadEvent((_prev) => ({ + id: event.id, + has_clip: event.has_clip, + has_snapshot: event.has_snapshot, + plus_id: event.plus_id, + })); downloadButton.current = e.target; setState({ ...state, showDownloadMenu: true }); }; @@ -177,6 +187,10 @@ export default function Events({ path, ...props }) { e.stopPropagation(); } + if (uploading.includes(id)) { + return; + } + if (!config.plus.enabled) { setState({ ...state, showDownloadMenu: false, showPlusConfig: true }); return; @@ -202,6 +216,10 @@ export default function Events({ path, ...props }) { } setUploading((prev) => prev.filter((i) => i !== id)); + + if (state.showDownloadMenu && downloadEvent.id === id) { + setState({ ...state, showDownloadMenu: false }); + } }; if (!config) { @@ -278,11 +296,19 @@ export default function Events({ path, ...props }) { {downloadEvent.has_snapshot && !downloadEvent.plus_id && ( onSendToPlus(downloadEvent.id)} /> )} + {downloadEvent.plus_id && ( + setState({ ...state, showDownloadMenu: false })} + /> + )} )} {state.showDatePicker && ( @@ -398,16 +424,20 @@ export default function Events({ path, ...props }) {