Skip to content

Commit 15f839b

Browse files
authored
Merge pull request #1422 from numbersprotocol/develop
Bump version to 0.52.0
2 parents bbd2fa8 + 99d7999 commit 15f839b

File tree

13 files changed

+249
-67
lines changed

13 files changed

+249
-67
lines changed

.github/workflows/pre-release.yml

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,77 @@ jobs:
151151
name: ios-build-number
152152
path: build/ios-build-number.txt
153153

154+
build-apks-upload-google-drive:
155+
runs-on: ubuntu-latest
156+
strategy:
157+
matrix:
158+
include:
159+
- folder_name: storage-dev-bubble-qa
160+
storage_base_url: NUMBERS_STORAGE_DEV_BASE_URL
161+
storage_trusted_client_key: NUMBERS_STORAGE_DEV_TRUSTED_CLIENT_KEY
162+
bubble_db_url: NUMBERS_BUBBLE_DB_QA_URL
163+
- folder_name: storage-qa-bubble-qa
164+
storage_base_url: NUMBERS_STORAGE_QA_BASE_URL
165+
storage_trusted_client_key: NUMBERS_STORAGE_QA_TRUSTED_CLIENT_KEY
166+
bubble_db_url: NUMBERS_BUBBLE_DB_QA_URL
167+
- folder_name: storage-prod-bubble-qa
168+
storage_base_url: NUMBERS_STORAGE_BASE_URL
169+
storage_trusted_client_key: NUMBERS_STORAGE_TRUSTED_CLIENT_KEY
170+
bubble_db_url: NUMBERS_BUBBLE_DB_QA_URL
171+
- folder_name: storage-dev-bubble-prod
172+
storage_base_url: NUMBERS_STORAGE_DEV_BASE_URL
173+
storage_trusted_client_key: NUMBERS_STORAGE_DEV_TRUSTED_CLIENT_KEY
174+
bubble_db_url: NUMBERS_BUBBLE_DB_URL
175+
- folder_name: storage-qa-bubble-prod
176+
storage_base_url: NUMBERS_STORAGE_QA_BASE_URL
177+
storage_trusted_client_key: NUMBERS_STORAGE_QA_TRUSTED_CLIENT_KEY
178+
bubble_db_url: NUMBERS_BUBBLE_DB_URL
179+
- folder_name: storage-prod-bubble-prod
180+
storage_base_url: NUMBERS_STORAGE_BASE_URL
181+
storage_trusted_client_key: NUMBERS_STORAGE_TRUSTED_CLIENT_KEY
182+
bubble_db_url: NUMBERS_BUBBLE_DB_URL
183+
steps:
184+
- uses: actions/checkout@v2
185+
186+
- uses: actions/setup-node@v2
187+
with:
188+
node-version: '16'
189+
190+
- name: Check if version has been updated
191+
id: version_check
192+
uses: EndBug/version-check@v2
193+
with:
194+
diff-search: true
195+
token: ${{ secrets.GITHUB_TOKEN }}
196+
197+
- name: Build Ionic
198+
env:
199+
NUMBERS_STORAGE_BASE_URL: ${{ secrets[matrix.storage_base_url] }}
200+
NUMBERS_STORAGE_TRUSTED_CLIENT_KEY: ${{ secrets[matrix.storage_trusted_client_key] }}
201+
NUMBERS_BUBBLE_DB_URL: ${{ secrets[matrix.bubble_db_url] }}
202+
run: |
203+
npm install -g @ionic/cli
204+
npm install
205+
npm run build
206+
207+
- name: Build APKs
208+
run: |
209+
npx cap sync android
210+
cd android/
211+
./gradlew assembleDebug
212+
213+
- name: Upload matrix build outputs to Google Drive
214+
uses: numbersprotocol/action-google-drive@master
215+
with:
216+
skicka-tokencache-json: ${{ secrets.SKICKA_TOKENCACHE_JSON }}
217+
google-client-id: ${{ secrets.SKICKA_GOOGLE_CLIENT_ID }}
218+
google-client-secret: ${{ secrets.SKICKA_GOOGLE_CLIENT_SECRET }}
219+
upload-from: ./android/app/build/outputs/apk/debug/
220+
upload-to: /capture-lite/apk/${{ steps.version_check.outputs.version }}/${{ matrix.folder_name }}/
221+
154222
create-github-release:
155223
runs-on: ubuntu-latest
156-
needs: [deploy-play-store, deploy-app-store]
224+
needs: [deploy-play-store, deploy-app-store, build-apks-upload-google-drive]
157225
steps:
158226
- uses: actions/checkout@v2
159227

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.52.0 - 2022-03-25
9+
10+
### Changed
11+
12+
- Replace share option "Share C2PA Photo" with "Share Asset Profile"
13+
14+
### Fixed
15+
16+
- Prevent user from performing List in CaptureClub with the same asset twice.
17+
818
## 0.51.1 - 2022-03-23
919

