Compare commits
No commits in common. "675a763af3562330ec1a3cbb4ad780490d5ca6de" and "09229f42c79c7a8938387a8953dadd55192a0d33" have entirely different histories.
675a763af3
...
09229f42c7
@ -8,7 +8,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 2",
|
||||||
"lint:fix": "eslint . --fix --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
"lint:fix": "eslint . --fix --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||||
"lint:staged": "eslint --fix --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
"lint:staged": "eslint --fix --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||||
"formatter:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
|
"formatter:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
|
||||||
|
@ -109,7 +109,6 @@ export const MainLayout = () => {
|
|||||||
|
|
||||||
if (pubkey && !hasSubscribed.current) {
|
if (pubkey && !hasSubscribed.current) {
|
||||||
// Call `subscribeForSigits` only if it hasn't been called before
|
// Call `subscribeForSigits` only if it hasn't been called before
|
||||||
// #193 disabled websocket subscribtion, until #194 is done
|
|
||||||
subscribeForSigits(pubkey)
|
subscribeForSigits(pubkey)
|
||||||
|
|
||||||
// Mark `subscribeForSigits` as called
|
// Mark `subscribeForSigits` as called
|
||||||
|
@ -18,10 +18,6 @@ export interface RestoreState {
|
|||||||
payload: State
|
payload: State
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserLogout {
|
|
||||||
type: typeof ActionTypes.USER_LOGOUT
|
|
||||||
}
|
|
||||||
|
|
||||||
export const userLogOutAction = () => {
|
export const userLogOutAction = () => {
|
||||||
return {
|
return {
|
||||||
type: ActionTypes.USER_LOGOUT
|
type: ActionTypes.USER_LOGOUT
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as ActionTypes from '../actionTypes'
|
import * as ActionTypes from '../actionTypes'
|
||||||
import { RestoreState, UserLogout } from '../actions'
|
import { RestoreState } from '../actions'
|
||||||
|
|
||||||
export enum LoginMethods {
|
export enum LoginMethods {
|
||||||
extension = 'extension',
|
extension = 'extension',
|
||||||
@ -54,4 +54,3 @@ export type AuthDispatchTypes =
|
|||||||
| UpdateKeyPair
|
| UpdateKeyPair
|
||||||
| UpdateNsecBunkerPubkey
|
| UpdateNsecBunkerPubkey
|
||||||
| UpdateNsecBunkerRelays
|
| UpdateNsecBunkerRelays
|
||||||
| UserLogout
|
|
||||||
|
@ -3,15 +3,12 @@ import { combineReducers } from 'redux'
|
|||||||
import { UserAppData } from '../types'
|
import { UserAppData } from '../types'
|
||||||
import * as ActionTypes from './actionTypes'
|
import * as ActionTypes from './actionTypes'
|
||||||
import authReducer from './auth/reducer'
|
import authReducer from './auth/reducer'
|
||||||
import { AuthDispatchTypes, AuthState } from './auth/types'
|
import { AuthState } from './auth/types'
|
||||||
import metadataReducer from './metadata/reducer'
|
import metadataReducer from './metadata/reducer'
|
||||||
import relaysReducer from './relays/reducer'
|
import relaysReducer from './relays/reducer'
|
||||||
import { RelaysDispatchTypes, RelaysState } from './relays/types'
|
import { RelaysState } from './relays/types'
|
||||||
import UserAppDataReducer from './userAppData/reducer'
|
import UserAppDataReducer from './userAppData/reducer'
|
||||||
import userRobotImageReducer from './userRobotImage/reducer'
|
import userRobotImageReducer from './userRobotImage/reducer'
|
||||||
import { MetadataDispatchTypes } from './metadata/types'
|
|
||||||
import { UserAppDataDispatchTypes } from './userAppData/types'
|
|
||||||
import { UserRobotImageDispatchTypes } from './userRobotImage/types'
|
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
auth: AuthState
|
auth: AuthState
|
||||||
@ -21,13 +18,6 @@ export interface State {
|
|||||||
userAppData?: UserAppData
|
userAppData?: UserAppData
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppActions =
|
|
||||||
| AuthDispatchTypes
|
|
||||||
| MetadataDispatchTypes
|
|
||||||
| UserRobotImageDispatchTypes
|
|
||||||
| RelaysDispatchTypes
|
|
||||||
| UserAppDataDispatchTypes
|
|
||||||
|
|
||||||
export const appReducer = combineReducers({
|
export const appReducer = combineReducers({
|
||||||
auth: authReducer,
|
auth: authReducer,
|
||||||
metadata: metadataReducer,
|
metadata: metadataReducer,
|
||||||
@ -36,10 +26,8 @@ export const appReducer = combineReducers({
|
|||||||
userAppData: UserAppDataReducer
|
userAppData: UserAppDataReducer
|
||||||
})
|
})
|
||||||
|
|
||||||
export default (
|
// FIXME: define types
|
||||||
state: ReturnType<typeof appReducer> | undefined,
|
export default (state: any, action: any) => {
|
||||||
action: AppActions
|
|
||||||
) => {
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ActionTypes.USER_LOGOUT:
|
case ActionTypes.USER_LOGOUT:
|
||||||
return appReducer(undefined, action)
|
return appReducer(undefined, action)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import * as ActionTypes from '../actionTypes'
|
import * as ActionTypes from '../actionTypes'
|
||||||
import { UserRobotImageDispatchTypes } from './types'
|
import { MetadataDispatchTypes } from './types'
|
||||||
|
|
||||||
const initialState: string | null = null
|
const initialState: string | null = null
|
||||||
|
|
||||||
const reducer = (
|
const reducer = (
|
||||||
state = initialState,
|
state = initialState,
|
||||||
action: UserRobotImageDispatchTypes
|
action: MetadataDispatchTypes
|
||||||
): string | null | undefined => {
|
): string | null | undefined => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ActionTypes.SET_USER_ROBOT_IMAGE:
|
case ActionTypes.SET_USER_ROBOT_IMAGE:
|
||||||
|
@ -6,4 +6,4 @@ export interface SetUserRobotImage {
|
|||||||
payload: string | null
|
payload: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UserRobotImageDispatchTypes = SetUserRobotImage | RestoreState
|
export type MetadataDispatchTypes = SetUserRobotImage | RestoreState
|
||||||
|
@ -859,16 +859,9 @@ export const subscribeForSigits = async (pubkey: string) => {
|
|||||||
'#p': [pubkey]
|
'#p': [pubkey]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the received event synchronously
|
relayController.subscribeForEvents(filter, relaySet.read, (event) => {
|
||||||
const events = await relayController.fetchEvents(filter, relaySet.read)
|
processReceivedEvent(event) // Process the received event
|
||||||
for (const e of events) {
|
})
|
||||||
await processReceivedEvent(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Async processing of the events has a race condition
|
|
||||||
// relayController.subscribeForEvents(filter, relaySet.read, (event) => {
|
|
||||||
// processReceivedEvent(event)
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
|
const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
|
||||||
@ -914,7 +907,7 @@ const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
|
|||||||
|
|
||||||
if (!meta) return
|
if (!meta) return
|
||||||
|
|
||||||
await updateUsersAppData(meta)
|
updateUsersAppData(meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,7 +6,6 @@ import { localCache } from '../services'
|
|||||||
import { RelayMap, RelaySet } from '../types'
|
import { RelayMap, RelaySet } from '../types'
|
||||||
import {
|
import {
|
||||||
DEFAULT_LOOK_UP_RELAY_LIST,
|
DEFAULT_LOOK_UP_RELAY_LIST,
|
||||||
ONE_DAY_IN_MS,
|
|
||||||
ONE_WEEK_IN_MS,
|
ONE_WEEK_IN_MS,
|
||||||
SIGIT_RELAY
|
SIGIT_RELAY
|
||||||
} from './const'
|
} from './const'
|
||||||
@ -57,7 +56,7 @@ const findRelayListInCache = async (hexKey: string): Promise<Event | null> => {
|
|||||||
// Check if the cached event is not older than one week
|
// Check if the cached event is not older than one week
|
||||||
if (
|
if (
|
||||||
cachedRelayListMetadataEvent &&
|
cachedRelayListMetadataEvent &&
|
||||||
!isOlderThanOneWeek(cachedRelayListMetadataEvent.cachedAt)
|
isOlderThanOneWeek(cachedRelayListMetadataEvent.cachedAt)
|
||||||
) {
|
) {
|
||||||
return cachedRelayListMetadataEvent.event
|
return cachedRelayListMetadataEvent.event
|
||||||
}
|
}
|
||||||
@ -89,11 +88,11 @@ const getDefaultRelayMap = (): RelayMap => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const isOlderThanOneWeek = (cachedAt: number) => {
|
const isOlderThanOneWeek = (cachedAt: number) => {
|
||||||
return Date.now() - cachedAt > ONE_WEEK_IN_MS
|
return Date.now() - cachedAt < ONE_WEEK_IN_MS
|
||||||
}
|
}
|
||||||
|
|
||||||
const isOlderThanOneDay = (cachedAt: number) => {
|
const isOlderThanOneDay = (cachedAt: number) => {
|
||||||
return Date.now() - cachedAt > ONE_DAY_IN_MS
|
return Date.now() - cachedAt < ONE_WEEK_IN_MS
|
||||||
}
|
}
|
||||||
|
|
||||||
const isRelayTag = (tag: string[]): boolean => tag[0] === 'r'
|
const isRelayTag = (tag: string[]): boolean => tag[0] === 'r'
|
||||||
|
Loading…
Reference in New Issue
Block a user