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

Issue 389 sync #405

Merged
merged 8 commits into from
Jun 6, 2019
Merged

Issue 389 sync #405

merged 8 commits into from
Jun 6, 2019

Conversation

sssoleileraaa
Copy link
Contributor

@sssoleileraaa sssoleileraaa commented Jun 6, 2019

Description

Resolves #389

  • Message sync (download+decrypt) now occurs whenever there is a metadata sync with the server instead of every 5 seconds checking if there are new messages.
  • We now use the queue to download and decrypt messages in a job called MessageDownloadJob

Test Plan

  • Send messages from source interface and make sure message sync still occurs whenever there is a metadata download. Trigger this by clicking the Refresh icon.

Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one substantive comment - this is looking great !


logger = logging.getLogger(__name__)


class DownloadSubmissionJob(ApiJob):
class MessageDownloadJob(ApiJob):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the plan still to inherit from a new common object to reduce code duplication with FileDownloadJob?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! That's the plan: MessageDownloadJob, FileDownloadJob, and ReplyDownloadJob will all inherit from a DownloadJob class. I tried to keep the _decrypt_file method generic enough so that we can move it into DownloadJob. There should be a follow-up PR for this.

I just wanted to keep code changes small here since deleting the message_sync thread felt like a big change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filed #406 for this

class DownloadSubmissionJob(ApiJob):
class MessageDownloadJob(ApiJob):

CHUNK_SIZE = 4096
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(unused)

job.success_signal.connect(self.on_message_download_success, type=Qt.QueuedConnection)
job.failure_signal.connect(self.on_message_download_failure, type=Qt.QueuedConnection)

self.api_job_queue.enqueue(job)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff lgtm and works as advertised! 🥇

@redshiftzero redshiftzero merged commit 17dfb00 into master Jun 6, 2019
@redshiftzero redshiftzero deleted the issue-389-sync branch June 6, 2019 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace MessageSync with DownloadMessageJob
2 participants