remove duplicate calls

This commit is contained in:
peter.maquiran
2025-10-17 16:20:48 +01:00
parent a9cd4843d5
commit c14431034c
9 changed files with 54 additions and 52 deletions
@@ -43,7 +43,7 @@ export class PublicationFileGetByDocumentIdService {
var httpResult = await this.remote.FileListByDocumentId(input);
if(httpResult.isOk()) {
var localResult = await this.local.findAll();
var localResult = await this.local.find({documentId: input.documentId});
if(localResult.isOk()) {
const serverFiles = httpResult.value.data
@@ -75,7 +75,7 @@ export class PublicationFileGetByDocumentIdService {
datePublication: input.datePublication,
}).then(() => {
const end = performance.now();
console.log(`Insert duration for file "${file.name}": ${(end - start).toFixed(2)} ms`);
//console.log(`Insert duration for file "${file.name}": ${(end - start).toFixed(2)} ms`);
});
}
}
@@ -83,8 +83,8 @@ export class PublicationFileGetByDocumentIdService {
for (const localFile of localResult.value) {
const found = httpResult.value.data.filter((e) => e.name === localFile.name);
if (found.length === 0 && localFile.name) {
remove.push(localFile);
this.local.delete(localFile.id);
//remove.push(localFile);
//this.local.delete(localFile.id);
}
}
@@ -66,21 +66,21 @@ export class PublicationListByProcessIdService {
const updated = [];
const remove = [];
console.log("local::", localList.value.length);
console.log("server::", publications.length);
//console.log("local::", localList.value.length);
//console.log("server::", publications.length);
// detect added & updated
for (const [id, serverItem] of serverMap) {
if (!localMap.has(id)) {
console.log(serverMap.get(id), "addddddd");
console.log(localList, publications);
//console.log(serverMap.get(id), "addddddd");
//console.log(localList, publications);
added.push(serverMap.get(id));
} else if (serverItem.datePublication !== localMap.get(id).datePublication) {
updated.push(serverMap.get(id));
console.log('update');
//console.log('update');
} else {
console.log('else');
console.log(localMap, serverMap);
//console.log('else');
//console.log(localMap, serverMap);
}
}
@@ -91,9 +91,9 @@ export class PublicationListByProcessIdService {
}
}
console.log("update::", Object.keys(updated).length);
console.log("added::", added.length);
console.log("remove::", remove.length);
//console.log("update::", Object.keys(updated).length);
//console.log("added::", added.length);
//console.log("remove::", remove.length);
// apply updates
if (updated.length > 0) {
@@ -7,8 +7,8 @@ import FDBFactory from 'fake-indexeddb/lib/FDBFactory';
import FDBKeyRange from 'fake-indexeddb/lib/FDBKeyRange';
export const actionDatabase = new Dexie('action-database-v1', {
indexedDB: new FDBFactory,
IDBKeyRange: FDBKeyRange, // Mocking IDBKeyRange
//indexedDB: new FDBFactory,
//IDBKeyRange: FDBKeyRange, // Mocking IDBKeyRange
}) as Dexie & {
action: DexieActionTable,
publication: DexiePublicationTable,
+4 -4
View File
@@ -22,11 +22,11 @@ export class CropImagePage implements OnInit {
private modalController: ModalController,
) {
this.base64ToCroppe = this.navParams.get('base64ToCroppe')
console.log('To cropp',this.base64ToCroppe)
//console.log('To cropp',this.base64ToCroppe)
}
ngOnInit() {
console.log('To cropp',this.base64ToCroppe)
//console.log('To cropp',this.base64ToCroppe)
}
fileChangeEvent(event: any): void {
@@ -37,8 +37,8 @@ export class CropImagePage implements OnInit {
imageCropped(event: ImageCroppedEvent, tracing?: TracingType) {
this.croppedImage = event.base64;
console.log('Croped image', event)
console.log('Croped image 22', this.croppedImage)
//console.log('Croped image', event)
//console.log('Croped image 22', this.croppedImage)
tracing.addEvent('Croped image')
tracing.setAttribute('outcome','success')
// event.blob can be used to upload the cropped image
@@ -291,7 +291,7 @@ export class PublicationsPage implements OnInit {
}
goToPublicationsList = (folderId: string) => {
console.log('nice', folderId)
//console.log('nice', folderId)
if(window["sharedContent"]){
this.AddPublication('2',folderId,window["sharedContent"])
return
@@ -163,16 +163,6 @@ export class ViewPublicationsPage implements OnInit {
}
publicationIsPresent(publicationId, folderId) {
return this.publicationFolderService.publicationList[folderId].find(e => e.DocumentId == publicationId)
}
publicationFind(publicationId, folderId) {
return this.publicationFolderService.publicationList[folderId].find(e => e.DocumentId == publicationId)
}
publicationFindIndex(publicationId, folderId) {
return this.publicationFolderService.publicationList[folderId].findIndex(e => e.DocumentId == publicationId)
}
async loadPublication(publicationId, folderId) {
await this.publicationFolderService.loadPublication(publicationId, folderId)
+25 -13
View File
@@ -13,7 +13,7 @@ import { v4 as uuidv4 } from 'uuid'
})
export class SwiperPage implements OnInit {
@Input() publicationList: IPublicationDocument[];
publicationList: IPublicationDocument[] = [];
@Input() navigation: boolean;
@Input() pagination: boolean;
@Input() processId: number;
@@ -39,18 +39,6 @@ export class SwiperPage implements OnInit {
ngOnInit() {
setTimeout(() => {
var videos:NodeListOf<HTMLVideoElement> = document.querySelectorAll(`#C${this.componentId} video`);
try {
// Pause each video
videos.forEach(function (video) {
video.load();
})
} catch(e) {}
}, 100)
this.local.find({documentId: this.documentId}).then(async e => {
if(e.isOk() && e.value.length == 0) {
var result = await this.publicationFileGetByDocumentIdService.execute({
@@ -61,9 +49,11 @@ export class SwiperPage implements OnInit {
if(result.isOk()) {
this.publicationList = result.value.added;
this.makeLoad();
}
} else if(e.isOk()) {
this.publicationList = e.value;
this.makeLoad();
var a = e.value.find(e => e.datePublication != this.datePublication)
if(a) {
@@ -75,12 +65,34 @@ export class SwiperPage implements OnInit {
if(result.isOk()) {
this.publicationList = result.value.added;
this.makeLoad();
}
}
}
});
}
makeLoad() {
// Check if theres at least one video in the publication list
const hasVideo = this.publicationList.some(pub =>
this.checkFileType.checkFileType(pub.extension) === 'video'
);
// If there are no videos, skip everything
if (!hasVideo) return;
// Load all videos after 100ms
setTimeout(() => {
try {
const videos: NodeListOf<HTMLVideoElement> = document.querySelectorAll(
`#C${this.componentId} video`
);
videos.forEach(video => video.load());
} catch (e) {
console.error('Error loading videos:', e);
}
}, 100);
}
ngOnChanges() {
this.onSlideChange()
}
+2 -2
View File
@@ -79,8 +79,8 @@ export class PublicationFolderService {
}
this.publications[id] = this.publications[id].sort((a, b) => {
const dateA = new Date(a.datePublication).getTime();
const dateB = new Date(b.datePublication).getTime();
const dateA = new Date(a.dateIndex).getTime();
const dateB = new Date(b.dateIndex).getTime();
return dateB - dateA; // Revertendo a ordem aqui
});
+6 -6
View File
@@ -1,11 +1,11 @@
export let versionData = {
"shortSHA": "9e3c6db93",
"SHA": "9e3c6db93ab352472ebeb023e65027473b3ab1d4",
"shortSHA": "a9cd4843d",
"SHA": "a9cd4843d53711a2ee60d7d2d49a9632f38ddd39",
"branch": "developer",
"lastCommitAuthor": "'peter.maquiran'",
"lastCommitTime": "'Thu Oct 16 16:09:35 2025 +0100'",
"lastCommitMessage": "fix chat and gabinete",
"lastCommitNumber": "6152",
"changeStatus": "On branch developer\nYour branch is ahead of 'origin/developer' by 9 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/infra/socket/signalR/signalR.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.html\n\tmodified: src/app/shared/gabinete-digital/generic/task-details/task-details.page.html\n\tmodified: src/environments/environment.prod.ts",
"lastCommitTime": "'Fri Oct 17 13:58:05 2025 +0100'",
"lastCommitMessage": "pedido",
"lastCommitNumber": "6153",
"changeStatus": "On branch developer\nYour branch is ahead of 'origin/developer' by 10 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/core/actions/use-case/publication-file-get-by-document-id.service.ts\n\tmodified: src/app/core/actions/use-case/publication-list-by-process-id.service.ts\n\tmodified: src/app/infra/database/dexie/instance/action/service.ts\n\tmodified: src/app/modals/crop-image/crop-image.page.ts\n\tmodified: src/app/pages/publications/publications.page.ts\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts\n\tmodified: src/app/shared/swiper/swiper.page.ts\n\tmodified: src/app/store/publication-folder.service.ts\n\tmodified: version/git-version.ts",
"changeAuthor": "peter.maquiran"
}