Hide zap button when inappropriate
* Current user has No Nostr pubkey connected * Creator can't accept zaps * Creator is current user (self-zap)
This commit is contained in:
@@ -41,11 +41,13 @@ const GalleryContent = <template>
|
|||||||
type="button"
|
type="button"
|
||||||
{{on "click" (fn @copyEventId closeMenu)}}
|
{{on "click" (fn @copyEventId closeMenu)}}
|
||||||
>Copy Photo Event ID</button>
|
>Copy Photo Event ID</button>
|
||||||
<button
|
{{#if @canZapPhoto}}
|
||||||
class="dropdown-item"
|
<button
|
||||||
type="button"
|
class="dropdown-item"
|
||||||
{{on "click" (fn @openZap closeMenu)}}
|
type="button"
|
||||||
>Zap this photo</button>
|
{{on "click" (fn @openZap closeMenu)}}
|
||||||
|
>Zap this photo</button>
|
||||||
|
{{/if}}
|
||||||
{{#if @canDeletePhoto}}
|
{{#if @canDeletePhoto}}
|
||||||
<button
|
<button
|
||||||
class="dropdown-item text-danger"
|
class="dropdown-item text-danger"
|
||||||
@@ -120,6 +122,7 @@ export default class PhotoGallery extends Component {
|
|||||||
@service nostrAuth;
|
@service nostrAuth;
|
||||||
@service nostrData;
|
@service nostrData;
|
||||||
@service nostrRelay;
|
@service nostrRelay;
|
||||||
|
@service nostrZap;
|
||||||
@service blossom;
|
@service blossom;
|
||||||
@service settings;
|
@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() {
|
get uploaderName() {
|
||||||
const pubkey = this.currentPhoto?.pubkey;
|
const pubkey = this.currentPhoto?.pubkey;
|
||||||
if (!pubkey) return null;
|
if (!pubkey) return null;
|
||||||
@@ -335,6 +346,7 @@ export default class PhotoGallery extends Component {
|
|||||||
@openZap={{this.openZap}}
|
@openZap={{this.openZap}}
|
||||||
@closeZap={{this.closeZap}}
|
@closeZap={{this.closeZap}}
|
||||||
@zapModalOpen={{this.zapModalOpen}}
|
@zapModalOpen={{this.zapModalOpen}}
|
||||||
|
@canZapPhoto={{this.canZapPhoto}}
|
||||||
/>
|
/>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#in-element this.destinationElement}}
|
{{#in-element this.destinationElement}}
|
||||||
@@ -357,6 +369,7 @@ export default class PhotoGallery extends Component {
|
|||||||
@openZap={{this.openZap}}
|
@openZap={{this.openZap}}
|
||||||
@closeZap={{this.closeZap}}
|
@closeZap={{this.closeZap}}
|
||||||
@zapModalOpen={{this.zapModalOpen}}
|
@zapModalOpen={{this.zapModalOpen}}
|
||||||
|
@canZapPhoto={{this.canZapPhoto}}
|
||||||
/>
|
/>
|
||||||
{{/in-element}}
|
{{/in-element}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@@ -9,7 +9,12 @@ export class MockNostrAuthService extends Service {
|
|||||||
@tracked connectUri = null;
|
@tracked connectUri = null;
|
||||||
|
|
||||||
get isConnected() {
|
get isConnected() {
|
||||||
return false;
|
return (
|
||||||
|
!!this.pubkey &&
|
||||||
|
(this.signerType === 'extension'
|
||||||
|
? typeof window !== 'undefined' && typeof window.nostr !== 'undefined'
|
||||||
|
: true)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get isMobile() {
|
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) {
|
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];
|
this.selectedPhoto = this.photos[0];
|
||||||
|
|
||||||
await render(
|
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) {
|
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];
|
this.selectedPhoto = this.photos[0];
|
||||||
|
|
||||||
await render(
|
await render(
|
||||||
|
|||||||
Reference in New Issue
Block a user