Skip to content

Additional Event Firing Fix #1

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

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 7 additions & 2 deletions firebase_admin/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def __init__(self, url, stream_handler, build_headers, stream_id):
self.stream_id = stream_id
self.sse = None
self.thread = None
self.last_value = None
self.start()

def make_session(self):
Expand All @@ -134,7 +135,11 @@ def start_stream(self):
msg_data["event"] = msg.event
if self.stream_id:
msg_data["stream_id"] = self.stream_id
self.stream_handler(msg_data)
if not self.last_value:
self.last_value = msg_data["data"]
if msg_data["data"] != self.last_value:
self.last_value = msg_data["data"]
self.stream_handler(msg_data)

def close(self):
while not self.sse and not hasattr(self.sse, 'resp'):
Expand Down Expand Up @@ -818,4 +823,4 @@ def _extract_error_message(self, error):
return '{0}\nReason: {1}'.format(error, data.get('error', 'unknown'))
except ValueError:
pass
return '{0}\nReason: {1}'.format(error, error.response.content.decode())
return '{0}\nReason: {1}'.format(error, error.response.content.decode())