diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-01-06 07:21:07 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-01-09 13:03:56 +0300 |
commit | e99cbef9e57919e3351ec455f529011e623e9a37 (patch) | |
tree | f2de748393dfee318ed6e301ba4ca78775d52095 /src | |
parent | 8e4456a6d5665a57a2fdb0ca5091273711a6a9b6 (diff) |
Extract function to handle start getting messages preconditions
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/MessagesList/MessagesList.vue | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/components/MessagesList/MessagesList.vue b/src/components/MessagesList/MessagesList.vue index 2381bd809..8f1ac8980 100644 --- a/src/components/MessagesList/MessagesList.vue +++ b/src/components/MessagesList/MessagesList.vue @@ -167,23 +167,15 @@ export default { // is a participant in the old and the new conversation). token: { immediate: true, - handler(token) { - if (token && this.isParticipant) { - this.startGettingMessages() - } else { - this.cancelLookForNewMessages() - } + handler() { + this.handleStartGettingMessagesPreconditions() }, }, isParticipant: { immediate: true, - handler(isParticipant) { - if (this.token && isParticipant) { - this.startGettingMessages() - } else { - this.cancelLookForNewMessages() - } + handler() { + this.handleStartGettingMessagesPreconditions() }, }, }, @@ -297,6 +289,14 @@ export default { return moment.unix(message.timestamp) }, + handleStartGettingMessagesPreconditions() { + if (this.token && this.isParticipant) { + this.startGettingMessages() + } else { + this.cancelLookForNewMessages() + } + }, + /** * Fetches the messages of a conversation given the conversation token. Triggers * a long-polling request for new messages. |