Skip to content

Commit

Permalink
dialing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sartxi committed Jun 4, 2024
1 parent 3e5b48c commit e8da2f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions libs/blocks/locui/loc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { setStatus } from '../utils/status.js';
import { getStatus, preview } from '../utils/franklin.js';
import login from '../../../tools/sharepoint/login.js';
import { getServiceUpdates } from '../utils/miloc.js';
import { connectAemSK } from '../../../utils/sidekick.js';
import { connectSK } from '../../../utils/sidekick.js';

const LANG_ACTIONS = ['Translate', 'English Copy', 'Rollout'];
const MOCK_REFERRER = 'https%3A%2F%2Fadobe.sharepoint.com%2F%3Ax%3A%2Fr%2Fsites%2Fadobecom%2F_layouts%2F15%2FDoc.aspx%3Fsourcedoc%3D%257B94460FAC-CDEE-4B31-B8E0-AA5E3F45DCC5%257D%26file%3Dwesco-demo.xlsx';
Expand Down Expand Up @@ -137,14 +137,14 @@ async function loginToSharePoint() {

async function connectSidekick() {
return new Promise((resolve) => {
const onConnected = ({ detail }) => {
const onConnect = ({ detail }) => {
if (detail?.data?.profile) {
user.value = detail.data.profile;
resolve();
}
setStatus('details', 'info', 'Please sign-in to AEM sidekick.');
};
connectAemSK(onConnected, () => {
connectSK(onConnect, () => {
setStatus('details', 'info', 'Please open AEM sidekick to continue.');
});
});
Expand Down
16 changes: 8 additions & 8 deletions libs/utils/sidekick.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default function init({ createTag, loadBlock, loadScript, loadStyle }) {
stylePublish(sk);
}

function onSidekickAvailable(callback) {
function onSkLoaded(callback) {
// sidekick nextGen
const observer = new MutationObserver(() => {
const sidekick = document.querySelector('aem-sidekick');
Expand All @@ -113,15 +113,15 @@ function onSidekickAvailable(callback) {
}, { once: true });
}

export function connectAemSK(setStatus, notLoaded = null) {
const isOpen = document.querySelector('helix-sidekick')
export function connectSK(status, standby = null) {
const sidekick = document.querySelector('helix-sidekick')
|| document.querySelector('aem-sidekick');
if (isOpen) {
isOpen.addEventListener('statusfetched', setStatus);
if (sidekick) {
sidekick.addEventListener('statusfetched', status);
} else {
notLoaded?.();
onSidekickAvailable((sidekick) => {
sidekick?.addEventListener('statusfetched', setStatus);
standby?.();
onSkLoaded((sk) => {
sk?.addEventListener('statusfetched', status);
});
}
}

0 comments on commit e8da2f0

Please sign in to comment.