Skip to content

Commit

Permalink
Merge pull request #3013 from numbersprotocol/feature-v230822-Remove-…
Browse files Browse the repository at this point in the history
…options-from-list-on-ionic-asset-page

Feature v230822 remove options from list on ionic asset page
  • Loading branch information
sultanmyrza authored Aug 29, 2023
2 parents f90243a + 350403f commit 1f38902
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 163 deletions.
2 changes: 1 addition & 1 deletion src/app/features/home/details/details.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ng-container>
<button
*ngIf="(isFromSeriesPage$ | ngrxPush) === false"
(click)="openOptionsMenuEvenOffline()"
(click)="openOptionsMenuWithAvailableOptions()"
mat-mini-fab
class="capture-rebranded-button"
joyrideStep="highlightDetailsPageOptionsMenu"
Expand Down
217 changes: 55 additions & 162 deletions src/app/features/home/details/details.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ export class DetailsPage {
)
);

readonly postCreationWorkflowCompleted$ = this.activeDetailedCapture$.pipe(
switchMap(c => c.postCreationWorkflowCompleted$)
);

readonly isCollectedCapture$ = this.type$.pipe(
map(type => type === 'post-capture')
);
Expand Down Expand Up @@ -410,70 +414,73 @@ export class DetailsPage {
.subscribe();
}

async openOptionsMenuEvenOffline() {
this.userGuideService.setHasClickedDetailsPageOptionsMenu(true);

this.isCollectedCapture$
async openOptionsMenuWithAvailableOptions() {
combineLatest([
this.networkConnected$,
this.activeDetailedCapture$,
this.postCreationWorkflowCompleted$,
this.isCollectedCapture$,
this.translocoService.selectTranslateObject({
'details.actions.edit': null,
'details.actions.unpublish': null,
'details.actions.networkActions': null,
'details.actions.remove': null,
}),
])
.pipe(
first(),
map(isCollectedCapture => {
return new Promise<void>(resolve => {
map(
([
networkConnected,
activeDetailedCapture,
postCreationWorkflowCompleted,
isCollectedCapture,
[
editActionText,
unpublishActionText,
networkActionsText,
removeActionText,
],
]) => {
const buttons: ActionSheetButton[] = [];

if (!isCollectedCapture) {
if (
networkConnected &&
!isCollectedCapture &&
activeDetailedCapture.id
) {
buttons.push({
text: this.translocoService.translate('details.actions.edit'),
handler: () => {
this.handleEditAction();
resolve();
},
text: editActionText,
handler: () => this.handleEditAction(),
});
}
// Temporarely remove Mint & Share button
// buttons.push({
// text: this.translocoService.translate('details.actions.mintAndShare'),
// handler: () => {
// this.handleMintAndShareAction();
// resolve();
// },
// });

if (!isCollectedCapture) {
if (
networkConnected &&
!isCollectedCapture &&
activeDetailedCapture.id
) {
buttons.push({
text: this.translocoService.translate(
'details.actions.unpublish'
),
handler: () => {
this.handleUnpublishAction();
resolve();
},
text: unpublishActionText,
handler: () => this.handleUnpublishAction(),
});
}
if (networkConnected && postCreationWorkflowCompleted) {
buttons.push({
text: networkActionsText,
handler: () => this.handleOpenNetworkActions(),
});
}

buttons.push({
text: this.translocoService.translate(
'details.actions.networkActions'
),
handler: () => {
this.handleOpenNetworkActions();
resolve();
},
});

buttons.push({
text: this.translocoService.translate('details.actions.remove'),
text: removeActionText,
handler: () => this.handleRemoveAction(),
cssClass: 'details-page-options-menu-remove-button',
handler: () => {
this.handleRemoveAction();
resolve();
},
});

this.actionSheetController
return this.actionSheetController
.create({ buttons })
.then(sheet => sheet.present());
});
})
}
)
)
.subscribe();
}
Expand Down Expand Up @@ -676,120 +683,6 @@ export class DetailsPage {
}
}

openOptionsMenu() {
this.userGuideService.setHasClickedDetailsPageOptionsMenu(true);
combineLatest([
this.activeDetailedCapture$,
this.activeDetailedCapture$.pipe(switchMap(c => c.diaBackendAsset$)),
this.activeDetailedCapture$.pipe(
switchMap(c => c.postCreationWorkflowCompleted$)
),
this.translocoService.selectTranslateObject({
'message.transferOwnership': null,
'message.viewOnCaptureClub': null,
'message.deregisterFromNetwork': null,
'message.mintNftToken': null,
'message.viewAssetProfile': null,
'message.viewSupportingVideoOnIpfs': null,
networkActions: null,
}),
])
.pipe(
first(),
concatMap(
([
detailedCapture,
diaBackendAsset,
postCreationWorkflowCompleted,
[
messageTransferOwnership,
messageViewOnCaptureClub,
messageDeregisterFromNetwork,
messageMintNftToken,
messageviewAssetProfile,
messageViewSupportingVideoOnIpfs,
messageNetworkActions,
],
]) =>
new Promise<void>(resolve => {
const buttons: ActionSheetButton[] = [];
if (
postCreationWorkflowCompleted &&
diaBackendAsset?.supporting_file
) {
buttons.push({
text: messageViewSupportingVideoOnIpfs,
handler: () => {
this.openIpfsSupportingVideo();
},
});
}
if (postCreationWorkflowCompleted && detailedCapture.id) {
buttons.push({
text: messageTransferOwnership,
handler: () => {
this.openContactSelectionDialog();
resolve();
},
});
}
if (diaBackendAsset?.source_type === 'store') {
buttons.push({
text: messageViewOnCaptureClub,
handler: () => {
this.openCaptureClub();
},
});
}
buttons.push({
text: messageDeregisterFromNetwork,
handler: () => {
this.remove().then(() => resolve());
},
});
if (
postCreationWorkflowCompleted &&
diaBackendAsset?.nft_token_id === null
) {
buttons.push({
text: messageMintNftToken,
handler: () => {
this.mintNft().then(() => resolve());
},
role: 'destructive',
});
}
if (postCreationWorkflowCompleted && detailedCapture.id) {
buttons.push({
text: messageviewAssetProfile,
handler: () => {
this.openCertificate();
resolve();
},
});
}
if (postCreationWorkflowCompleted) {
buttons.push({
text: messageNetworkActions,
handler: () => {
this.router.navigate(
['actions', { id: detailedCapture.id }],
{ relativeTo: this.route }
);
resolve();
},
});
}
this.actionSheetController
.create({ buttons })
.then(sheet => sheet.present());
})
),
untilDestroyed(this)
)
.subscribe();
}

private openIpfsSupportingVideo() {
return this.activeDetailedCapture$
.pipe(
Expand Down

0 comments on commit 1f38902

Please sign in to comment.