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
b4cfa173
Commit
b4cfa173
authored
Oct 17, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix redux
parent
d898ab28
Pipeline
#17234
failed with stage
in 2 minutes
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
16 deletions
+33
-16
package-lock.json
package-lock.json
+2
-3
src/hook.ts
src/hook.ts
+6
-0
src/reducers/chatSlice.ts
src/reducers/chatSlice.ts
+9
-3
src/reducers/joinSlice.ts
src/reducers/joinSlice.ts
+12
-6
src/ui/WaitRoom.tsx
src/ui/WaitRoom.tsx
+4
-4
No files found.
package-lock.json
View file @
b4cfa173
...
...
@@ -2848,9 +2848,8 @@
},
"node_modules/@reduxjs/toolkit": {
"version": "1.8.6",
"resolved": "http
://bnpm.byted
.org/@reduxjs/toolkit/-/toolkit-1.8.6.tgz",
"resolved": "http
s://registry.npmjs
.org/@reduxjs/toolkit/-/toolkit-1.8.6.tgz",
"integrity": "sha512-4Ia/Loc6WLmdSOzi7k5ff7dLK8CgG2b8aqpLsCAJhazAzGdp//YBUSaj0ceW6a3kDBDNRrq5CRwyCS0wBiL1ig==",
"license": "MIT",
"dependencies": {
"immer": "^9.0.7",
"redux": "^4.1.2",
...
...
@@ -17559,7 +17558,7 @@
},
"@reduxjs/toolkit": {
"version": "1.8.6",
"resolved": "http
://bnpm.byted
.org/@reduxjs/toolkit/-/toolkit-1.8.6.tgz",
"resolved": "http
s://registry.npmjs
.org/@reduxjs/toolkit/-/toolkit-1.8.6.tgz",
"integrity": "sha512-4Ia/Loc6WLmdSOzi7k5ff7dLK8CgG2b8aqpLsCAJhazAzGdp//YBUSaj0ceW6a3kDBDNRrq5CRwyCS0wBiL1ig==",
"requires": {
"immer": "^9.0.7",
src/hook.ts
0 → 100644
View file @
b4cfa173
import
{
TypedUseSelectorHook
,
useDispatch
,
useSelector
}
from
"
react-redux
"
;
import
type
{
RootState
,
AppDispatch
}
from
"
./store
"
;
// Use throughout your app instead of plain `useDispatch` and `useSelector`
export
const
useAppDispatch
:
()
=>
AppDispatch
=
useDispatch
;
export
const
useAppSelector
:
TypedUseSelectorHook
<
RootState
>
=
useSelector
;
src/reducers/chatSlice.ts
View file @
b4cfa173
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../store
"
;
const
initialState
=
""
;
export
interface
chatState
{
message
:
string
;
}
const
initialState
:
chatState
=
{
message
:
""
,
};
const
chatSlice
=
createSlice
({
name
:
"
chat
"
,
initialState
,
reducers
:
{
postChat
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
state
=
action
.
payload
;
state
.
message
=
action
.
payload
;
},
},
});
export
const
{
postChat
}
=
chatSlice
.
actions
;
export
const
selectChat
=
(
state
:
RootState
)
=>
state
.
chat
;
export
const
selectChat
=
(
state
:
RootState
)
=>
state
.
chat
.
message
;
export
default
chatSlice
.
reducer
;
src/reducers/joinSlice.ts
View file @
b4cfa173
import
{
createSlice
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../store
"
;
const
initialState
=
false
;
export
interface
JoinState
{
value
:
boolean
;
}
const
initialState
:
JoinState
=
{
value
:
false
,
};
const
joinedSlice
=
createSlice
({
name
:
"
join
"
,
initialState
,
reducers
:
{
setJoined
(
state
)
{
state
=
true
;
setJoined
:
(
state
)
=>
{
state
.
value
=
true
;
},
setUnJoined
(
state
)
{
state
=
false
;
setUnJoined
:
(
state
)
=>
{
state
.
value
=
false
;
},
},
});
export
const
{
setJoined
,
setUnJoined
}
=
joinedSlice
.
actions
;
export
const
selectJoined
=
(
state
:
RootState
)
=>
state
.
join
;
export
const
selectJoined
=
(
state
:
RootState
)
=>
state
.
join
.
value
;
export
default
joinedSlice
.
reducer
;
src/ui/WaitRoom.tsx
View file @
b4cfa173
...
...
@@ -3,7 +3,7 @@ import { useParams } from "react-router-dom";
import
{
ygopro
}
from
"
../api/idl/ocgcore
"
;
import
{
fetchDeck
,
IDeck
}
from
"
../api/Card
"
;
import
"
../css/WaitRoom.css
"
;
import
{
use
Dispatch
,
useSelector
}
from
"
react-redux
"
;
import
{
use
AppDispatch
,
useAppSelector
}
from
"
../hook
"
;
import
{
setJoined
,
selectJoined
}
from
"
../reducers/joinSlice
"
;
import
{
postChat
,
selectChat
}
from
"
../reducers/chatSlice
"
;
...
...
@@ -32,7 +32,7 @@ export default function WaitRoom() {
const
ws
=
useRef
<
WebSocket
|
null
>
(
null
);
const
dispatch
=
useDispatch
();
const
dispatch
=
use
App
Dispatch
();
const
{
player
,
passWd
,
ip
}
=
params
;
...
...
@@ -229,8 +229,8 @@ export default function WaitRoom() {
};
},
[
ws
]);
const
joined
=
useSelector
(
selectJoined
);
const
chat
=
useSelector
(
selectChat
);
const
joined
=
use
App
Selector
(
selectJoined
);
const
chat
=
use
App
Selector
(
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