release 1.2
This commit is contained in:
+26
-9
@@ -1,5 +1,7 @@
|
||||
// content.js
|
||||
console.log('[EXT][content] loaded');
|
||||
if (isDocumentsPage()) {
|
||||
console.log('[EXT][content] loaded');
|
||||
}
|
||||
|
||||
const dataType = 'metaData';
|
||||
const userDataType = 'userData';
|
||||
@@ -38,19 +40,26 @@ window.addEventListener('message', (event) => {
|
||||
|
||||
});
|
||||
|
||||
async function loadPageData() {
|
||||
async function loadStorageData() {
|
||||
storageData = await chrome.storage.local.get(dataType);
|
||||
|
||||
const userData = await chrome.storage.local.get(userDataType);
|
||||
storageData.userData = userData[userDataType];
|
||||
}
|
||||
|
||||
if (!storageData || !storageData.metaData || Object.keys(storageData.metaData).length === 0) {
|
||||
console.log(`[EXT][content] no data for ${dataType}, injecting...`);
|
||||
injectScript(`${dataType}.js`);
|
||||
} else {
|
||||
console.log(`[EXT][content] metadata already exists in storage`);
|
||||
async function updateStorageData() {
|
||||
if (!storageData.metaData || !storageData.userData) {
|
||||
await loadStorageData();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPageData() {
|
||||
console.log(`[EXT][content] renew data for ${dataType}, injecting...`);
|
||||
injectScript(`${dataType}.js`);
|
||||
|
||||
await loadStorageData();
|
||||
}
|
||||
|
||||
function isDocumentsPage() {
|
||||
return (
|
||||
location.href.includes('/clients/') &&
|
||||
@@ -89,6 +98,8 @@ window.addEventListener('message', async (event) => {
|
||||
return;
|
||||
}
|
||||
|
||||
await updateStorageData();
|
||||
|
||||
// Получаем данные из storage
|
||||
if (!storageData.metaData) {
|
||||
window.postMessage({
|
||||
@@ -171,6 +182,8 @@ window.addEventListener('message', async (event) => {
|
||||
}
|
||||
}, '*');
|
||||
|
||||
await updateStorageData();
|
||||
|
||||
// Фильтруем документы по номерам
|
||||
const filteredDocs = storageData.metaData.docs.filter(doc =>
|
||||
event.data.payload.docNumbers.includes(parseInt(doc.number, 10))
|
||||
@@ -223,10 +236,10 @@ window.addEventListener('message', async (event) => {
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// В content.js, в основном обработчике window.addEventListener добавьте:
|
||||
|
||||
// ОБРАБОТЧИК ПОДГОТОВКИ ДОКУМЕНТОВ (используем существующие метаданные)
|
||||
if (event.data.type === 'prepareDocuments') {
|
||||
await updateStorageData();
|
||||
|
||||
// Проверяем наличие метаданных
|
||||
if (!storageData.metaData) {
|
||||
window.postMessage({
|
||||
@@ -287,6 +300,8 @@ window.addEventListener('message', async (event) => {
|
||||
|
||||
// ОБРАБОТЧИК ПРОВЕРКИ ПРАВ НА ОТЗЫВ
|
||||
if (event.data.type === 'checkRevokePermission') {
|
||||
await updateStorageData();
|
||||
|
||||
const hasPermission = String(storageData.userData?.id) === String(event.data.payload.userIdLpu);
|
||||
|
||||
window.postMessage({
|
||||
@@ -328,6 +343,8 @@ window.addEventListener('message', async (event) => {
|
||||
|
||||
// ОБРАБОТЧИК ПОИСКА ПОЛУЧАТЕЛЕЙ ПО ТЕЛЕФОНУ
|
||||
if (event.data.type === 'searchRecipients') {
|
||||
await updateStorageData();
|
||||
|
||||
const data = {
|
||||
...event.data.payload,
|
||||
idPatientMis: storageData.metaData.patient.idPatientMis
|
||||
|
||||
Reference in New Issue
Block a user