mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-16 18:29:08 +00:00
lerna: starting point
This commit is contained in:
parent
f7e2898633
commit
cb0b1d2410
17 changed files with 730 additions and 1067 deletions
|
@ -4,8 +4,8 @@ import { colors } from '../global-colors'
|
|||
import Color from 'color'
|
||||
import RoleStyled from './role.styled'
|
||||
import Tooltip from '../tooltip'
|
||||
import logger from '../../../logger'
|
||||
const log = logger(__filename)
|
||||
// import logger from '../../../logger'
|
||||
// const log = logger(__filename)
|
||||
|
||||
const fromColors = (colors) => Object.entries(colors).reduce(
|
||||
(acc, [v, val]) => ({ ...acc, [`--role-color-${v}`]: val })
|
||||
|
@ -45,15 +45,15 @@ export default class Role extends React.Component<RoleProps, RoleState> {
|
|||
}
|
||||
|
||||
onMouseOver = () => {
|
||||
log.debug('caught hovering')
|
||||
// log.debug('caught hovering')
|
||||
if (this.props.disabled && this.state.hovering === false) {
|
||||
log.debug('set hovering')
|
||||
// log.debug('set hovering')
|
||||
this.setState({ hovering: true })
|
||||
}
|
||||
}
|
||||
|
||||
onMouseOut = () => {
|
||||
log.debug('out hovering')
|
||||
// log.debug('out hovering')
|
||||
this.setState({ hovering: false })
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ const defaultProps: SocialCardProps = {
|
|||
imageSize: 200
|
||||
}
|
||||
|
||||
const SocialCards: React.StatelessFunctionalComponent<SocialCardProps> = (props) => {
|
||||
const SocialCards = (props: SocialCardProps) => {
|
||||
props = {
|
||||
...defaultProps,
|
||||
...props
|
||||
|
|
|
@ -10,7 +10,7 @@ type Props = {
|
|||
const HeaderBarAuth = dynamic(() => import('../components/header/auth'))
|
||||
const HeaderBarUnauth = dynamic(() => import('../components/header/unauth'))
|
||||
|
||||
const HeaderBar: React.StatelessFunctionalComponent<Props> = (props) => {
|
||||
const HeaderBar = (props: Props) => {
|
||||
if (props.user == null) {
|
||||
return <HeaderBarUnauth {...props} />
|
||||
} else {
|
||||
|
|
|
@ -8,6 +8,7 @@ import { Provider } from 'react-redux'
|
|||
import ErrorP, { Overlay } from './_error'
|
||||
import styled from 'styled-components'
|
||||
import { withRedux } from '../config/redux'
|
||||
import type { UserPartial } from '../../services/discord'
|
||||
|
||||
type NextPage = React.Component<any> & React.StatelessFunctionalComponent<any> & {
|
||||
getInitialProps: (ctx: any, ...args: any) => any
|
||||
|
@ -35,9 +36,18 @@ class RoleypolyApp extends App {
|
|||
|
||||
let pageProps = {}
|
||||
const rpc = withCookies(ctx)
|
||||
|
||||
const user = await rpc.getCurrentUser()
|
||||
ctx.user = user
|
||||
let user: ?UserPartial
|
||||
try {
|
||||
user = await rpc.getCurrentUser()
|
||||
ctx.user = user
|
||||
} catch (e) {
|
||||
if (e.code === 403) {
|
||||
ctx.user = null
|
||||
} else {
|
||||
console.error(e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
ctx.robots = 'INDEX, FOLLOW'
|
||||
|
||||
ctx.layout = {
|
||||
|
|
|
@ -36,7 +36,7 @@ const RoleHolder = styled.div`
|
|||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
`
|
||||
class Server extends React.Component<ServerPageProps> {
|
||||
class Server extends React.PureComponent<ServerPageProps> {
|
||||
static async getInitialProps (ctx: *, rpc: *, router: *) {
|
||||
const isDiscordBot = ctx.req && ctx.req.headers['user-agent'].includes('Discordbot')
|
||||
if (ctx.user == null) {
|
||||
|
|
|
@ -25,7 +25,7 @@ export default class RPCClient {
|
|||
cookieHeader: string
|
||||
|
||||
rpc: {
|
||||
[fn: string]: (...args: any[]) => Promise<mixed> | string
|
||||
[fn: string]: (...args: any[]) => Promise<any>
|
||||
} = {}
|
||||
|
||||
__rpcAvailable: Array<{
|
||||
|
@ -42,11 +42,12 @@ export default class RPCClient {
|
|||
this.dev = process.env.NODE_ENV === 'development'
|
||||
}
|
||||
|
||||
this.rpc = new Proxy({
|
||||
toJSON () {
|
||||
return '{}'
|
||||
}
|
||||
}, { get: this.__rpcCall, has: this.__checkCall, ownKeys: this.__listCalls, delete: () => {} })
|
||||
this.rpc = new Proxy({}, {
|
||||
get: this.__rpcCall,
|
||||
has: this.__checkCall,
|
||||
ownKeys: this.__listCalls,
|
||||
delete: () => {}
|
||||
})
|
||||
|
||||
if (this.dev) {
|
||||
this.updateCalls()
|
||||
|
@ -90,7 +91,9 @@ export default class RPCClient {
|
|||
}
|
||||
const rsp = await rq.send(req).ok(() => true)
|
||||
const body: RPCResponse = rsp.body
|
||||
// console.log(body)
|
||||
if (body.error === true) {
|
||||
console.error(body)
|
||||
throw RPCError.fromResponse(body, rsp.status)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue