Skip to content

issue 5747 refactor content scripts for Thunderbird - #5748

Merged
tomholub merged 11 commits into
masterfrom
issue-5747-thunderbird-refactor
May 29, 2024
Merged

tomholub merged 11 commits into
masterfrom
issue-5747-thunderbird-refactor

Conversation

@tomholub

@tomholub tomholub commented May 28, 2024

Copy link
Copy Markdown
Collaborator

This PR attempts to clean up content script code and make it easier to add another environment (like another webmail, or Thunderbird)

Further, test logging output was cleaned up a bit, and debug html files are uploaded to artifacts again.

close #5747
issue #5396


Tests (delete all except exactly one):

  • Does not need tests (refactor only, docs or internal changes)

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities
  • is documented clearly and usefully, or doesn't need documentation

@tomholub tomholub changed the title issue 5747 initial refactor issue 5747 refactor content scripts for Thunderbird May 28, 2024

@tomholub tomholub left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's a pure refactor, moving code around. I still find it messy but I think it's an improvement, and it's clearer now how another UI implementation may be added.

@tomholub

tomholub commented May 28, 2024

Copy link
Copy Markdown
Collaborator Author

After this PR, Thunderbird could be added like so:

Catch.try(async () => {
+if(this is thunderbird) {
+  await new ThunderbirdWebmailStartup().asyncConstructor();
+} else {
  await new GmailWebmailStartup().asyncConstructor();
+}
})();
// content_scripts/webmail/thunderbird/thunderbird-webmail-startup.ts

export class ThunderbirdWebmailStartup {
  private replacePgpElsInterval: number;
  private replacer: GmailElementReplacer;

  public asyncConstructor = async () => {
    await contentScriptSetupIfVacant({
      name: 'thunderbird',
      variant: undefined,
      getUserAccountEmail: () => undefined, // todo, but can start with undefined
      getUserFullName: () => undefined // todo, but can start with undefined
      getReplacer: () => new ThunderbirdElementReplacer(), // todo - add this class empty, methods do nothing
      start: this.start
    });
  }

    private start = async (
      acctEmail: string,
      clientConfiguration: ClientConfiguration,
      injector: Injector,
      notifications: Notifications,
      factory: XssSafeFactory,
      relayManager: RelayManager
    ) => {
      // injector.btns(); // todo in another issue - add compose button
      this.replacer.runIntervalFunctionsPeriodically();
      await notifications.showInitial(acctEmail);
      await notifications.show('FlowCrypt Thunderbird support is still in early development, and not expected to function properly yet. Support will be gradually added in upcoming versions.');
    }
  };
};

@tomholub
tomholub marked this pull request as ready for review May 28, 2024 15:38
@tomholub
tomholub requested a review from sosnovsky as a code owner May 28, 2024 15:38
@tomholub
tomholub enabled auto-merge (squash) May 28, 2024 15:38
@tomholub
tomholub requested a review from martgil May 28, 2024 15:42
Comment thread extension/js/content_scripts/webmail/gmail/gmail-webmail-startup.ts Outdated
sosnovsky
sosnovsky previously approved these changes May 28, 2024

@sosnovsky sosnovsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Works well 👍

@tomholub tomholub left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

just checking - looks okay. The artifact update untested, since test started passing again

@tomholub
tomholub merged commit 6823435 into master May 29, 2024
@tomholub
tomholub deleted the issue-5747-thunderbird-refactor branch May 29, 2024 18:02
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.

refactor content scripts to make it easier to implement Thunderbird support

2 participants