Skip to content

Commit 17c0bb9

Browse files
committed
Use 0 as base stream time unless stream producer reconnected
1 parent db687a8 commit 17c0bb9

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/asciinema/streaming/stream_server.ex

+5-8
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ defmodule Asciinema.Streaming.StreamServer do
6767
vt_size: nil,
6868
theme: nil,
6969
last_event_id: 0,
70-
base_stream_time: nil,
70+
base_stream_time: 0,
7171
last_stream_time: nil,
7272
last_event_time: nil,
7373
user_agent: nil,
@@ -262,8 +262,8 @@ defmodule Asciinema.Streaming.StreamServer do
262262
defp via_tuple(stream_id),
263263
do: {:via, Horde.Registry, {Asciinema.Streaming.StreamRegistry, stream_id}}
264264

265-
defp update_base_stream_time(state, last_event_id, time) do
266-
if in_sync?(state, last_event_id) do
265+
defp update_base_stream_time(state, client_last_event_id, time) do
266+
if client_last_event_id == state.last_event_id do
267267
state
268268
else
269269
%{state | base_stream_time: time}
@@ -298,8 +298,8 @@ defmodule Asciinema.Streaming.StreamServer do
298298
%{state | vt: vt, vt_size: {cols, rows}}
299299
end
300300

301-
defp restart_recording(state, last_event_id, cols, rows, term_init, theme, query) do
302-
if in_sync?(state, last_event_id) do
301+
defp restart_recording(state, client_last_event_id, cols, rows, term_init, theme, query) do
302+
if client_last_event_id == state.last_event_id and client_last_event_id != 0 do
303303
state
304304
else
305305
state
@@ -387,9 +387,6 @@ defmodule Asciinema.Streaming.StreamServer do
387387
|> Enum.into(%{})
388388
end
389389

390-
defp in_sync?(state, last_event_id),
391-
do: last_event_id != 0 and last_event_id == state.last_event_id
392-
393390
defp serialize_time(time) do
394391
whole = div(time, 1_000_000)
395392

0 commit comments

Comments
 (0)