Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
love_飞影
Neos
Commits
d898ab28
Commit
d898ab28
authored
Oct 17, 2022
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate chat
parent
3adbf313
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
4 deletions
+27
-4
src/reducers/chatSlice.ts
src/reducers/chatSlice.ts
+18
-0
src/reducers/joinSlice.ts
src/reducers/joinSlice.ts
+2
-0
src/store.ts
src/store.ts
+2
-0
src/ui/WaitRoom.tsx
src/ui/WaitRoom.tsx
+5
-4
No files found.
src/reducers/chatSlice.ts
0 → 100644
View file @
d898ab28
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../store
"
;
const
initialState
=
""
;
const
chatSlice
=
createSlice
({
name
:
"
chat
"
,
initialState
,
reducers
:
{
postChat
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
state
=
action
.
payload
;
},
},
});
export
const
{
postChat
}
=
chatSlice
.
actions
;
export
const
selectChat
=
(
state
:
RootState
)
=>
state
.
chat
;
export
default
chatSlice
.
reducer
;
src/reducers/joinSlice.ts
View file @
d898ab28
import
{
createSlice
}
from
"
@reduxjs/toolkit
"
;
import
{
createSlice
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../store
"
;
const
initialState
=
false
;
const
initialState
=
false
;
...
@@ -16,4 +17,5 @@ const joinedSlice = createSlice({
...
@@ -16,4 +17,5 @@ const joinedSlice = createSlice({
});
});
export
const
{
setJoined
,
setUnJoined
}
=
joinedSlice
.
actions
;
export
const
{
setJoined
,
setUnJoined
}
=
joinedSlice
.
actions
;
export
const
selectJoined
=
(
state
:
RootState
)
=>
state
.
join
;
export
default
joinedSlice
.
reducer
;
export
default
joinedSlice
.
reducer
;
src/store.ts
View file @
d898ab28
import
{
configureStore
}
from
"
@reduxjs/toolkit
"
;
import
{
configureStore
}
from
"
@reduxjs/toolkit
"
;
import
joinedReducer
from
"
./reducers/joinSlice
"
;
import
joinedReducer
from
"
./reducers/joinSlice
"
;
import
chatReducer
from
"
./reducers/chatSlice
"
;
export
const
store
=
configureStore
({
export
const
store
=
configureStore
({
reducer
:
{
reducer
:
{
join
:
joinedReducer
,
join
:
joinedReducer
,
chat
:
chatReducer
,
},
},
});
});
...
...
src/ui/WaitRoom.tsx
View file @
d898ab28
...
@@ -4,7 +4,8 @@ import { ygopro } from "../api/idl/ocgcore";
...
@@ -4,7 +4,8 @@ import { ygopro } from "../api/idl/ocgcore";
import
{
fetchDeck
,
IDeck
}
from
"
../api/Card
"
;
import
{
fetchDeck
,
IDeck
}
from
"
../api/Card
"
;
import
"
../css/WaitRoom.css
"
;
import
"
../css/WaitRoom.css
"
;
import
{
useDispatch
,
useSelector
}
from
"
react-redux
"
;
import
{
useDispatch
,
useSelector
}
from
"
react-redux
"
;
import
{
setJoined
}
from
"
../reducers/joinSlice
"
;
import
{
setJoined
,
selectJoined
}
from
"
../reducers/joinSlice
"
;
import
{
postChat
,
selectChat
}
from
"
../reducers/chatSlice
"
;
type
Player
=
{
type
Player
=
{
name
?:
string
;
name
?:
string
;
...
@@ -22,7 +23,6 @@ export default function WaitRoom() {
...
@@ -22,7 +23,6 @@ export default function WaitRoom() {
ip
?:
string
;
ip
?:
string
;
}
>
();
}
>
();
const
[
chat
,
setChat
]
=
useState
<
string
>
(
""
);
const
[
choseDeck
,
setChoseDeck
]
=
useState
<
boolean
>
(
false
);
const
[
choseDeck
,
setChoseDeck
]
=
useState
<
boolean
>
(
false
);
const
[
observerCount
,
setObserverCount
]
=
useState
<
number
>
(
0
);
const
[
observerCount
,
setObserverCount
]
=
useState
<
number
>
(
0
);
const
[
player0
,
setPlayer0
]
=
useState
<
Player
>
({});
const
[
player0
,
setPlayer0
]
=
useState
<
Player
>
({});
...
@@ -78,7 +78,7 @@ export default function WaitRoom() {
...
@@ -78,7 +78,7 @@ export default function WaitRoom() {
case
"
stoc_chat
"
:
{
case
"
stoc_chat
"
:
{
const
chat
=
pb
.
stoc_chat
;
const
chat
=
pb
.
stoc_chat
;
setChat
(
chat
.
msg
);
dispatch
(
postChat
(
chat
.
msg
)
);
break
;
break
;
}
}
case
"
stoc_hs_player_change
"
:
{
case
"
stoc_hs_player_change
"
:
{
...
@@ -229,7 +229,8 @@ export default function WaitRoom() {
...
@@ -229,7 +229,8 @@ export default function WaitRoom() {
};
};
},
[
ws
]);
},
[
ws
]);
const
joined
=
useSelector
((
state
)
=>
state
);
const
joined
=
useSelector
(
selectJoined
);
const
chat
=
useSelector
(
selectChat
);
const
handleChoseDeck
=
async
()
=>
{
const
handleChoseDeck
=
async
()
=>
{
if
(
ws
.
current
)
{
if
(
ws
.
current
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment