Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
9a432009
Commit
9a432009
authored
Nov 03, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
b11e70b2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
13 deletions
+13
-13
context.tsx
lib/socket/context.tsx
+5
-5
useSocketChannel.tsx
lib/socket/useSocketChannel.tsx
+4
-4
useSocketMessage.tsx
lib/socket/useSocketMessage.tsx
+3
-3
Transaction.tsx
ui/pages/Transaction.tsx
+1
-1
No files found.
lib/socket/context.tsx
View file @
9a432009
...
...
@@ -14,12 +14,12 @@ export function SocketProvider({ children, options, url }: SocketProviderProps)
const
[
socket
,
setSocket
]
=
useState
<
Socket
|
null
>
(
null
);
useEffect
(()
=>
{
const
s
=
new
Socket
(
url
,
options
);
s
.
connect
();
setSocket
(
s
);
const
s
ocketInstance
=
new
Socket
(
url
,
options
);
s
ocketInstance
.
connect
();
setSocket
(
s
ocketInstance
);
return
()
=>
{
s
.
disconnect
();
s
ocketInstance
.
disconnect
();
setSocket
(
null
);
};
},
[
options
,
url
]);
...
...
@@ -34,7 +34,7 @@ export function SocketProvider({ children, options, url }: SocketProviderProps)
export
function
useSocket
()
{
const
context
=
React
.
useContext
(
SocketContext
);
if
(
context
===
undefined
)
{
throw
new
Error
(
'
use
Coun
t must be used within a SocketProvider
'
);
throw
new
Error
(
'
use
Socke
t must be used within a SocketProvider
'
);
}
return
context
;
}
lib/socket/useSocketChannel.tsx
View file @
9a432009
...
...
@@ -20,8 +20,8 @@ export default function useSocketChannel({ topic, params, isDisabled, onJoin, on
const
onCloseRef
=
useRef
<
string
>
();
const
onErrorRef
=
useRef
<
string
>
();
const
onJoin
Fun
=
useRef
(
onJoin
);
onJoin
Fun
.
current
=
onJoin
;
const
onJoin
Ref
=
useRef
(
onJoin
);
onJoin
Ref
.
current
=
onJoin
;
useEffect
(()
=>
{
const
cleanUpRefs
=
()
=>
{
...
...
@@ -31,7 +31,7 @@ export default function useSocketChannel({ topic, params, isDisabled, onJoin, on
if
(
!
isDisabled
)
{
onCloseRef
.
current
=
onSocketClose
&&
socket
?.
onClose
(
onSocketClose
);
onErrorRef
.
current
=
onSocketError
&&
socket
?.
on
Close
(
onSocketError
);
onErrorRef
.
current
=
onSocketError
&&
socket
?.
on
Error
(
onSocketError
);
}
else
{
cleanUpRefs
();
}
...
...
@@ -52,7 +52,7 @@ export default function useSocketChannel({ topic, params, isDisabled, onJoin, on
}
const
ch
=
socket
.
channel
(
topic
,
params
);
ch
.
join
().
receive
(
'
ok
'
,
(
message
)
=>
onJoin
Fun
.
current
?.(
ch
,
message
));
ch
.
join
().
receive
(
'
ok
'
,
(
message
)
=>
onJoin
Ref
.
current
?.(
ch
,
message
));
setChannel
(
ch
);
return
()
=>
{
...
...
lib/socket/useSocketMessage.tsx
View file @
9a432009
...
...
@@ -3,8 +3,8 @@ import { useEffect, useRef } from 'react';
import
type
{
SocketMessageParams
}
from
'
lib/socket/types
'
;
export
default
function
useSocketMessage
({
channel
,
event
,
handler
}:
SocketMessageParams
)
{
const
handler
Fun
=
useRef
(
handler
);
handler
Fun
.
current
=
handler
;
const
handler
Ref
=
useRef
(
handler
);
handler
Ref
.
current
=
handler
;
useEffect
(()
=>
{
if
(
channel
===
undefined
)
{
...
...
@@ -12,7 +12,7 @@ export default function useSocketMessage({ channel, event, handler }: SocketMess
}
const
ref
=
channel
.
on
(
event
,
(
message
)
=>
{
handler
Fun
.
current
?.(
message
);
handler
Ref
.
current
?.(
message
);
});
return
()
=>
{
...
...
ui/pages/Transaction.tsx
View file @
9a432009
...
...
@@ -48,7 +48,7 @@ const TransactionPageContent = () => {
return
<
ExternalLink
key=
{
explorer
.
baseUrl
}
title=
{
`Open in ${ explorer.title }`
}
href=
{
url
.
toString
()
}
/>;
});
const
hasGoBackLink
=
false
&&
isBrowser
()
&&
window
.
document
.
referrer
.
includes
(
'
/txs
'
);
const
hasGoBackLink
=
isBrowser
()
&&
window
.
document
.
referrer
.
includes
(
'
/txs
'
);
return
(
<
Page
>
...
...
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