diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts index 4b100fc7f..0e3e7a611 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -31,6 +31,9 @@ import { File } from '@ionic-native/file/ngx'; import { Media } from '@ionic-native/media/ngx'; import { checkFileTypeService } from 'src/app/services/checkFileType.service'; import { FileValidatorService } from "src/app/services/file/file-validator.service" +import { App } from '@capacitor/app'; +import { Router } from '@angular/router'; + const config = { quality: 0.5, maxWidth: 800, @@ -133,7 +136,8 @@ export class NewPublicationPage implements OnInit { public FileService: FileService, private mediaCapture: MediaCapture, public checkFileType: checkFileTypeService, - private FileValidatorService: FileValidatorService + private FileValidatorService: FileValidatorService, + private router: Router, ) { this.publicationType = this.navParams.get('publicationType'); @@ -536,11 +540,12 @@ export class NewPublicationPage implements OnInit { await this.publications.CreatePublication(this.folderId, this.publication).toPromise(); - this.close(); this.httpErrorHandle.httpsSucessMessagge('Criar publicação') - window["sharedContent"] = null; - window["endSharedContent"] = null; - + if(window["sharedContent"]) { + this.router.navigate(['/home/publications', this.folderId]); + return + } + this.close(); } catch (error) { this.httpErrorHandle.httpStatusHandle(error) @@ -562,6 +567,10 @@ export class NewPublicationPage implements OnInit { this.modalController.dismiss(this.publication).then(() => { this.showLoader = true; }); + + if(window["sharedContent"]) { + this.closeApp(); + } } clear() { @@ -782,5 +791,9 @@ export class NewPublicationPage implements OnInit { this.seletedContent.splice(index, 1) } + closeApp() { + App.exitApp() + } + } diff --git a/src/app/pages/publications/publications.page.html b/src/app/pages/publications/publications.page.html index 60591173b..391c47e29 100644 --- a/src/app/pages/publications/publications.page.html +++ b/src/app/pages/publications/publications.page.html @@ -24,7 +24,7 @@ --> -
diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index f81d448cc..2287fc8bf 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -349,7 +349,7 @@ export class PublicationsPage implements OnInit { componentProps: { publicationType: publicationType, folderId: folderId, - intent: intent + intent: window["sharedContent"] }, cssClass: 'new-publication modal modal-desktop', backdropDismiss: false @@ -362,8 +362,8 @@ export class PublicationsPage implements OnInit { } goToPublicationsList(folderId: string) { - if(this.intent){ - this.AddPublication('2',folderId,this.intent) + if(window["sharedContent"]){ + this.AddPublication('2',folderId,window["sharedContent"]) return } if (window.innerWidth < 701) { diff --git a/src/app/pages/publications/view-publications/view-publications.page.ts b/src/app/pages/publications/view-publications/view-publications.page.ts index 247a1ca9f..cc12b5a37 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.ts +++ b/src/app/pages/publications/view-publications/view-publications.page.ts @@ -1,6 +1,6 @@ import { Component, ElementRef, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; -import { ModalController,IonicSlides } from '@ionic/angular'; +import { ModalController, IonicSlides } from '@ionic/angular'; import { Publication } from 'src/app/models/publication'; import { PublicationFolder } from 'src/app/models/publicationfolder'; import { PublicationPipe } from 'src/app/pipes/publication.pipe'; @@ -16,9 +16,10 @@ import { Storage } from '@ionic/storage'; import { PublicationFolderService } from 'src/app/store/publication-folder.service'; // import { CapacitorVideoPlayer } from 'capacitor-video-player'; import { checkFileTypeService } from 'src/app/services/checkFileType.service'; -import { PublicationVideoManagerService } from "src/app/services/publication/publication-video-manager.service" +import { PublicationVideoManagerService } from "src/app/services/publication/publication-video-manager.service" import { StopvideoService } from "src/app/services/stopvideo.service" import { Result } from 'neverthrow'; +import { App } from '@capacitor/app'; @Component({ selector: 'app-view-publications', templateUrl: './view-publications.page.html', @@ -43,7 +44,7 @@ export class ViewPublicationsPage implements OnInit { initialSlide: 0, speed: 400, loop: true, - pagination : { + pagination: { el: '.swiper-pagination', clickable: true } @@ -70,13 +71,13 @@ export class ViewPublicationsPage implements OnInit { public stopvideoService: StopvideoService) { - /* this.publicationVideoManagerService.setContainer(this.VideoManager.nativeElement) */ + /* this.publicationVideoManagerService.setContainer(this.VideoManager.nativeElement) */ - setTimeout(() => { + setTimeout(() => { - console.log(this.VideoManager.nativeElement) - }, 2000) + console.log(this.VideoManager.nativeElement) + }, 2000) this.createPublicationList() @@ -122,7 +123,7 @@ export class ViewPublicationsPage implements OnInit { onVisibilityChange = (e: boolean) => { console.log("nice to have", e) - if(!e) { + if (!e) { this.stopVideo() } } @@ -131,26 +132,30 @@ export class ViewPublicationsPage implements OnInit { stopVideo() { var videos = document.querySelectorAll('video'); - // Pause each video - videos.forEach(function (video) { - video.pause(); - }) + try { + // Pause each video + videos.forEach(function (video) { + video.pause(); + }) - this.videoElements.forEach(videoElement => { - // You can access the native HTML video element using videoElement.nativeElement - const video: HTMLVideoElement = videoElement.nativeElement; + this.videoElements.forEach(videoElement => { + // You can access the native HTML video element using videoElement.nativeElement + const video: HTMLVideoElement = videoElement.nativeElement; - video.pause() - // Do something with each video element - // console.log(video); - }); + video.pause() + // Do something with each video element + // console.log(video); + }); + } catch (error) { + console.log(error) + } } ngOnChanges() { if (typeof (this.folderId) == 'object') { - this.folderId = (this.folderId as any )['ProcessId'] + this.folderId = (this.folderId as any)['ProcessId'] } this.createPublicationList() @@ -186,6 +191,10 @@ export class ViewPublicationsPage implements OnInit { } goBack() { + if (window["sharedContent"]) { + App.exitApp(); + return + } this.router.navigate(['/home/publications']); } @@ -274,13 +283,13 @@ export class ViewPublicationsPage implements OnInit { } else { - let a: any = Object.assign({},this.publicationFolderService.publicationList[folderId][findIndex]) + let a: any = Object.assign({}, this.publicationFolderService.publicationList[folderId][findIndex]) let b: any = Object.assign({}, publicationDetails) a.Files = a.Files.length b.Files = b.Files.length - if(JSON.stringify(a) != JSON.stringify(b)) { + if (JSON.stringify(a) != JSON.stringify(b)) { // console.log({a, b}) this.publicationFolderService.publicationList[folderId][findIndex] = publicationDetails @@ -350,9 +359,9 @@ export class ViewPublicationsPage implements OnInit { } - getSortedPublications(): Publication[] { + getSortedPublications(): Publication[] { const unsortedPublications = this.publicationFolderService.publicationList[this.folderId]; - + if (unsortedPublications) { // Copiar a lista original para evitar alterações indesejadas const publicationsCopy = [...unsortedPublications]; diff --git a/src/app/services/chunkService.ts b/src/app/services/chunkService.ts new file mode 100644 index 000000000..6f8bc75f9 --- /dev/null +++ b/src/app/services/chunkService.ts @@ -0,0 +1,53 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) + +export class ChunksService { + + chunkSize: number + private file: File + + constructor() { + + } + + get totalChunks () { + return Math.ceil(this.file.size / this.chunkSize); + } + + // Function to read a chunk of the file + readChunk(start: number, end: number): Promise