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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
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
MyCard
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
Pipeline
#17231
failed with stage
in 2 minutes
Changes
4
Pipelines
1
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
{
RootState
}
from
"
../store
"
;
const
initialState
=
false
;
...
...
@@ -16,4 +17,5 @@ const joinedSlice = createSlice({
});
export
const
{
setJoined
,
setUnJoined
}
=
joinedSlice
.
actions
;
export
const
selectJoined
=
(
state
:
RootState
)
=>
state
.
join
;
export
default
joinedSlice
.
reducer
;
src/store.ts
View file @
d898ab28
import
{
configureStore
}
from
"
@reduxjs/toolkit
"
;
import
joinedReducer
from
"
./reducers/joinSlice
"
;
import
chatReducer
from
"
./reducers/chatSlice
"
;
export
const
store
=
configureStore
({
reducer
:
{
join
:
joinedReducer
,
chat
:
chatReducer
,
},
});
...
...
src/ui/WaitRoom.tsx
View file @
d898ab28
...
...
@@ -4,7 +4,8 @@ import { ygopro } from "../api/idl/ocgcore";
import
{
fetchDeck
,
IDeck
}
from
"
../api/Card
"
;
import
"
../css/WaitRoom.css
"
;
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
=
{
name
?:
string
;
...
...
@@ -22,7 +23,6 @@ export default function WaitRoom() {
ip
?:
string
;
}
>
();
const
[
chat
,
setChat
]
=
useState
<
string
>
(
""
);
const
[
choseDeck
,
setChoseDeck
]
=
useState
<
boolean
>
(
false
);
const
[
observerCount
,
setObserverCount
]
=
useState
<
number
>
(
0
);
const
[
player0
,
setPlayer0
]
=
useState
<
Player
>
({});
...
...
@@ -78,7 +78,7 @@ export default function WaitRoom() {
case
"
stoc_chat
"
:
{
const
chat
=
pb
.
stoc_chat
;
setChat
(
chat
.
msg
);
dispatch
(
postChat
(
chat
.
msg
)
);
break
;
}
case
"
stoc_hs_player_change
"
:
{
...
...
@@ -229,7 +229,8 @@ export default function WaitRoom() {
};
},
[
ws
]);
const
joined
=
useSelector
((
state
)
=>
state
);
const
joined
=
useSelector
(
selectJoined
);
const
chat
=
useSelector
(
selectChat
);
const
handleChoseDeck
=
async
()
=>
{
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