1

I am almost finished with project 3: mail of CS50w 2020. The only problem is that when I send a new mail to someone the sent page loads without showing the new mail I just sent. I added event.preventDefault(); so that the page doesn't reload to inbox. Any ideas?

1 Answer 1

6

This is probably not relevant to you anymore, but I had the same bug, and stumbled upon this question when googling, so it might help other people with this bug.

So you're calling load_mailbox('sent') at the end of your function for sending emails, right? As far as I can tell, the problem is that when you call load_mailbox('sent'), the new email you just sent has not been updated in the SQLite database yet. Try wrapping the call to load_mailbox in the setTimeout function, like so:

setTimeout(function(){ load_mailbox('sent'); }, 100}

The 100ms delay was sufficient in my case, and the outbox now shows the most recent email also.

2
  • Did you by any chance get stuck with sending mail? Thanks. Commented Apr 12, 2021 at 17:05
  • Worked perfectly, almost got it on my own, I didn't put the load_mailbox function in a nameless/arrow function but after I did, the bug disappeared. Thx so much!
    – PrimeBeat
    Commented Aug 24, 2021 at 6:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .