Allow to change language

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-06-16 18:00:27 +02:00
parent 08b4fb9b08
commit 5cb3f478ae
8 changed files with 110 additions and 9 deletions

View File

@@ -477,4 +477,13 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
{:error, "Error while saving user setting"}
end
end
def update_locale(_parent, %{locale: locale}, %{
context: %{current_user: %User{id: logged_user_id, locale: current_locale} = user}
}) do
with true == current_locale != locale,
{:ok, %User{} = updated_user} <- Users.update_user(user, %{locale: locale}) do
{:ok, updated_user}
end
end
end