Skip to content

Commit

Permalink
feat: only show visible devices on main downloads page
Browse files Browse the repository at this point in the history
Closes #346
  • Loading branch information
ericswpark committed Feb 9, 2024
1 parent 5d21de4 commit 160212e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion server/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/downloads/templates/downloads_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<div id="root"></div>

{{ active_devices|json_script:'active-devices' }}
{{ active_visible_devices|json_script:'active-visible-devices' }}
<script src="{% static 'downloads-main.bundle.js' %}?cachebust={% now 'U' %}"></script>
<!-- TODO: Remove cache-busting tag once main page is stable! -->
{% endblock %}
8 changes: 4 additions & 4 deletions server/downloads/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class DownloadsMainView(TemplateView):
template_name = "downloads_main.html"

def get_context_data(self, **kwargs):
active_devices = [
active_visible_devices = [
device
for device in Device.objects.all()
if device.has_enabled_hashed_builds()
if device.has_enabled_hashed_builds() and device.visible
]
return {
"active_devices": [
"active_visible_devices": [
{
"codename": device.codename,
"enabled": device.status,
Expand All @@ -31,7 +31,7 @@ def get_context_data(self, **kwargs):
"downloads_device", kwargs={"codename": device.codename}
),
}
for device in active_devices
for device in active_visible_devices
]
}

Expand Down
8 changes: 4 additions & 4 deletions server/frontend/downloads-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Fuse from "fuse.js";

const root = createRoot(document.getElementById("root"));

const ACTIVE_DEVICES = JSON.parse(
document.getElementById("active-devices").textContent,
const ACTIVE_VISIBLE_DEVICES = JSON.parse(
document.getElementById("active-visible-devices").textContent,
);

function App() {
Expand Down Expand Up @@ -39,12 +39,12 @@ function DownloadList({ filter }) {

if (filter) {
// Fuzzy search through all devices
filtered_devices = new Fuse(ACTIVE_DEVICES, {keys: ['name']}).search(filter);
filtered_devices = new Fuse(ACTIVE_VISIBLE_DEVICES, {keys: ['name']}).search(filter);

// Map results returned from Fuse.js to remove item enclosing
filtered_devices = filtered_devices.map((result) => result.item)
} else {
filtered_devices = ACTIVE_DEVICES;
filtered_devices = ACTIVE_VISIBLE_DEVICES;
}

function sortActive(a, b) {
Expand Down

0 comments on commit 160212e

Please sign in to comment.