mail icon indicating copy to clipboard operation
mail copied to clipboard

👌 IMPROVE: don't open first mail by default

Open violoncelloCH opened this issue 2 years ago • 7 comments

fix #6526

This removes the logic to automatically open the first message of a mailbox

In contrary to #2794, this also doesn't open the first mail, when the current folder is reloaded as this would be unexpected: If I open a mailbox, don't select any mail and click on the same mailbox again I don't want the first message to be opened at that time. (Also the current implementation would've lead to first messages being opened while navigation between mailboxes.)

There is one remaining bug: on the initial load of the priority mailbox, this.$store.getters.getEnvelopes(this.mailbox.databaseId, this.searchQuery) returns an empty list even though there are mails in the inbox. Therefore hasEnvelopes is false and the "No message selected" placeholder isn't displayed. After a few seconds (after the third or fourth sync request; but I'm not sure that's actually related) the getEnvelopes getter suddenly returns the correct answer and the view gets updated. I couldn't find out why this getter isn't working at initial load. Any idea on how to debug this further ?

violoncelloCH avatar Jul 10 '22 10:07 violoncelloCH

Therefore hasEnvelopes is false and the "No message selected" placeholder isn't displayed. After a few seconds (after the third or fourth sync request; but I'm not sure that's actually related) the getEnvelopes getter suddenly returns the correct answer and the view gets updated. I couldn't find out why this getter isn't working at initial load. Any idea on how to debug this further ?

Sounds like a Vue reactivity bug I've fought before. Not sure how I solved it last time.

ChristophWurst avatar Jul 13 '22 14:07 ChristophWurst

Yes, indeed... I did some further debugging and found that getters.getMailbox(mailboxId).envelopeLists initially only contains one entry: "is:pi-other": [ 4, 3 ] only later on a second one is added "": [ 4, 3 ] (that's when getEnvelopes actually returns the list of envelopes instead of just an empty list... no idea though where that second entry comes from and why it's only added at that time and not initially

violoncelloCH avatar Jul 13 '22 15:07 violoncelloCH

Okay, some more results: The problem seems to be that only the sync (with timeout 30*1000) in App.vue (this exactly matches the delay of 30 seconds I get for the "No message selected" message to appear) https://github.com/nextcloud/mail/blob/916e98a4fbfc73b1933afb22baa4a5a8d9798e5a/src/App.vue#L41 triggers the async action syncInboxes https://github.com/nextcloud/mail/blob/916e98a4fbfc73b1933afb22baa4a5a8d9798e5a/src/store/actions.js#L713-L715 which in turn dispatches fetchEnvelopes with query undefined this then commits addEnvelope with query being empty/undefined: https://github.com/nextcloud/mail/blob/916e98a4fbfc73b1933afb22baa4a5a8d9798e5a/src/store/actions.js#L467-L471 so only at that point, mailbox.envelopeLists actually contains an element with index being an empty string...

My question now is: Is that element of envelopeLists actually supposed to have an empty string as index ? If yes, how should this be properly fixed ?

  • By doing a this.$store.dispatch('syncInboxes') at the initial loading of the page ?
  • or just by doing dispatch('fetchEnvelopes') with undefined query parameter at initial load ?
  • or is there a better way I don't see yet ?

violoncelloCH avatar Jul 13 '22 19:07 violoncelloCH

My question now is: Is that element of envelopeLists actually supposed to have an empty string as index ? If yes, how should this be properly fixed ?

Empty string is the unfiltered envelope list. That would be used when you view your real inbox, not the unified one. The unified inbox consists of three filtered inboxes.

The background sync always uses the unfiltered inbox. So on page load there is no list for ''. Only the first background sync will initialize that.

So that is not a bug and fetching that list on page load is hopefully not necessary.

Therefore hasEnvelopes is false and the "No message selected" placeholder isn't displayed.

It is or is not displayed?

ChristophWurst avatar Jul 14 '22 14:07 ChristophWurst

Thanks for the explanation !

It is or is not displayed?

On the unified inbox, the placeholder is not displayed initially but only after 30 seconds, once there exists a list for ''. If I understand it correctly, the hasEnvelope lookup should query for is:pi-other, is:pi-important and is:pi-starred instead of '' in the case of the unified inbox. I'll check how to fix this.

violoncelloCH avatar Jul 14 '22 14:07 violoncelloCH

friendly ping :) could I get some feedback on this now that I've implemented a fix ^ ?

violoncelloCH avatar Aug 09 '22 13:08 violoncelloCH

@violoncelloCH could you add a screenshot for easier design review? :) What would be great is an emptycontent screen like:

mail icon Welcome to Nextcloud Mail (h2) Write a new message (as a button)

jancborchardt avatar Sep 01 '22 16:09 jancborchardt

@jancborchardt please see attached a preview of your comment and if i understood you right,

mail icon Welcome to Nextcloud Mail (h2) Write a new message (as a button)

Screenshot from 2023-08-04 19-27-19

GretaD avatar Aug 04 '23 17:08 GretaD

Jan, sorry, it was green, and i just click the merge button. If theres still something to do here, i will push a fixup on Monday 🤦

GretaD avatar Aug 04 '23 18:08 GretaD