Skip to content

Commit

Permalink
Merge branch 'develop' into amenconi-nft-bulk-transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
amenconi authored Feb 28, 2024
2 parents 5a48cda + d0c1d68 commit 8b27b9e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 31 deletions.
27 changes: 9 additions & 18 deletions src/app/@api/file.api.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '@env/environment';
import {
FILE_SIZES,
BUILD5_PROD_ADDRESS_API,
BUILD5_TEST_ADDRESS_API,
WEN_FUNC,
} from '@build-5/interfaces';
import { FILE_SIZES } from '@build-5/interfaces';
import { NzUploadXHRArgs } from 'ng-zorro-antd/upload';
import { Observable, map, of } from 'rxjs';
import { Build5, https } from '@build-5/sdk';

const EXTENSION_PAT = /\.[^/.]+$/;
const ORIGIN = environment.production ? Build5.PROD : Build5.TEST;

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -42,22 +39,16 @@ export class FileApi {
return of(url.match('.mp4$') ? 'video' : 'image');
};

public upload(memberId: string, item: NzUploadXHRArgs) {
const formData = new FormData();
formData.append('file', <Blob>item.postFile);
formData.append('member', memberId);
formData.append('uid', item.file.uid);
formData.append('projectApiKey', environment.build5Token);
const origin = environment.production ? BUILD5_PROD_ADDRESS_API : BUILD5_TEST_ADDRESS_API;
return this.httpClient
.post(origin + WEN_FUNC.uploadFile, formData)
public upload = (memberId: string, item: NzUploadXHRArgs) =>
https(ORIGIN)
.project(environment.build5Token)
.uploadFile(<Blob>item.postFile, memberId, item.file.uid)
.pipe(
map((b: any) => {
map((r) => {
if (item.onSuccess) {
item.onSuccess(b.data.url, item.file, b.data.url);
item.onSuccess(r.url, item.file, r.url);
}
}),
)
.subscribe();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input } from '@angular/core';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { DEFAULT_NETWORK, NETWORK_DETAIL, Network, WEN_NAME } from '@build-5/interfaces';
import { NETWORK_DETAIL, Network, WEN_NAME } from '@build-5/interfaces';

@Component({
selector: 'wen-wallet-deeplink',
Expand Down Expand Up @@ -90,11 +90,9 @@ export class WalletDeeplinkComponent {
}

private getBloomDeepLink(): SafeUrl {
if (!this._network || this._network === Network.IOTA || this._network === Network.ATOI) {
// TODO: IOTA network support in Bloom
if (!this._network) {
return '';
} else {
// Shimmer Network
const parameters = {
address: this.targetAddress,
baseCoinAmount: Number(this.targetAmount ?? 0).toFixed(0),
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/space/pages/upsert/upsert.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ <h1 class="mt-7" *ngIf="editMode" i18n>Edit space</h1>
[nzDirectory]="false"
nzType="drag"
[nzLimit]="1"
[nzCustomRequest]="uploadFile.bind(this, 'space_avatar')"
[nzCustomRequest]="uploadFile.bind(this)"
(nzChange)="uploadChangeAvatar($event)"
nzFileType="image/png,image/jpg,image/jpeg,image/webp"
[nzShowUploadList]="true"
Expand Down Expand Up @@ -210,7 +210,7 @@ <h1 class="mt-7" *ngIf="editMode" i18n>Edit space</h1>
nzListType="picture-card"
[nzDirectory]="false"
[nzLimit]="1"
[nzCustomRequest]="uploadFile.bind(this, 'space_banner')"
[nzCustomRequest]="uploadFile.bind(this)"
(nzChange)="uploadChangeBanner($event)"
nzFileType="image/png,image/jpg,image/jpeg,image/webp"
[nzPreviewFile]="previewFile"
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/space/pages/upsert/upsert.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class UpsertPage implements OnInit {
}
}

public uploadFile(type: 'space_avatar' | 'space_banner', item: NzUploadXHRArgs): Subscription {
public uploadFile(item: NzUploadXHRArgs): Subscription {
if (!this.auth.member$.value) {
const err = $localize`Member seems to log out during the file upload request.`;
this.nzNotification.error(err, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
[nzDirectory]="false"
nzType="drag"
[nzLimit]="1"
[nzCustomRequest]="newService.uploadFile.bind(newService, 'token_icon')"
[nzCustomRequest]="newService.uploadFile.bind(newService)"
(nzChange)="newService.uploadChangeIcon($event)"
nzFileType="image/png,image/jpg,image/jpeg,image/webp"
[nzShowUploadList]="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
nzType="drag"
nzListType="picture-card"
[nzLimit]="1"
[nzCustomRequest]="newService.uploadFile.bind(newService, 'token_introductionary')"
[nzCustomRequest]="newService.uploadFile.bind(newService)"
(nzChange)="newService.uploadChangeIntroductionary($event)"
nzFileType="image/png,image/jpg,image/jpeg,image/webp,video/mp4"
[nzShowUploadList]="{
Expand Down
5 changes: 1 addition & 4 deletions src/app/pages/token/services/new.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ export class NewService {
}
}

public uploadFile(
type: 'token_icon' | 'token_introductionary',
item: NzUploadXHRArgs,
): Subscription {
public uploadFile(item: NzUploadXHRArgs): Subscription {
if (!this.auth.member$.value) {
const err = $localize`Member seems to log out during the file upload request.`;
this.nzNotification.error(err, '');
Expand Down

0 comments on commit 8b27b9e

Please sign in to comment.