new release #190

Merged
b merged 68 commits from staging into main 2024-09-06 18:59:34 +00:00
5 changed files with 3 additions and 54 deletions
Showing only changes of commit 49c1714962 - Show all commits

View File

@ -18,4 +18,3 @@ export const SET_RELAY_MAP_UPDATED = 'SET_RELAY_MAP_UPDATED'
export const UPDATE_USER_APP_DATA = 'UPDATE_USER_APP_DATA'
export const UPDATE_PROCESSED_GIFT_WRAPS = 'UPDATE_PROCESSED_GIFT_WRAPS'
export const SET_D_TAG_FOR_APP_DATA = 'SET_D_TAG_FOR_APP_DATA'

View File

@ -1,10 +1,6 @@
import { UserAppData } from '../../types'
import * as ActionTypes from '../actionTypes'
import {
SetDTagForAppData,
UpdateProcessedGiftWraps,
UpdateUserAppData
} from './types'
import { UpdateProcessedGiftWraps, UpdateUserAppData } from './types'
export const updateUserAppData = (payload: UserAppData): UpdateUserAppData => ({
type: ActionTypes.UPDATE_USER_APP_DATA,
@ -17,8 +13,3 @@ export const updateProcessedGiftWraps = (
type: ActionTypes.UPDATE_PROCESSED_GIFT_WRAPS,
payload
})
export const setDTagForAppData = (payload: string): SetDTagForAppData => ({
type: ActionTypes.SET_D_TAG_FOR_APP_DATA,
payload
})

View File

@ -24,12 +24,6 @@ const reducer = (
processedGiftWraps: action.payload
}
case ActionTypes.SET_D_TAG_FOR_APP_DATA:
return {
...state,
dTag: action.payload
}
case ActionTypes.RESTORE_STATE:
return action.payload.userAppData || null

View File

@ -12,13 +12,7 @@ export interface UpdateProcessedGiftWraps {
payload: string[]
}
export interface SetDTagForAppData {
type: typeof ActionTypes.SET_D_TAG_FOR_APP_DATA
payload: string
}
export type UserAppDataDispatchTypes =
| UpdateUserAppData
| UpdateProcessedGiftWraps
| SetDTagForAppData
| RestoreState

View File

@ -24,7 +24,6 @@ import {
relayController
} from '../controllers'
import {
setDTagForAppData,
updateProcessedGiftWraps,
updateUserAppData as updateUserAppDataAction
} from '../store/actions'
@ -35,6 +34,7 @@ import { Meta, SignedEvent, UserAppData } from '../types'
import { getDefaultRelayMap } from './relays'
import { parseJson, removeLeadingSlash } from './string'
import { timeout } from './utils'
import { getHash } from './hash'
/**
* Generates a `d` tag for userAppData
@ -49,36 +49,7 @@ const getDTagForUserAppData = async (): Promise<string | null> => {
)
}
let dTag = store.getState().userAppData?.dTag
// if dTag is found in redux store then just return that
if (dTag) return dTag
// dTag not found is redux store. Generate it.
const unsignedEvent: UnsignedEvent = {
kind: kinds.ShortTextNote,
pubkey: pubkey,
created_at: 0,
tags: [],
content: `938_${pubkey}`
}
const nostrController = NostrController.getInstance()
const signedEvent = await nostrController
.signEvent(unsignedEvent)
.catch((err) => {
console.error('Failed to sign event for dTag', err)
toast.error(err.message || err)
return null
})
if (!signedEvent) return null
dTag = signedEvent.sig
// save dTag in redux store
store.dispatch(setDTagForAppData(dTag))
return dTag
return getHash(`938_${pubkey}`)
}
/**