Merge branch 'develop' into chore/load-reply-message
This commit is contained in:
@@ -17,8 +17,8 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
|
||||
before_action :set_include_contact_inboxes, only: [:index, :active, :search, :filter, :show, :update]
|
||||
|
||||
def index
|
||||
@contacts_count = resolved_contacts.count
|
||||
@contacts = fetch_contacts(resolved_contacts)
|
||||
@contacts_count = @contacts.total_count
|
||||
end
|
||||
|
||||
def search
|
||||
@@ -29,8 +29,8 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
|
||||
OR contacts.additional_attributes->>\'company_name\' ILIKE :search',
|
||||
search: "%#{params[:q].strip}%"
|
||||
)
|
||||
@contacts_count = contacts.count
|
||||
@contacts = fetch_contacts(contacts)
|
||||
@contacts_count = @contacts.total_count
|
||||
end
|
||||
|
||||
def import
|
||||
@@ -55,8 +55,8 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
|
||||
def active
|
||||
contacts = Current.account.contacts.where(id: ::OnlineStatusTracker
|
||||
.get_available_contact_ids(Current.account.id))
|
||||
@contacts_count = contacts.count
|
||||
@contacts = fetch_contacts(contacts)
|
||||
@contacts_count = @contacts.total_count
|
||||
end
|
||||
|
||||
def show; end
|
||||
@@ -133,13 +133,14 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
|
||||
end
|
||||
|
||||
def fetch_contacts(contacts)
|
||||
contacts_with_avatar = filtrate(contacts)
|
||||
.includes([{ avatar_attachment: [:blob] }])
|
||||
.page(@current_page).per(RESULTS_PER_PAGE)
|
||||
# Build includes hash to avoid separate query when contact_inboxes are needed
|
||||
includes_hash = { avatar_attachment: [:blob] }
|
||||
includes_hash[:contact_inboxes] = { inbox: :channel } if @include_contact_inboxes
|
||||
|
||||
return contacts_with_avatar.includes([{ contact_inboxes: [:inbox] }]) if @include_contact_inboxes
|
||||
|
||||
contacts_with_avatar
|
||||
filtrate(contacts)
|
||||
.includes(includes_hash)
|
||||
.page(@current_page)
|
||||
.per(RESULTS_PER_PAGE)
|
||||
end
|
||||
|
||||
def build_contact_inbox
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<script setup>
|
||||
import { defineProps, defineModel } from 'vue';
|
||||
import { defineProps, defineModel, computed } from 'vue';
|
||||
import { useToggle } from '@vueuse/core';
|
||||
|
||||
import Button from 'dashboard/components-next/button/Button.vue';
|
||||
import WithLabel from './WithLabel.vue';
|
||||
|
||||
defineProps({
|
||||
const props = defineProps({
|
||||
label: {
|
||||
type: String,
|
||||
required: true,
|
||||
@@ -31,6 +34,11 @@ defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
const FIELDS = {
|
||||
TEXT: 'text',
|
||||
PASSWORD: 'password',
|
||||
};
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
});
|
||||
@@ -39,6 +47,17 @@ const model = defineModel({
|
||||
type: [String, Number],
|
||||
required: true,
|
||||
});
|
||||
|
||||
const [isPasswordVisible, togglePasswordVisibility] = useToggle();
|
||||
|
||||
const isPasswordField = computed(() => props.type === FIELDS.PASSWORD);
|
||||
|
||||
const currentInputType = computed(() => {
|
||||
if (isPasswordField.value) {
|
||||
return isPasswordVisible.value ? FIELDS.TEXT : FIELDS.PASSWORD;
|
||||
}
|
||||
return props.type;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -56,7 +75,7 @@ const model = defineModel({
|
||||
v-bind="$attrs"
|
||||
v-model="model"
|
||||
:name="name"
|
||||
:type="type"
|
||||
:type="currentInputType"
|
||||
class="block w-full border-none rounded-md shadow-sm bg-n-alpha-black2 appearance-none outline outline-1 focus:outline focus:outline-1 text-n-slate-12 placeholder:text-n-slate-10 sm:text-sm sm:leading-6 px-3 py-3"
|
||||
:class="{
|
||||
'error outline-n-ruby-8 dark:outline-n-ruby-8 hover:outline-n-ruby-9 dark:hover:outline-n-ruby-9 disabled:outline-n-ruby-8 dark:disabled:outline-n-ruby-8':
|
||||
@@ -66,7 +85,20 @@ const model = defineModel({
|
||||
'px-3 py-3': spacing === 'base',
|
||||
'px-3 py-2 mb-0': spacing === 'compact',
|
||||
'pl-9': icon,
|
||||
'pr-10': isPasswordField,
|
||||
}"
|
||||
/>
|
||||
<Button
|
||||
v-if="isPasswordField"
|
||||
type="button"
|
||||
slate
|
||||
sm
|
||||
link
|
||||
:icon="isPasswordVisible ? 'i-lucide-eye-off' : 'i-lucide-eye'"
|
||||
class="absolute inset-y-0 right-0 pr-3"
|
||||
:aria-label="isPasswordVisible ? 'Hide password' : 'Show password'"
|
||||
:aria-pressed="isPasswordVisible"
|
||||
@click="togglePasswordVisibility()"
|
||||
/>
|
||||
</WithLabel>
|
||||
</template>
|
||||
|
||||
@@ -32,9 +32,11 @@ class Whatsapp::IncomingMessageBaseService
|
||||
set_contact
|
||||
return unless @contact
|
||||
|
||||
set_conversation
|
||||
create_messages
|
||||
clear_message_source_id_from_redis
|
||||
ActiveRecord::Base.transaction do
|
||||
set_conversation
|
||||
create_messages
|
||||
clear_message_source_id_from_redis
|
||||
end
|
||||
end
|
||||
|
||||
def process_statuses
|
||||
|
||||
@@ -5,6 +5,6 @@ end
|
||||
|
||||
json.payload do
|
||||
json.array! @contacts do |contact|
|
||||
json.partial! 'api/v1/models/contact', formats: [:json], resource: contact, with_contact_inboxes: true
|
||||
json.partial! 'api/v1/models/contact', formats: [:json], resource: contact, with_contact_inboxes: @include_contact_inboxes
|
||||
end
|
||||
end
|
||||
|
||||
@@ -215,7 +215,7 @@ RSpec.describe Conversation do
|
||||
it 'adds a message for system auto resolution if marked resolved by system' do
|
||||
account.update(auto_resolve_after: 40 * 24 * 60)
|
||||
conversation2 = create(:conversation, status: 'open', account: account, assignee: old_assignee)
|
||||
Current.user = nil
|
||||
Current.reset
|
||||
|
||||
message_data = if account.auto_resolve_after >= 1440 && account.auto_resolve_after % 1440 == 0
|
||||
{ key: 'auto_resolved_days', count: account.auto_resolve_after / 1440 }
|
||||
|
||||
Reference in New Issue
Block a user