Skip to content

Download list of emails #90

@pbarolat

Description

@pbarolat

I'm not much of a programmer but I needed a way to download the entire list of my "Hide My Email" address of which I have hundreds. This is what I came up with. It's very simple and probably needs a bit of modification to be added to the code base (if someone actually wants to do that):

diff --git a/src/pages/Popup/Popup.tsx b/src/pages/Popup/Popup.tsx
index e6fcad9..6dabba0 100644
--- a/src/pages/Popup/Popup.tsx
+++ b/src/pages/Popup/Popup.tsx
@@ -629,6 +629,33 @@ const HmeManager = (props: {
);
};

  • const downloadEmailsAsCsv = () => {
  • const fetchHmeList = async () => {
  •  setHmeEmailsError(undefined);
    
  •  setIsFetching(true);
    
  •  try {
    
  •    const pms = new PremiumMailSettings(props.client);
    
  •    const result = await pms.listHme();
    
  •      result.hmeEmails.sort((a, b) => b.createTimestamp - a.createTimestamp)
    
  •      const csvContent = result.hmeEmails.map(hme => `${hme.label},${hme.hme},${hme.createTimestamp}`).join('\n');
    
  •      const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
    
  •      const url = URL.createObjectURL(blob);
    
  •      const link = document.createElement('a');
    
  •      link.setAttribute('href', url);
    
  •      link.setAttribute('download', 'hide-my-emails.csv');
    
  •      link.style.visibility = 'hidden';
    
  •      document.body.appendChild(link);
    
  •      link.click();
    
  •      document.body.removeChild(link);
    
  •  } catch (e) {
    
  •    setHmeEmailsError(e.toString());
    
  •  } finally {
    
  •    setIsFetching(false);
    
  •  }
    
  • };
  • fetchHmeList();
  • }
    const hmeListGrid = (fetchedHmeEmails: HmeEmail[]) => {
    const hmeEmails =
    searchHmeEmails(searchPrompt || '', fetchedHmeEmails) || fetchedHmeEmails;
    @@ -742,6 +769,13 @@ const HmeManager = (props: {
    icon={faPlus}
    label="Generate new email"
    />
  •    </div>
    
  •     <div>
    
  •      <FooterButton
    
  •        onClick={downloadEmailsAsCsv}
    
  •        icon={faPlus}
    
  •        label="Download email list"
    
  •      />
       </div>
       <div className="text-right">
         <SignOutButton {...props} />
    

diff --git a/src/pages/Popup/stateMachine.ts b/src/pages/Popup/stateMachine.ts
index 9a74039..388dd33 100644
--- a/src/pages/Popup/stateMachine.ts
+++ b/src/pages/Popup/stateMachine.ts
@@ -40,5 +40,6 @@ export const STATE_MACHINE_TRANSITIONS: Transitions = {
[PopupState.AuthenticatedAndManaging]: {
GENERATE: PopupState.Authenticated,
SIGN_OUT: PopupState.SignedOut,

  • DOWNLOAD: PopupState.Authenticated,
    },
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions