mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-17 02:29:10 +00:00
lerna: starting point
This commit is contained in:
parent
f7e2898633
commit
cb0b1d2410
17 changed files with 730 additions and 1067 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue