Skip to content

Commit

Permalink
fix(common): remove user location on online status
Browse files Browse the repository at this point in the history
  • Loading branch information
trueChazza committed Jan 29, 2022
1 parent ed83616 commit 25444d8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 29 deletions.
19 changes: 2 additions & 17 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,7 @@ let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("
topbar.config({barColors: {0: "#6366f1"}, shadowColor: "rgba(0, 0, 0, .3)"})

window.addEventListener("phx:page-loading-start", info => topbar.show())
window.addEventListener("phx:page-loading-stop", info => {
if (info.detail.kind === 'initial') {
channel.push('shout', { user_id: window.userId, page_title: document.title })
}

topbar.hide()
})

channel.on("shout", message => {
const element = document.querySelector(`#current-location-${ message.user_id }`)

if(element) {
element.innerHTML = message.page_title
}
})
window.addEventListener("phx:page-loading-stop", info => topbar.hide())

presence.onSync(() => {
let presences = []
Expand Down Expand Up @@ -57,8 +43,7 @@ presence.onSync(() => {
<span class="bg-green-400 absolute top-0 right-0 block h-2.5 w-2.5 rounded-full ring-2 ring-white" aria-hidden="true"></span>
</span>
<div class="ml-4 truncate">
<p class="text-sm font-medium text-gray-900 truncate">${ item.user_name }</p>
<p id="current-location-${ item.user_id }" class="text-sm text-gray-500 truncate">${ item.page_title }</p>
<p class="text-sm text-gray-900 truncate">${ item.user_name }</p>
</div>
</div>
</div>
Expand Down
12 changes: 2 additions & 10 deletions lib/media_server_web/live/movies_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,17 @@
<div class="lg:col-span-3">
<div class="md:flex md:items-center md:justify-between">
<div class="flex-1 min-w-0">

<h2 class="text-2xl font-bold leading-7 text-gray-900 sm:text-3xl sm:truncate">
<%= @decoded["title"] %>
</h2>

<p><%= @decoded["year"] %> - <%= @decoded["runtime"] %> minutes</p>
</div>
<div class="mt-4 flex md:mt-0 md:ml-4">
<%= if @decoded["hasFile"] do %>

<button phx-click="play" phx-value-movie={@decoded["id"]} type="button" class="ml-3 inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Play
</button>

<% else %>

<button type="button" class="cursor-not-allowed ml-3 inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-gray-400 focus:outline-none">
Play
</button>

<% end %>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/media_server_web/templates/layout/root.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
window.userName = "<%= assigns[:current_user].name %>";
</script>
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
<script defer phx-track-static type="text/javascript" src={Routes.static_path(@conn, "/assets/app.js?id=8")}></script>
<script defer phx-track-static type="text/javascript" src={Routes.static_path(@conn, "/assets/app.js?id=9")}></script>
<% end %>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion lib/media_server_web/templates/watch/watch.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
window.userEmail = "<%= assigns[:current_user].email %>";
window.userName = "<%= assigns[:current_user].name %>";
</script>
<script defer phx-track-static type="text/javascript" src={Routes.static_path(@conn, "/assets/app.js?id=8")}></script>
<script defer phx-track-static type="text/javascript" src={Routes.static_path(@conn, "/assets/app.js?id=9")}></script>
<% end %>
</head>
<body>
Expand Down

0 comments on commit 25444d8

Please sign in to comment.