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

Make HTML body loading a single step experience #7612

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
<MessageHTMLBody v-if="message.hasHtmlBody"
:url="htmlUrl"
:message="message"
:full-height="fullHeight" />
:full-height="fullHeight"
@load="$emit('load', $event)" />
<MessageEncryptedBody v-else-if="isEncrypted"
:body="message.body"
:from="from"
Expand Down
9 changes: 3 additions & 6 deletions src/components/MessageHTMLBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
</ActionButton>
</Actions>
</div>
<IconLoading v-if="loading" />
<div id="message-container" :class="{hidden: loading, scroll: !fullHeight}">
<div id="message-container" :class="{scroll: !fullHeight}">
<iframe ref="iframe"
class="message-frame"
:title="t('mail', 'Message frame')"
Expand All @@ -43,7 +42,7 @@
import { iframeResizer } from 'iframe-resizer'
import PrintScout from 'printscout'
import { trustSender } from '../service/TrustedSenderService'
import { NcActionButton as ActionButton, NcActions as Actions, NcLoadingIcon as IconLoading } from '@nextcloud/vue'
import { NcActionButton as ActionButton, NcActions as Actions } from '@nextcloud/vue'
import IconImage from 'vue-material-design-icons/ImageSizeSelectActual'
import IconMail from 'vue-material-design-icons/Email'
import IconDomain from 'vue-material-design-icons/Domain'
Expand All @@ -61,7 +60,6 @@ export default {
IconImage,
IconMail,
IconDomain,
IconLoading,
},
props: {
url: {
Expand All @@ -80,7 +78,6 @@ export default {
},
data() {
return {
loading: true,
hasBlockedContent: false,
isSenderTrusted: this.message.isSenderTrusted,
}
Expand Down Expand Up @@ -115,7 +112,7 @@ export default {
|| iframeDoc.querySelectorAll('[data-original-style]').length > 0
|| iframeDoc.querySelectorAll('style[data-original-content]').length > 0

this.loading = false
this.$emit('load')
if (this.isSenderTrusted) {
this.displayIframe()
}
Expand Down
27 changes: 21 additions & 6 deletions src/components/ThreadEnvelope.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@
</template>
</div>
</div>
<Loading v-if="loading" />
<Message v-else-if="message"
<Loading v-if="loading !== LOADING_DONE" />
<Message v-if="message && loading !== LOADING_MESSAGE"
v-show="loading === LOADING_DONE"
:envelope="envelope"
:message="message"
:full-height="fullHeight" />
:full-height="fullHeight"
@load="loading = LOADING_DONE" />
<Error v-else-if="error"
:error="error && error.message ? error.message : t('mail', 'Not found')"
:message="errorMessage"
Expand Down Expand Up @@ -181,6 +183,11 @@ import { matchError } from '../errors/match'
import NoTrashMailboxConfiguredError from '../errors/NoTrashMailboxConfiguredError'
import { isPgpText } from '../crypto/pgp'

// Ternary loading state
const LOADING_DONE = 0
const LOADING_MESSAGE = 1
const LOADING_BODY = 2

export default {
name: 'ThreadEnvelope',
components: {
Expand Down Expand Up @@ -232,11 +239,14 @@ export default {
},
data() {
return {
loading: false,
loading: LOADING_DONE,
error: undefined,
message: undefined,
importantSvg,
seenTimer: undefined,
LOADING_BODY,
LOADING_DONE,
LOADING_MESSAGE,
}
},
computed: {
Expand Down Expand Up @@ -303,6 +313,7 @@ export default {
this.fetchMessage()
} else {
this.message = undefined
this.loading = LOADING_DONE
}
},
},
Expand All @@ -323,7 +334,7 @@ export default {
},
methods: {
async fetchMessage() {
this.loading = true
this.loading = LOADING_MESSAGE

logger.debug(`fetching thread message ${this.envelope.databaseId}`)

Expand All @@ -339,7 +350,11 @@ export default {
}, 2000)
}

this.loading = false
if (this.message.hasHtmlBody) {
this.loading = LOADING_BODY
} else {
this.loading = LOADING_DONE
}
} catch (error) {
logger.error('Could not fetch message', { error })
}
Expand Down