Zap the planet! #81
@@ -41,11 +41,13 @@ const GalleryContent = <template>
|
||||
type="button"
|
||||
{{on "click" (fn @copyEventId closeMenu)}}
|
||||
>Copy Photo Event ID</button>
|
||||
<button
|
||||
class="dropdown-item"
|
||||
type="button"
|
||||
{{on "click" (fn @openZap closeMenu)}}
|
||||
>Zap this photo</button>
|
||||
{{#if @canZapPhoto}}
|
||||
<button
|
||||
class="dropdown-item"
|
||||
type="button"
|
||||
{{on "click" (fn @openZap closeMenu)}}
|
||||
>Zap this photo</button>
|
||||
{{/if}}
|
||||
{{#if @canDeletePhoto}}
|
||||
<button
|
||||
class="dropdown-item text-danger"
|
||||
@@ -120,6 +122,7 @@ export default class PhotoGallery extends Component {
|
||||
@service nostrAuth;
|
||||
@service nostrData;
|
||||
@service nostrRelay;
|
||||
@service nostrZap;
|
||||
@service blossom;
|
||||
@service settings;
|
||||
|
||||
@@ -147,6 +150,14 @@ export default class PhotoGallery extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
get canZapPhoto() {
|
||||
return (
|
||||
!this.isCreator &&
|
||||
this.nostrAuth.isConnected &&
|
||||
!!this.nostrZap.getLightningAddress(this.currentPhoto?.pubkey)
|
||||
);
|
||||
}
|
||||
|
||||
get uploaderName() {
|
||||
const pubkey = this.currentPhoto?.pubkey;
|
||||
if (!pubkey) return null;
|
||||
@@ -335,6 +346,7 @@ export default class PhotoGallery extends Component {
|
||||
@openZap={{this.openZap}}
|
||||
@closeZap={{this.closeZap}}
|
||||
@zapModalOpen={{this.zapModalOpen}}
|
||||
@canZapPhoto={{this.canZapPhoto}}
|
||||
/>
|
||||
{{else}}
|
||||
{{#in-element this.destinationElement}}
|
||||
@@ -357,6 +369,7 @@ export default class PhotoGallery extends Component {
|
||||
@openZap={{this.openZap}}
|
||||
@closeZap={{this.closeZap}}
|
||||
@zapModalOpen={{this.zapModalOpen}}
|
||||
@canZapPhoto={{this.canZapPhoto}}
|
||||
/>
|
||||
{{/in-element}}
|
||||
{{/if}}
|
||||
|
||||
@@ -9,7 +9,12 @@ export class MockNostrAuthService extends Service {
|
||||
@tracked connectUri = null;
|
||||
|
||||
get isConnected() {
|
||||
return false;
|
||||
return (
|
||||
!!this.pubkey &&
|
||||
(this.signerType === 'extension'
|
||||
? typeof window !== 'undefined' && typeof window.nostr !== 'undefined'
|
||||
: true)
|
||||
);
|
||||
}
|
||||
|
||||
get isMobile() {
|
||||
|
||||
@@ -480,7 +480,8 @@ module('Integration | Component | photo-gallery', function (hooks) {
|
||||
});
|
||||
|
||||
test('it shows Zap this photo in the dropdown', async function (assert) {
|
||||
this.nostrAuth.pubkey = USER_A;
|
||||
this.nostrAuth.pubkey = USER_B;
|
||||
this.nostrAuth.signerType = 'connect';
|
||||
this.selectedPhoto = this.photos[0];
|
||||
|
||||
await render(
|
||||
@@ -508,7 +509,8 @@ module('Integration | Component | photo-gallery', function (hooks) {
|
||||
});
|
||||
|
||||
test('it opens zap modal when Zap this photo is clicked', async function (assert) {
|
||||
this.nostrAuth.pubkey = USER_A;
|
||||
this.nostrAuth.pubkey = USER_B;
|
||||
this.nostrAuth.signerType = 'connect';
|
||||
this.selectedPhoto = this.photos[0];
|
||||
|
||||
await render(
|
||||
|
||||
Reference in New Issue
Block a user