Skip to content

Commit

Permalink
Merge pull request #3211 from numbersprotocol/v240206-capture-cam-ion…
Browse files Browse the repository at this point in the history
…ic-internal

V240206 capture cam ionic internal
  • Loading branch information
sultanmyrza authored Feb 15, 2024
2 parents fe0c806 + 3a54d64 commit 6312ad9
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 34 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "io.numbersprotocol.capturelite"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 888
versionName "0.88.8"
versionCode 891
versionName "0.89.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
Expand Down
8 changes: 4 additions & 4 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,13 @@
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 888;
CURRENT_PROJECT_VERSION = 891;
DEVELOPMENT_TEAM = G7NB5YCKAP;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = G7NB5YCKAP;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.88.8;
MARKETING_VERSION = 0.89.1;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = io.numbersprotocol.capturelite;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -395,13 +395,13 @@
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 888;
CURRENT_PROJECT_VERSION = 891;
DEVELOPMENT_TEAM = G7NB5YCKAP;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = G7NB5YCKAP;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.88.8;
MARKETING_VERSION = 0.89.1;
PRODUCT_BUNDLE_IDENTIFIER = io.numbersprotocol.capturelite;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = NumbersAppDistributionV4;
Expand Down
2 changes: 1 addition & 1 deletion ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 24ca1bcaa3932b2d964431fb23583535c4454ed9

COCOAPODS: 1.12.1
COCOAPODS: 1.14.3
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "capture-lite",
"version": "0.88.8",
"version": "0.89.1",
"author": "numbersprotocol",
"homepage": "https://numbersprotocol.io/",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ export class CaptureItemComponent {
)
);

readonly hasCaption$ = this.proof$.pipe(
switchMap(proof => this.diaBackendAssetRepository.fetchByProof$(proof)),
map(asset => asset.caption !== '')
);
readonly hasCaption$ = this.proof$.pipe(map(proof => proof.caption !== ''));

