mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-17 02:29:10 +00:00
absolutely massive typescript porting time
This commit is contained in:
parent
01f238f515
commit
30d08a630f
159 changed files with 2563 additions and 3861 deletions
|
@ -1,37 +1,33 @@
|
|||
// @flow
|
||||
import * as React from 'react'
|
||||
import Head from 'next/head'
|
||||
import type { PageProps } from '../../types'
|
||||
import { PageProps } from '../../types'
|
||||
import SocialCards from '../../components/social-cards'
|
||||
import redirect from '../../util/redirect'
|
||||
import { connect } from 'react-redux'
|
||||
import { fetchServerIfNeed, getCurrentServerState, type ServerState } from '../../stores/currentServer'
|
||||
import { renderRoles, getCategoryViewState, toggleRole, type ViewState } from '../../stores/roles'
|
||||
// import { connect } from 'react-redux'
|
||||
import styled from 'styled-components'
|
||||
import Role from '../../components/role'
|
||||
|
||||
type ServerPageProps = PageProps & {
|
||||
currentServer: ServerState,
|
||||
view: ViewState,
|
||||
currentServer: any,
|
||||
view: any,
|
||||
isDiscordBot: boolean
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, { router: { query: { id } } }) => {
|
||||
return {
|
||||
currentServer: getCurrentServerState(state, id),
|
||||
view: getCategoryViewState(state)
|
||||
}
|
||||
}
|
||||
|
||||
const Category = styled.div``
|
||||
const Hider = styled.div``
|
||||
|
||||
type HiderProps = {
|
||||
visible: boolean
|
||||
children?: any
|
||||
}
|
||||
const Hider = styled.div<HiderProps>``
|
||||
|
||||
const RoleHolder = styled.div`
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
`
|
||||
class Server extends React.PureComponent<ServerPageProps> {
|
||||
static async getInitialProps (ctx: *, rpc: *, router: *) {
|
||||
static async getInitialProps (ctx: any, rpc: any, router: any) {
|
||||
const isDiscordBot = ctx.req && ctx.req.headers['user-agent'].includes('Discordbot')
|
||||
if (ctx.user == null) {
|
||||
if (!isDiscordBot) {
|
||||
|
@ -40,10 +36,10 @@ class Server extends React.PureComponent<ServerPageProps> {
|
|||
}
|
||||
|
||||
ctx.robots = 'NOINDEX, NOFOLLOW'
|
||||
await ctx.store.dispatch(fetchServerIfNeed(router.query.id, rpc))
|
||||
// await ctx.store.dispatch(fetchServerIfNeed(router.query.id, rpc))
|
||||
|
||||
if (!isDiscordBot) {
|
||||
await ctx.store.dispatch(renderRoles(router.query.id))
|
||||
// await ctx.store.dispatch(renderRoles(router.query.id))
|
||||
}
|
||||
return { isDiscordBot }
|
||||
}
|
||||
|
@ -54,13 +50,13 @@ class Server extends React.PureComponent<ServerPageProps> {
|
|||
this.props.router.push('/s/add')
|
||||
}
|
||||
|
||||
await dispatch(fetchServerIfNeed(id))
|
||||
await dispatch(renderRoles(id))
|
||||
// await dispatch(fetchServerIfNeed(id))
|
||||
// await dispatch(renderRoles(id))
|
||||
}
|
||||
|
||||
onToggle = (role) => (nextState) => {
|
||||
onToggle = (role) => (/*nextState*/) => {
|
||||
if (role.safe) {
|
||||
this.props.dispatch(toggleRole(role.id, nextState))
|
||||
// this.props.dispatch(toggleRole(role.id, nextState))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +82,7 @@ class Server extends React.PureComponent<ServerPageProps> {
|
|||
<title key='title'>{currentServer.server.name} - Roleypoly</title>
|
||||
</Head>
|
||||
{ this.renderSocial() }
|
||||
hello <span style={{ color: currentServer.gm?.color }}>{currentServer.gm?.nickname}</span> on {currentServer.server.name} ({ view.dirty ? 'dirty' : 'clean' })
|
||||
hello <span style={{ color: currentServer.gm.color }}>{currentServer.gm.nickname }</span> on {currentServer.server.name} ({ view.dirty ? 'dirty' : 'clean' })
|
||||
<Hider visible={true || currentServer.id !== null}>
|
||||
{ !view.invalidated && view.categories.map(c => <Category key={`cat__${c.name}__${c.id}`}>
|
||||
<div>{ c.name }</div>
|
||||
|
@ -102,4 +98,4 @@ class Server extends React.PureComponent<ServerPageProps> {
|
|||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(Server)
|
||||
export default Server
|
Loading…
Add table
Add a link
Reference in a new issue