Skip to content

Commit

Permalink
fix: update configs key to config
Browse files Browse the repository at this point in the history
  • Loading branch information
w3b6x9 committed Aug 18, 2022
1 parent 272e949 commit 126bff1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion example/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function Index() {
params: { apikey: token, vsndate: '2022' },
});

channel = socket.channel('any', { configs: { broadcast: { self: true } } })
channel = socket.channel('any', { config: { broadcast: { self: true } } })

channel
.on("postgres_changes", { event: "*", schema: "public" }, payload => {
Expand Down
10 changes: 5 additions & 5 deletions lib/realtime_web/channels/realtime_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ defmodule RealtimeWeb.RealtimeChannel do

is_new_api =
case params do
%{"configs" => _} -> true
%{"config" => _} -> true
_ -> false
end

pg_change_params =
if is_new_api do
send(self(), :sync_presence)

params["configs"]["postgres_changes"]
params["config"]["postgres_changes"]
|> case do
[_ | _] = params_list ->
params_list
Expand Down Expand Up @@ -138,7 +138,7 @@ defmodule RealtimeWeb.RealtimeChannel do
Logger.debug("Start channel, #{inspect(pg_change_params, pretty: true)}")

presence_key =
with key when is_binary(key) <- params["configs"]["presence"]["key"],
with key when is_binary(key) <- params["config"]["presence"]["key"],
true <- String.length(key) > 0 do
key
else
Expand All @@ -156,13 +156,13 @@ defmodule RealtimeWeb.RealtimeChannel do
},
assign(socket, %{
access_token: access_token,
ack_broadcast: !!params["configs"]["broadcast"]["ack"],
ack_broadcast: !!params["config"]["broadcast"]["ack"],
confirm_token_ref: confirm_token_ref,
is_new_api: is_new_api,
pg_sub_ref: pg_sub_ref,
pg_change_params: pg_change_params,
presence_key: presence_key,
self_broadcast: !!params["configs"]["broadcast"]["self"],
self_broadcast: !!params["config"]["broadcast"]["self"],
tenant_topic: tenant_topic
})}
else
Expand Down

0 comments on commit 126bff1

Please sign in to comment.