Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Fix sites list for needs to upgrade condition check (#4758)

Adrian Gruntkowski7ff1a16ae31e
diff --git a/lib/plausible_web/live/sites.ex b/lib/plausible_web/live/sites.ex
index cdf61a06a4..93417f14f3 100644
--- a/lib/plausible_web/live/sites.ex
+++ b/lib/plausible_web/live/sites.ex
@@ -35,7 +35,7 @@ defmodule PlausibleWeb.Live.Sites do
|> assign_new(:needs_to_upgrade, fn %{current_user: current_user, sites: sites} ->
user_owns_sites =
Enum.any?(sites.entries, fn site ->
- List.first(site.invitations).role == :owner
+ length(site.invitations) > 0 && List.first(site.invitations).role == :owner
end) ||
Auth.user_owns_sites?(current_user)