readonly isVideo$ = this.proof$.pipe(
concatMap(proof => proof.getFirstAssetMeta()),
Expand Down
55 changes: 40 additions & 15 deletions src/app/features/home/capture-tab/capture-tab.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { formatDate, KeyValue } from '@angular/common';
import { HttpErrorResponse } from '@angular/common/http';
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
import {
ActionSheetButton,
Expand All @@ -15,7 +16,6 @@ import {
catchError,
concatMap,
concatMapTo,
finalize,
map,
pluck,
shareReplay,
Expand All @@ -35,6 +35,7 @@ import {
DiaBackendAssetRepository,
} from '../../../shared/dia-backend/asset/dia-backend-asset-repository.service';
import { DiaBackendAsseRefreshingService } from '../../../shared/dia-backend/asset/refreshing/dia-backend-asset-refreshing.service';
import { DiaBackendAssetUploadingService } from '../../../shared/dia-backend/asset/uploading/dia-backend-asset-uploading.service';
import { DiaBackendAuthService } from '../../../shared/dia-backend/auth/dia-backend-auth.service';
import { DiaBackendTransactionRepository } from '../../../shared/dia-backend/transaction/dia-backend-transaction-repository.service';
import { ErrorService } from '../../../shared/error/error.service';
Expand All @@ -45,6 +46,7 @@ import { getOldProof } from '../../../shared/repositories/proof/old-proof-adapte
import { Proof } from '../../../shared/repositories/proof/proof';
import { ProofRepository } from '../../../shared/repositories/proof/proof-repository.service';
import { reloadApp } from '../../../utils/miscellaneous';
import { PrefetchingDialogComponent } from '../onboarding/prefetching-dialog/prefetching-dialog.component';

@UntilDestroy({ checkProperties: true })
@Component({
Expand Down Expand Up @@ -152,12 +154,15 @@ export class CaptureTabComponent implements OnInit {
)
);

private pendingUploadTasks = 0;

constructor(
private readonly actionSheetController: ActionSheetController,
private readonly router: Router,
private readonly mediaStore: MediaStore,
private readonly database: Database,
private readonly confirmAlert: ConfirmAlert,
private readonly dialog: MatDialog,
private readonly preferenceManager: PreferenceManager,
private readonly changeDetectorRef: ChangeDetectorRef,
private readonly proofRepository: ProofRepository,
Expand All @@ -170,8 +175,13 @@ export class CaptureTabComponent implements OnInit {
private readonly translocoService: TranslocoService,
private readonly errorService: ErrorService,
private readonly blockingActionService: BlockingActionService,
private readonly captureTabService: CaptureTabService
) {}
private readonly captureTabService: CaptureTabService,
private readonly uploadService: DiaBackendAssetUploadingService
) {
this.uploadService.pendingTasks$
.pipe(untilDestroyed(this))
.subscribe(value => (this.pendingUploadTasks = value));
}

ngOnInit(): void {
this.initSegmentListener();
Expand Down Expand Up @@ -334,17 +344,32 @@ export class CaptureTabComponent implements OnInit {
return item.id;
}

refreshCaptures(event: Event) {
this.diaBackendAssetRefreshingService
.refresh()
.pipe(
finalize(() => {
this.capturedTabPageIndex$.next(0);
this.collectedTabPageIndex$.next(0);
this.draftTabPageIndex$.next(0);
return (<CustomEvent>event).detail.complete();
})
)
.subscribe();
async refreshCaptures(event: Event) {
(<CustomEvent>event).detail.complete();

// Don't refresh if there are still captures being uploaded.
if (this.pendingUploadTasks > 0) return;

const confirmRefresh = await this.showRefreshAlert();
if (confirmRefresh) {
this.capturedTabPageIndex$.next(0);
this.collectedTabPageIndex$.next(0);
this.draftTabPageIndex$.next(0);

return this.dialog.open(PrefetchingDialogComponent, {
disableClose: true,
});
}
}

private async showRefreshAlert() {
return this.confirmAlert.present({
header: this.translocoService.translate('syncAndRestore'),
message: this.translocoService.translate('message.confirmSyncAndRestore'),
confirmButtonText: this.translocoService.translate(
'confirmSyncAndRestore'
),
cancelButtonText: this.translocoService.translate('cancelSyncAndRestore'),
});
}
}
45 changes: 40 additions & 5 deletions src/app/features/home/details/edit-caption/edit-caption.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ import { DomSanitizer } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { NavController } from '@ionic/angular';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { combineLatest, fromEvent } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { combineLatest, fromEvent, of } from 'rxjs';
import {
concatMap,
finalize,
first,
map,
tap as switchTap,
} from 'rxjs/operators';
import { DiaBackendAuthService } from '../../../../shared/dia-backend/auth/dia-backend-auth.service';
import { BUBBLE_IFRAME_URL } from '../../../../shared/dia-backend/secret';
import { BubbleToIonicPostMessage } from '../../../../shared/iframe/iframe';
import { IframeService } from '../../../../shared/iframe/iframe.service';
import { getOldProof } from '../../../../shared/repositories/proof/old-proof-adapter';
import { ProofRepository } from '../../../../shared/repositories/proof/proof-repository.service';
import { isNonNullable } from '../../../../utils/rx-operators/rx-operators';
import { InformationSessionService } from '../information/session/information-session.service';

@UntilDestroy()
@Component({
Expand Down Expand Up @@ -43,15 +52,17 @@ export class EditCaptionPage {
private readonly sanitizer: DomSanitizer,
private readonly navController: NavController,
private readonly iframeService: IframeService,
private readonly diaBackendAuthService: DiaBackendAuthService
private readonly diaBackendAuthService: DiaBackendAuthService,
private readonly informationSessionService: InformationSessionService,
private readonly proofRepository: ProofRepository
) {
this.processIframeEvents();
}

processIframeEvents() {
fromEvent(window, 'message')
.pipe(
tap(event => {
switchTap(event => {
const postMessageEvent = event as MessageEvent;
const data = postMessageEvent.data as BubbleToIonicPostMessage;
switch (data) {
Expand All @@ -60,12 +71,36 @@ export class EditCaptionPage {
break;
case BubbleToIonicPostMessage.EDIT_CAPTION_SAVE:
this.iframeService.refreshDetailsPageIframe();
this.navController.back();
this.syncCaptionAndNavigateBack();
break;
}
}),
untilDestroyed(this)
)
.subscribe();
}

syncCaptionAndNavigateBack() {
if (this.informationSessionService.activatedDetailedCapture) {
combineLatest([
this.informationSessionService.activatedDetailedCapture.proof$,
this.informationSessionService.activatedDetailedCapture.caption$,
])
.pipe(
first(),
concatMap(([proof, latestCaptionFromBackend]) => {
if (proof) {
proof.caption = latestCaptionFromBackend;
return this.proofRepository.update(
[proof],
(x, y) => getOldProof(x).hash === getOldProof(y).hash
);
}
return of(null);
}),
finalize(() => this.navController.back())
)
.subscribe();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class DiaBackendAssetDownloadingService {
},
});
proof.diaBackendAssetId = diaBackendAsset.id;
proof.caption = diaBackendAsset.caption;
if (diaBackendAsset.signed_metadata) proof.setSignatureVersion();
return this.proofRepository.add(proof, OnConflictStrategy.REPLACE);
}
Expand Down
9 changes: 9 additions & 0 deletions src/app/shared/repositories/proof/proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export class Proof {

diaBackendAssetId?: string = undefined;

/**
* When user uploades a capture we do not have option to set caption. Therefore caption is empty
* by default. Everytime caption is updated we need to update the caption in the proof as well.
*/
caption = '';

isCollected = false;

signatures: Signatures = {};
Expand Down Expand Up @@ -120,6 +126,7 @@ export class Proof {
);
proof.setIndexedAssets(indexedProofView.indexedAssets);
proof.diaBackendAssetId = indexedProofView.diaBackendAssetId;
proof.caption = indexedProofView.caption ?? '';
proof.isCollected = indexedProofView.isCollected ?? false;
proof.signatureVersion = indexedProofView.signatureVersion;
proof.integritySha = indexedProofView.integritySha;
Expand Down Expand Up @@ -290,6 +297,7 @@ export class Proof {
signatures: this.signatures,
signatureVersion: this.signatureVersion,
diaBackendAssetId: this.diaBackendAssetId,
caption: this.caption,
isCollected: this.isCollected,
integritySha: this.integritySha,
cameraSource: this.cameraSource,
Expand Down Expand Up @@ -424,6 +432,7 @@ export interface IndexedProofView extends Tuple {
readonly signatures: Signatures;
readonly signatureVersion?: string;
readonly diaBackendAssetId?: string;
readonly caption?: string;
readonly isCollected?: boolean;
readonly integritySha?: string;
readonly cameraSource: CameraSource;
Expand Down
4 changes: 4 additions & 0 deletions src/assets/i18n/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
"restorePhotos": "Restore Captures",
"restore": "Restore",
"skip": "Skip",
"syncAndRestore": "Sync and restore all assets?",
"confirmSyncAndRestore": "Confirm",
"cancelSyncAndRestore": "Do it later",
"contactUs": "Contact us",
"editUsername": "Edit Username",
"forgotPassword": "Forgot Password",
Expand Down Expand Up @@ -169,6 +172,7 @@
"networkNotConnected": "No internet connections.",
"allPhotosRegistered": "All Captures registered on blockchain successfully",
"confirmPrefetch": "Do you want to restore the registered Captures? It may take minutes to complete.",
"confirmSyncAndRestore": "This will download all assets and making sure your local data is up to date",
"loadingPreviousData": "Restoring Captures...",
"doNotTurnOffApp": "Please keep the screen on and DO NOT leave the app.",
"upgrading": "Upgrading...",
Expand Down
4 changes: 4 additions & 0 deletions src/assets/i18n/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
"restorePhotos": "恢復已註冊的瞬時影像",
"restore": "恢復",
"skip": "跳過",
"syncAndRestore": "遠端同步並還原所有資產?",
"confirmSyncAndRestore": "確認",
"cancelSyncAndRestore": "稍後再說",
"contactUs": "聯絡我們",
"editUsername": "修改使用者名稱",
"forgotPassword": "忘記密碼",
Expand Down Expand Up @@ -169,6 +172,7 @@
"networkNotConnected": "沒有網路連線",
"allPhotosRegistered": "所有瞬時影像都已成功註冊",
"confirmPrefetch": "是否要恢復已註冊的瞬時影像?這個流程需要數分鐘的時間。",
"confirmSyncAndRestore": "這將重新下載所有資產,並確保您的本地數據是最新的。",
"loadingPreviousData": "正在恢復已註冊的瞬時影像...",
"doNotTurnOffApp": "載入中,期間請勿關閉螢幕與離開 APP。",
"upgrading": "升級中...",
Expand Down

0 comments on commit 6312ad9

Please sign in to comment.