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
b4cfa173
Commit
b4cfa173
authored
Oct 17, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix redux
parent
d898ab28
Changes
5
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 @@
...
@@ -2848,9 +2848,8 @@
},
},
"node_modules/@reduxjs/toolkit": {
"node_modules/@reduxjs/toolkit": {
"version": "1.8.6",
"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==",
"integrity": "sha512-4Ia/Loc6WLmdSOzi7k5ff7dLK8CgG2b8aqpLsCAJhazAzGdp//YBUSaj0ceW6a3kDBDNRrq5CRwyCS0wBiL1ig==",
"license": "MIT",
"dependencies": {
"dependencies": {
"immer": "^9.0.7",
"immer": "^9.0.7",
"redux": "^4.1.2",
"redux": "^4.1.2",
...
@@ -17559,7 +17558,7 @@
...
@@ -17559,7 +17558,7 @@
},
},
"@reduxjs/toolkit": {
"@reduxjs/toolkit": {
"version": "1.8.6",
"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==",
"integrity": "sha512-4Ia/Loc6WLmdSOzi7k5ff7dLK8CgG2b8aqpLsCAJhazAzGdp//YBUSaj0ceW6a3kDBDNRrq5CRwyCS0wBiL1ig==",
"requires": {
"requires": {
"immer": "^9.0.7",
"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
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../store
"
;
import
{
RootState
}
from
"
../store
"
;
const
initialState
=
""
;
export
interface
chatState
{
message
:
string
;
}
const
initialState
:
chatState
=
{
message
:
""
,
};
const
chatSlice
=
createSlice
({
const
chatSlice
=
createSlice
({
name
:
"
chat
"
,
name
:
"
chat
"
,
initialState
,
initialState
,
reducers
:
{
reducers
:
{
postChat
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
postChat
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
state
=
action
.
payload
;
state
.
message
=
action
.
payload
;
},
},
},
},
});
});
export
const
{
postChat
}
=
chatSlice
.
actions
;
export
const
{
postChat
}
=
chatSlice
.
actions
;
export
const
selectChat
=
(
state
:
RootState
)
=>
state
.
chat
;
export
const
selectChat
=
(
state
:
RootState
)
=>
state
.
chat
.
message
;
export
default
chatSlice
.
reducer
;
export
default
chatSlice
.
reducer
;
src/reducers/joinSlice.ts
View file @
b4cfa173
import
{
createSlice
}
from
"
@reduxjs/toolkit
"
;
import
{
createSlice
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../store
"
;
import
{
RootState
}
from
"
../store
"
;
const
initialState
=
false
;
export
interface
JoinState
{
value
:
boolean
;
}
const
initialState
:
JoinState
=
{
value
:
false
,
};
const
joinedSlice
=
createSlice
({
const
joinedSlice
=
createSlice
({
name
:
"
join
"
,
name
:
"
join
"
,
initialState
,
initialState
,
reducers
:
{
reducers
:
{
setJoined
(
state
)
{
setJoined
:
(
state
)
=>
{
state
=
true
;
state
.
value
=
true
;
},
},
setUnJoined
(
state
)
{
setUnJoined
:
(
state
)
=>
{
state
=
false
;
state
.
value
=
false
;
},
},
},
},
});
});
export
const
{
setJoined
,
setUnJoined
}
=
joinedSlice
.
actions
;
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
;
export
default
joinedSlice
.
reducer
;
src/ui/WaitRoom.tsx
View file @
b4cfa173
...
@@ -3,7 +3,7 @@ import { useParams } from "react-router-dom";
...
@@ -3,7 +3,7 @@ import { useParams } from "react-router-dom";
import
{
ygopro
}
from
"
../api/idl/ocgcore
"
;
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
{
use
Dispatch
,
useSelector
}
from
"
react-redux
"
;
import
{
use
AppDispatch
,
useAppSelector
}
from
"
../hook
"
;
import
{
setJoined
,
selectJoined
}
from
"
../reducers/joinSlice
"
;
import
{
setJoined
,
selectJoined
}
from
"
../reducers/joinSlice
"
;
import
{
postChat
,
selectChat
}
from
"
../reducers/chatSlice
"
;
import
{
postChat
,
selectChat
}
from
"
../reducers/chatSlice
"
;
...
@@ -32,7 +32,7 @@ export default function WaitRoom() {
...
@@ -32,7 +32,7 @@ export default function WaitRoom() {
const
ws
=
useRef
<
WebSocket
|
null
>
(
null
);
const
ws
=
useRef
<
WebSocket
|
null
>
(
null
);
const
dispatch
=
useDispatch
();
const
dispatch
=
use
App
Dispatch
();
const
{
player
,
passWd
,
ip
}
=
params
;
const
{
player
,
passWd
,
ip
}
=
params
;
...
@@ -229,8 +229,8 @@ export default function WaitRoom() {
...
@@ -229,8 +229,8 @@ export default function WaitRoom() {
};
};
},
[
ws
]);
},
[
ws
]);
const
joined
=
useSelector
(
selectJoined
);
const
joined
=
use
App
Selector
(
selectJoined
);
const
chat
=
useSelector
(
selectChat
);
const
chat
=
use
App
Selector
(
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