Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Credit Count Bug #1167

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions lib/animina/genservers/profileview_credits.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule Animina.GenServers.ProfileViewCredits do
use GenServer
alias Animina.Accounts.User
alias Phoenix.PubSub

@moduledoc """
@@ -50,22 +51,14 @@ defmodule Animina.GenServers.ProfileViewCredits do
end
end

def get_updated_credit_for_current_user(current_user, credits) do
case Enum.find(credits, fn credit ->
credit["user_id"] == current_user.id
end) do
nil -> current_user.credit_points
credit -> credit["points"]
end
def get_updated_credit_for_current_user(current_user, _credits) do
{:ok, user} = User.by_id(current_user.id)
user.credit_points
end

def get_updated_credit_for_user_profile(user_profile, credits) do
case Enum.find(credits, fn credit ->
credit["user_id"] == user_profile.id
end) do
nil -> user_profile.credit_points
credit -> credit["points"]
end
def get_updated_credit_for_user_profile(user_profile, _credits) do
{:ok, user} = User.by_id(user_profile.id)
user.credit_points
end

@impl true
Loading