mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
feat: Use typing status from utils (#8589)
This commit is contained in:
@@ -84,7 +84,10 @@ import {
|
|||||||
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
||||||
import uiSettingsMixin from 'dashboard/mixins/uiSettings';
|
import uiSettingsMixin from 'dashboard/mixins/uiSettings';
|
||||||
import { isEditorHotKeyEnabled } from 'dashboard/mixins/uiSettings';
|
import { isEditorHotKeyEnabled } from 'dashboard/mixins/uiSettings';
|
||||||
import { replaceVariablesInMessage } from '@chatwoot/utils';
|
import {
|
||||||
|
replaceVariablesInMessage,
|
||||||
|
createTypingIndicator,
|
||||||
|
} from '@chatwoot/utils';
|
||||||
import { CONVERSATION_EVENTS } from '../../../helper/AnalyticsHelper/events';
|
import { CONVERSATION_EVENTS } from '../../../helper/AnalyticsHelper/events';
|
||||||
import { checkFileSizeLimit } from 'shared/helpers/FileHelper';
|
import { checkFileSizeLimit } from 'shared/helpers/FileHelper';
|
||||||
import { uploadFile } from 'dashboard/helper/uploadHelper';
|
import { uploadFile } from 'dashboard/helper/uploadHelper';
|
||||||
@@ -140,6 +143,15 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
typingIndicator: createTypingIndicator(
|
||||||
|
() => {
|
||||||
|
this.$emit('typing-on');
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.$emit('typing-off');
|
||||||
|
},
|
||||||
|
TYPING_INDICATOR_IDLE_TIME
|
||||||
|
),
|
||||||
showUserMentions: false,
|
showUserMentions: false,
|
||||||
showCannedMenu: false,
|
showCannedMenu: false,
|
||||||
showVariables: false,
|
showVariables: false,
|
||||||
@@ -638,15 +650,6 @@ export default {
|
|||||||
hideMentions() {
|
hideMentions() {
|
||||||
this.showUserMentions = false;
|
this.showUserMentions = false;
|
||||||
},
|
},
|
||||||
resetTyping() {
|
|
||||||
this.$emit('typing-off');
|
|
||||||
this.idleTimer = null;
|
|
||||||
},
|
|
||||||
turnOffIdleTimer() {
|
|
||||||
if (this.idleTimer) {
|
|
||||||
clearTimeout(this.idleTimer);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleLineBreakWhenEnterToSendEnabled(event) {
|
handleLineBreakWhenEnterToSendEnabled(event) {
|
||||||
if (
|
if (
|
||||||
hasPressedEnterAndNotCmdOrShift(event) &&
|
hasPressedEnterAndNotCmdOrShift(event) &&
|
||||||
@@ -666,14 +669,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onKeyup() {
|
onKeyup() {
|
||||||
if (!this.idleTimer) {
|
this.typingIndicator.start();
|
||||||
this.$emit('typing-on');
|
|
||||||
}
|
|
||||||
this.turnOffIdleTimer();
|
|
||||||
this.idleTimer = setTimeout(
|
|
||||||
() => this.resetTyping(),
|
|
||||||
TYPING_INDICATOR_IDLE_TIME
|
|
||||||
);
|
|
||||||
this.updateImgToolbarOnDelete();
|
this.updateImgToolbarOnDelete();
|
||||||
},
|
},
|
||||||
onKeydown(event) {
|
onKeydown(event) {
|
||||||
@@ -685,8 +681,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onBlur() {
|
onBlur() {
|
||||||
this.turnOffIdleTimer();
|
this.typingIndicator.stop();
|
||||||
this.resetTyping();
|
|
||||||
this.$emit('blur');
|
this.$emit('blur');
|
||||||
},
|
},
|
||||||
onFocus() {
|
onFocus() {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
removeSignature,
|
removeSignature,
|
||||||
extractTextFromMarkdown,
|
extractTextFromMarkdown,
|
||||||
} from 'dashboard/helper/editorHelper';
|
} from 'dashboard/helper/editorHelper';
|
||||||
|
import { createTypingIndicator } from '@chatwoot/utils';
|
||||||
|
|
||||||
const TYPING_INDICATOR_IDLE_TIME = 4000;
|
const TYPING_INDICATOR_IDLE_TIME = 4000;
|
||||||
export default {
|
export default {
|
||||||
@@ -54,7 +55,15 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
idleTimer: null,
|
typingIndicator: createTypingIndicator(
|
||||||
|
() => {
|
||||||
|
this.$emit('typing-on');
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.$emit('typing-off');
|
||||||
|
},
|
||||||
|
TYPING_INDICATOR_IDLE_TIME
|
||||||
|
),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -137,28 +146,11 @@ export default {
|
|||||||
this.$emit('input', event.target.value);
|
this.$emit('input', event.target.value);
|
||||||
this.resizeTextarea();
|
this.resizeTextarea();
|
||||||
},
|
},
|
||||||
resetTyping() {
|
|
||||||
this.$emit('typing-off');
|
|
||||||
this.idleTimer = null;
|
|
||||||
},
|
|
||||||
turnOffIdleTimer() {
|
|
||||||
if (this.idleTimer) {
|
|
||||||
clearTimeout(this.idleTimer);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onKeyup() {
|
onKeyup() {
|
||||||
if (!this.idleTimer) {
|
this.typingIndicator.start();
|
||||||
this.$emit('typing-on');
|
|
||||||
}
|
|
||||||
this.turnOffIdleTimer();
|
|
||||||
this.idleTimer = setTimeout(
|
|
||||||
() => this.resetTyping(),
|
|
||||||
TYPING_INDICATOR_IDLE_TIME
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
onBlur() {
|
onBlur() {
|
||||||
this.turnOffIdleTimer();
|
this.typingIndicator.stop();
|
||||||
this.resetTyping();
|
|
||||||
this.$emit('blur');
|
this.$emit('blur');
|
||||||
},
|
},
|
||||||
onFocus() {
|
onFocus() {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braid/vue-formulate": "^2.5.2",
|
"@braid/vue-formulate": "^2.5.2",
|
||||||
"@chatwoot/prosemirror-schema": "1.0.3",
|
"@chatwoot/prosemirror-schema": "1.0.3",
|
||||||
"@chatwoot/utils": "^0.0.20",
|
"@chatwoot/utils": "^0.0.21",
|
||||||
"@hcaptcha/vue-hcaptcha": "^0.3.2",
|
"@hcaptcha/vue-hcaptcha": "^0.3.2",
|
||||||
"@june-so/analytics-next": "^1.36.5",
|
"@june-so/analytics-next": "^1.36.5",
|
||||||
"@radix-ui/colors": "^1.0.1",
|
"@radix-ui/colors": "^1.0.1",
|
||||||
|
|||||||
@@ -3177,10 +3177,10 @@
|
|||||||
prosemirror-utils "^0.9.6"
|
prosemirror-utils "^0.9.6"
|
||||||
prosemirror-view "^1.17.2"
|
prosemirror-view "^1.17.2"
|
||||||
|
|
||||||
"@chatwoot/utils@^0.0.20":
|
"@chatwoot/utils@^0.0.21":
|
||||||
version "0.0.20"
|
version "0.0.21"
|
||||||
resolved "https://registry.yarnpkg.com/@chatwoot/utils/-/utils-0.0.20.tgz#d7cb407da434efcce4262178dbef55441f218489"
|
resolved "https://registry.yarnpkg.com/@chatwoot/utils/-/utils-0.0.21.tgz#f9116daac0514a8a8fa6ce594efff10062222be0"
|
||||||
integrity sha512-rChMLxxbtzDpS2wePhnsdu+NDfRWbV+9Jw9eZ34jQRxkQ4LYVUoj6z5gC7a5+3izZQZ1XEwDSPHIiIvIUX4tzg==
|
integrity sha512-eUDJ1K5x1rFlBywRctU3hXXiJ1U0EZiklowNl/YJOh1/BWDns4It3DWrQmAcjvsNbEUNWMfY+ShJmjdeei71Cw==
|
||||||
dependencies:
|
dependencies:
|
||||||
date-fns "^2.29.1"
|
date-fns "^2.29.1"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user