1020
### Fixed

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
applicationId "io.numbersprotocol.capturelite"
77
minSdkVersion rootProject.ext.minSdkVersion
88
targetSdkVersion rootProject.ext.targetSdkVersion
9-
versionCode 341
10-
versionName "0.51.1"
9+
versionCode 350
10+
versionName "0.52.0"
1111
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {

package-lock.json

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "capture-lite",
3-
"version": "0.51.1",
3+
"version": "0.52.0",
44
"author": "numbersprotocol",
55
"homepage": "https://numbersprotocol.io/",
66
"scripts": {

src/app/features/home/details/actions/actions.page.ts

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { MatSnackBar } from '@angular/material/snack-bar';
44
import { ActivatedRoute } from '@angular/router';
55
import { TranslocoService } from '@ngneat/transloco';
66
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
7-
import { combineLatest, of } from 'rxjs';
8-
import { catchError, concatMap, first, map, tap } from 'rxjs/operators';
7+
import { combineLatest, forkJoin, of } from 'rxjs';
8+
import { catchError, concatMap, first, map, take, tap } from 'rxjs/operators';
99
import { ActionsDialogComponent } from '../../../../shared/actions/actions-dialog/actions-dialog.component';
1010
import {
1111
Action,
@@ -14,13 +14,17 @@ import {
1414
import { OrderHistoryService } from '../../../../shared/actions/service/order-history.service';
1515
import { BlockingActionService } from '../../../../shared/blocking-action/blocking-action.service';
1616
import { DiaBackendAuthService } from '../../../../shared/dia-backend/auth/dia-backend-auth.service';
17+
import { DiaBackendSeriesRepository } from '../../../../shared/dia-backend/series/dia-backend-series-repository.service';
1718
import {
1819
DiaBackendStoreService,
1920
NetworkAppOrder,
2021
} from '../../../../shared/dia-backend/store/dia-backend-store.service';
2122
import { ErrorService } from '../../../../shared/error/error.service';
2223
import { OrderDetailDialogComponent } from '../../../../shared/order-detail-dialog/order-detail-dialog.component';
23-
import { isNonNullable } from '../../../../utils/rx-operators/rx-operators';
24+
import {
25+
isNonNullable,
26+
VOID$,
27+
} from '../../../../utils/rx-operators/rx-operators';
2428

2529
@UntilDestroy()
2630
@Component({
@@ -34,7 +38,8 @@ export class ActionsPage {
3438
.pipe(catchError((err: unknown) => this.errorService.toastError$(err)));
3539

3640
private readonly id$ = this.route.paramMap.pipe(
37-
map(params => params.get('id'))
41+
map(params => params.get('id')),
42+
isNonNullable()
3843
);
3944

4045
constructor(
@@ -47,9 +52,71 @@ export class ActionsPage {
4752
private readonly snackBar: MatSnackBar,
4853
private readonly dialog: MatDialog,
4954
private readonly storeService: DiaBackendStoreService,
50-
private readonly orderHistoryService: OrderHistoryService
55+
private readonly orderHistoryService: OrderHistoryService,
56+
private readonly diaBackendStoreService: DiaBackendStoreService,
57+
private readonly diaBackendSeriesRepository: DiaBackendSeriesRepository
5158
) {}
5259

60+
canPerformAction$(action: Action) {
61+
if (action.title_text === 'List in CaptureClub') {
62+
/*
63+
Workaround:
64+
Currently there isn't a simple way to check whether an asset is listed in
65+
CaptureClub or not. So I first query List all Products API with
66+
associated_id parameter set to the assets cid. And then use list series
67+
API and check through all nested collections. See discussion here
68+
https://app.asana.com/0/0/1201558520076805/1201995911008176/f
69+
*/
70+
return this.id$.pipe(
71+
concatMap(cid =>
72+
forkJoin([
73+
this.diaBackendStoreService.listAllProducts$({
74+
associated_id: cid,
75+
service_name: 'CaptureClub',
76+
}),
77+
of(cid),
78+
])
79+
),
80+
concatMap(([response, cid]) => {
81+
if (response.count > 0) {
82+
throw new Error(
83+
this.translocoService.translate('message.hasListedInCaptureClub')
84+
);
85+
}
86+
return of(cid);
87+
}),
88+
concatMap(async cid => {
89+
let currentOffset = 0;
90+
const limit = 100;
91+
while (true) {
92+
const response = await this.diaBackendSeriesRepository
93+
.fetchAll$({ offset: currentOffset, limit })
94+
.toPromise();
95+
const listedAsSeries = response.results.some(serie =>
96+
serie.collections.some(collection =>
97+
collection.assets.some(asset => asset.cid === cid)
98+
)
99+
);
100+
if (listedAsSeries) {
101+
throw new Error(
102+
this.translocoService.translate(
103+
'message.hasListedInCaptureClub'
104+
)
105+
);
106+
}
107+
if (response.next == null) {
108+
break;
109+
}
110+
currentOffset += response.results.length;
111+
}
112+
return VOID$;
113+
}),
114+
take(1)
115+
);
116+
}
117+
return VOID$;
118+
}
119+
53120
openActionDialog$(action: Action) {
54121
return combineLatest([
55122
this.actionsService.getParams$(action.params_list_custom_param1),
@@ -128,8 +195,13 @@ export class ActionsPage {
128195
}
129196

130197
doAction(action: Action) {
131-
this.openActionDialog$(action)
198+
this.blockingActionService
199+
.run$(this.canPerformAction$(action))
132200
.pipe(
201+
catchError((err: unknown) => {
202+
return this.errorService.toastError$(err);
203+
}),
204+
concatMap(() => this.openActionDialog$(action)),
133205
concatMap(createOrderInput =>
134206
this.blockingActionService.run$(
135207
this.createOrder$(

src/app/features/home/details/details.page.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
switchTap,
3737
VOID$,
3838
} from '../../../utils/rx-operators/rx-operators';
39+
import { getAssetProfileUrl } from '../../../utils/url';
3940
import {
4041
DetailedCapture,
4142
InformationSessionService,
@@ -256,7 +257,7 @@ export class DetailsPage {
256257
this.activeDetailedCapture$.pipe(switchMap(c => c.diaBackendAsset$)),
257258
this.translocoService.selectTranslateObject({
258259
'message.copyIpfsAddress': null,
259-
'message.shareC2paPhoto': null,
260+
'message.shareAssetProfile': null,
260261
}),
261262
])
262263
.pipe(
@@ -458,7 +459,8 @@ export class DetailsPage {
458459
concatMap(([detailedCapture, token]) =>
459460
defer(() =>
460461
Browser.open({
461-
url: `https://authmedia.net/asset-profile?cid=${detailedCapture.id}&token=${token}`,
462+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
463+
url: getAssetProfileUrl(detailedCapture.id!, token),
462464
toolbarColor: '#564dfc',
463465
})
464466
)

src/app/shared/dia-backend/series/dia-backend-series-repository.service.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import { BASE_URL } from '../secret';
1010
providedIn: 'root',
1111
})
1212
export class DiaBackendSeriesRepository {
13-
private readonly fetchCollectedSeriesCount$ = this.fetch$({
13+
private readonly fetchCollectedSeriesCount$ = this.fetchAll$({
1414
limit: 1,
1515
collected: true,
1616
}).pipe(pluck('count'));
1717

1818
readonly fetchCollectedSeriesList$ = this.fetchCollectedSeriesCount$.pipe(
19-
switchMap(count => this.fetch$({ limit: count, collected: true }))
19+
switchMap(count => this.fetchAll$({ limit: count, collected: true }))
2020
);
2121

2222
constructor(
@@ -28,23 +28,16 @@ export class DiaBackendSeriesRepository {
2828
return this.read$(id);
2929
}
3030

31-
private fetch$({
32-
limit,
33-
collected,
34-
}: {
35-
limit?: number;
36-
collected?: boolean;
37-
}) {
31+
fetchAll$(
32+
queryParams: {
33+
limit?: number;
34+
collected?: boolean;
35+
offset?: number;
36+
} = {}
37+
) {
3838
return defer(() => this.authService.getAuthHeaders()).pipe(
3939
concatMap(headers => {
40-
let params = new HttpParams();
41-
42-
if (limit !== undefined) {
43-
params = params.set('limit', `${limit}`);
44-
}
45-
if (collected !== undefined) {
46-
params = params.set('collected', `${collected}`);
47-
}
40+
const params = new HttpParams({ fromObject: queryParams });
4841
return this.httpClient.get<PaginatedResponse<DiaBackendSeries>>(
4942
`${BASE_URL}/api/v3/series/`,
5043
{ headers, params }
@@ -70,6 +63,7 @@ export interface DiaBackendSeries {
7063
readonly collections: {
7164
readonly assets: {
7265
readonly id: string;
66+
readonly cid: string;
7367
readonly asset_file_thumbnail: string;
7468
readonly collected: boolean;
7569
}[];

0 commit comments

Comments
 (0)