fix the inverted logic
and make sure we send the events to index relays storing npub's metadata
This commit is contained in:
parent
c75a6b9957
commit
c3c7e30345
4 changed files with 37 additions and 15 deletions
|
|
@ -18,7 +18,7 @@ const RelayList = ({ relays, onUpdate, onRemove }) => {
|
||||||
checked={relay.read}
|
checked={relay.read}
|
||||||
onChange={(e) => onUpdate(index, 'read', e.target.checked)}
|
onChange={(e) => onUpdate(index, 'read', e.target.checked)}
|
||||||
/>
|
/>
|
||||||
Read
|
📨 Inbox (Read)
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<input
|
<input
|
||||||
|
|
@ -26,7 +26,7 @@ const RelayList = ({ relays, onUpdate, onRemove }) => {
|
||||||
checked={relay.write}
|
checked={relay.write}
|
||||||
onChange={(e) => onUpdate(index, 'write', e.target.checked)}
|
onChange={(e) => onUpdate(index, 'write', e.target.checked)}
|
||||||
/>
|
/>
|
||||||
Write
|
📤 Outbox (Write)
|
||||||
</label>
|
</label>
|
||||||
<button
|
<button
|
||||||
onClick={() => onRemove(index)}
|
onClick={() => onRemove(index)}
|
||||||
|
|
|
||||||
|
|
@ -212,9 +212,9 @@ const TemplateApplier = ({ setConnectedPubkey }) => {
|
||||||
<li key={index}>
|
<li key={index}>
|
||||||
<span className="relay-url">{relay.url}</span>
|
<span className="relay-url">{relay.url}</span>
|
||||||
<span className="relay-permissions">
|
<span className="relay-permissions">
|
||||||
{relay.read && relay.write ? '📖✍️' :
|
{relay.read && relay.write ? '📨📤 (Inbox + Outbox)' :
|
||||||
relay.read ? '📖' :
|
relay.read ? '📨 (Inbox)' :
|
||||||
relay.write ? '✍️' : ''}
|
relay.write ? '📤 (Outbox)' : ''}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,12 @@ const BLAST_RELAYS = [
|
||||||
'wss://offchain.pub',
|
'wss://offchain.pub',
|
||||||
'wss://sendit.nosflare.com',
|
'wss://sendit.nosflare.com',
|
||||||
'wss://nostr.mom',
|
'wss://nostr.mom',
|
||||||
'wss://nos.lol'
|
'wss://nos.lol',
|
||||||
|
'wss://purplepag.es',
|
||||||
|
'wss://indexer.coracle.social',
|
||||||
|
'wss://user.kindpag.es',
|
||||||
|
'wss://directory.yabu.me',
|
||||||
|
'wss://profiles.nostr1.com'
|
||||||
];
|
];
|
||||||
|
|
||||||
export const useNostr = () => {
|
export const useNostr = () => {
|
||||||
|
|
@ -224,8 +229,15 @@ export const useNostr = () => {
|
||||||
}
|
}
|
||||||
const tags = validRelays.map(relay => {
|
const tags = validRelays.map(relay => {
|
||||||
const params = [];
|
const params = [];
|
||||||
if (!relay.read) params.push('read');
|
// Read only
|
||||||
if (!relay.write) params.push('write');
|
if (relay.read && !relay.write) {
|
||||||
|
params.push('read');
|
||||||
|
}
|
||||||
|
// Write only
|
||||||
|
else if (!relay.read && relay.write) {
|
||||||
|
params.push('write');
|
||||||
|
}
|
||||||
|
// If both are true or both are false → no tags (default behavior)
|
||||||
return ['r', relay.url, ...params];
|
return ['r', relay.url, ...params];
|
||||||
});
|
});
|
||||||
const userRelayUrls = validRelays.map(r => r.url);
|
const userRelayUrls = validRelays.map(r => r.url);
|
||||||
|
|
|
||||||
|
|
@ -78,11 +78,11 @@ export const validateTemplate = (template) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof relay.read !== 'boolean') {
|
if (typeof relay.read !== 'boolean') {
|
||||||
throw new Error(`Relay ${index + 1} must specify read as boolean`);
|
throw new Error(`Relay ${index + 1} must specify read (inbox) as boolean`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof relay.write !== 'boolean') {
|
if (typeof relay.write !== 'boolean') {
|
||||||
throw new Error(`Relay ${index + 1} must specify write as boolean`);
|
throw new Error(`Relay ${index + 1} must specify write (outbox) as boolean`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -338,10 +338,13 @@ export const cloneTemplate = (template) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert template relays to kind 10002 tags format
|
* Convert template relays to kind 10002 tags format
|
||||||
|
* read = inbox, write = outbox
|
||||||
*/
|
*/
|
||||||
export const templateToKind10002Tags = (template) => {
|
export const templateToKind10002Tags = (template) => {
|
||||||
return template.relays.map(relay => {
|
return template.relays.map(relay => {
|
||||||
const params = [];
|
const params = [];
|
||||||
|
// If read is false, add 'read' tag (meaning "don't read from this relay")
|
||||||
|
// If write is false, add 'write' tag (meaning "don't write to this relay")
|
||||||
if (!relay.read) params.push('read');
|
if (!relay.read) params.push('read');
|
||||||
if (!relay.write) params.push('write');
|
if (!relay.write) params.push('write');
|
||||||
return ['r', relay.url, ...params];
|
return ['r', relay.url, ...params];
|
||||||
|
|
@ -350,6 +353,9 @@ export const templateToKind10002Tags = (template) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert kind 10002 tags to template format
|
* Convert kind 10002 tags to template format
|
||||||
|
* - ['r', url] = read AND write (both inbox and outbox)
|
||||||
|
* - ['r', url, 'read'] = read ONLY (inbox only)
|
||||||
|
* - ['r', url, 'write'] = write ONLY (outbox only)
|
||||||
*/
|
*/
|
||||||
export const kind10002TagsToTemplate = (tags, name = 'Imported Relays') => {
|
export const kind10002TagsToTemplate = (tags, name = 'Imported Relays') => {
|
||||||
const relays = tags
|
const relays = tags
|
||||||
|
|
@ -357,10 +363,14 @@ export const kind10002TagsToTemplate = (tags, name = 'Imported Relays') => {
|
||||||
.map(tag => {
|
.map(tag => {
|
||||||
const url = tag[1];
|
const url = tag[1];
|
||||||
const params = tag.slice(2);
|
const params = tag.slice(2);
|
||||||
|
// If 'read' is in params, read is false (don't read from this relay)
|
||||||
|
// If 'write' is in params, write is false (don't write to this relay)
|
||||||
|
const read = !params.includes('read');
|
||||||
|
const write = !params.includes('write');
|
||||||
return {
|
return {
|
||||||
url: url,
|
url: url,
|
||||||
read: !params.includes('read'),
|
read: read,
|
||||||
write: !params.includes('write')
|
write: write
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue