Merge branch 'develop' into fix/CW-6294
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
<script setup>
|
||||
import { h, computed, onMounted } from 'vue';
|
||||
import { h, ref, computed, onMounted } from 'vue';
|
||||
import { provideSidebarContext } from './provider';
|
||||
import { useAccount } from 'dashboard/composables/useAccount';
|
||||
import { useKbd } from 'dashboard/composables/utils/useKbd';
|
||||
import { useMapGetter } from 'dashboard/composables/store';
|
||||
import { useStore } from 'vuex';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { useSidebarKeyboardShortcuts } from './useSidebarKeyboardShortcuts';
|
||||
import { vOnClickOutside } from '@vueuse/components';
|
||||
import { emitter } from 'shared/helpers/mitt';
|
||||
@@ -55,14 +54,7 @@ const toggleShortcutModalFn = show => {
|
||||
|
||||
useSidebarKeyboardShortcuts(toggleShortcutModalFn);
|
||||
|
||||
// We're using localStorage to store the expanded item in the sidebar
|
||||
// This helps preserve context when navigating between portal and dashboard layouts
|
||||
// and also when the user refreshes the page
|
||||
const expandedItem = useStorage(
|
||||
'next-sidebar-expanded-item',
|
||||
null,
|
||||
sessionStorage
|
||||
);
|
||||
const expandedItem = ref(null);
|
||||
|
||||
const setExpandedItem = name => {
|
||||
expandedItem.value = expandedItem.value === name ? null : name;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { computed, onMounted, nextTick } from 'vue';
|
||||
import { computed, onMounted, watch, nextTick } from 'vue';
|
||||
import { useSidebarContext } from './provider';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import Policy from 'dashboard/components/policy.vue';
|
||||
@@ -126,6 +126,16 @@ onMounted(async () => {
|
||||
setExpandedItem(props.name);
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
hasActiveChild,
|
||||
hasNewActiveChild => {
|
||||
if (hasNewActiveChild && !isExpanded.value) {
|
||||
setExpandedItem(props.name);
|
||||
}
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<!-- eslint-disable-next-line vue/no-root-v-if -->
|
||||
|
||||
@@ -14,11 +14,19 @@ class ActionCableListener < BaseListener
|
||||
end
|
||||
|
||||
def notification_deleted(event)
|
||||
return if event.data[:notification].user.blank?
|
||||
notification_data = event.data[:notification_data]
|
||||
|
||||
notification, account, unread_count, count = extract_notification_and_account(event)
|
||||
tokens = [event.data[:notification].user.pubsub_token]
|
||||
broadcast(account, tokens, NOTIFICATION_DELETED, { notification: { id: notification.id }, unread_count: unread_count, count: count })
|
||||
user = User.find_by(id: notification_data[:user_id])
|
||||
account = Account.find_by(id: notification_data[:account_id])
|
||||
return if user.blank? || account.blank?
|
||||
|
||||
notification_finder = NotificationFinder.new(user, account)
|
||||
tokens = [user.pubsub_token]
|
||||
broadcast(account, tokens, NOTIFICATION_DELETED, {
|
||||
notification: { id: notification_data[:id] },
|
||||
unread_count: notification_finder.unread_count,
|
||||
count: notification_finder.count
|
||||
})
|
||||
end
|
||||
|
||||
def account_cache_invalidated(event)
|
||||
|
||||
@@ -180,7 +180,17 @@ class Notification < ApplicationRecord
|
||||
end
|
||||
|
||||
def dispatch_destroy_event
|
||||
Rails.configuration.dispatcher.dispatch(NOTIFICATION_DELETED, Time.zone.now, notification: self)
|
||||
# Pass serialized data instead of ActiveRecord object to avoid DeserializationError
|
||||
# when the async EventDispatcherJob runs after the notification has been deleted
|
||||
Rails.configuration.dispatcher.dispatch(
|
||||
NOTIFICATION_DELETED,
|
||||
Time.zone.now,
|
||||
notification_data: {
|
||||
id: id,
|
||||
user_id: user_id,
|
||||
account_id: account_id
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def set_last_activity_at
|
||||
|
||||
@@ -132,7 +132,14 @@ describe ActionCableListener do
|
||||
describe '#notification_deleted' do
|
||||
let(:event_name) { :'notification.deleted' }
|
||||
let!(:notification) { create(:notification, account: account, user: agent) }
|
||||
let!(:event) { Events::Base.new(event_name, Time.zone.now, notification: notification) }
|
||||
let(:notification_data) do
|
||||
{
|
||||
id: notification.id,
|
||||
user_id: agent.id,
|
||||
account_id: account.id
|
||||
}
|
||||
end
|
||||
let!(:event) { Events::Base.new(event_name, Time.zone.now, notification_data: notification_data) }
|
||||
|
||||
it 'sends message to account admins, inbox agents' do
|
||||
expect(ActionCableBroadcastJob).to receive(:perform_later).with(
|
||||
|
||||
Reference in New Issue
Block a user