Sign Nostr event with ditto

This commit is contained in:
Alex Gleason 2023-05-13 21:07:36 -05:00
parent a5c616312f
commit 85f526d1d4
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -181,12 +181,12 @@ const connectTimelineStream = (
case 'marker':
dispatch({ type: MARKER_FETCH_SUCCESS, marker: JSON.parse(data.payload) });
break;
case 'nostr:signEvent':
case 'nostr.sign':
(async () => {
const event = await window.nostr?.signEvent(JSON.parse(data.payload));
if (event) {
websocket.send(JSON.stringify({ event: 'nostr:event', payload: event }));
websocket.send(JSON.stringify({ event: 'nostr.sign', payload: JSON.stringify(event) }));
}
})();
break;
@ -201,7 +201,7 @@ const refreshHomeTimelineAndNotification = (dispatch: AppDispatch, done?: () =>
dispatch(fetchAnnouncements(done))))));
const connectUserStream = (opts?: StreamOpts) =>
connectTimelineStream('home', 'user', refreshHomeTimelineAndNotification, null, opts);
connectTimelineStream('home', `user${'nostr' in window ? '&nostr=true' : ''}`, refreshHomeTimelineAndNotification, null, opts);
const connectCommunityStream = ({ onlyMedia }: Record<string, any> = {}) =>
connectTimelineStream(`community${onlyMedia ? ':media' : ''}`, `public:local${onlyMedia ? ':media' : ''}`);