Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lbry
lbry-react-native
Commits
0db2c7e6
Commit
0db2c7e6
authored
Feb 24, 2020
by
Akinwale Ariwodola
Browse files
basic repost redirect handling
parent
f05d357f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/page/file/view.js
View file @
0db2c7e6
...
...
@@ -104,6 +104,8 @@ class FilePage extends React.PureComponent {
stopDownloadConfirmed
:
false
,
streamingMode
:
false
,
viewCountFetched
:
false
,
isRepost
:
false
,
uriPushedToDrawerStack
:
false
,
};
}
...
...
@@ -114,6 +116,22 @@ class FilePage extends React.PureComponent {
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
checkRepost
=
()
=>
{
const
{
claim
,
isResolvingUri
,
navigation
,
pushDrawerStack
}
=
this
.
props
;
const
{
uri
}
=
this
.
state
;
if
(
!
isResolvingUri
)
{
if
(
claim
&&
claim
.
repost_url
)
{
// redirect to canonical url
this
.
setState
({
isRepost
:
true
});
navigateToUri
(
navigation
,
claim
.
canonical_url
,
null
,
false
,
claim
.
permanent_url
,
false
,
true
);
}
else
{
this
.
setState
({
uriPushedToDrawerStack
:
true
},
()
=>
{
pushDrawerStack
(
uri
);
});
}
}
};
onComponentFocused
=
()
=>
{
StatusBar
.
setHidden
(
false
);
NativeModules
.
Firebase
.
setCurrentScreen
(
'
File
'
).
then
(
result
=>
{
...
...
@@ -130,6 +148,8 @@ class FilePage extends React.PureComponent {
setPlayerVisible
(
true
,
uri
);
if
(
!
isResolvingUri
&&
!
claim
)
resolveUri
(
uri
);
this
.
checkRepost
();
this
.
fetchFileInfo
(
uri
,
this
.
props
);
this
.
fetchCostInfo
(
uri
,
this
.
props
);
...
...
@@ -283,6 +303,11 @@ class FilePage extends React.PureComponent {
resolveUri
(
uri
);
}
if
(
!
prevProps
.
claim
&&
claim
)
{
this
.
checkRepost
();
return
;
}
// Returned to the page. If mediaLoaded, and currentMediaInfo is different, update
if
(
this
.
state
.
mediaLoaded
&&
window
.
currentMediaInfo
&&
window
.
currentMediaInfo
.
uri
!==
this
.
state
.
uri
)
{
const
{
metadata
}
=
this
.
props
;
...
...
@@ -973,6 +998,12 @@ class FilePage extends React.PureComponent {
let
innerContent
=
null
;
if
((
isResolvingUri
&&
!
claim
)
||
!
claim
)
{
if
(
!
isResolvingUri
&&
!
claim
&&
!
this
.
state
.
uriPushedToDrawerStack
)
{
this
.
setState
({
uriPushedToDrawerStack
:
true
},
()
=>
{
pushDrawerStack
(
uri
);
});
}
return
(
<
View
style
=
{
filePageStyle
.
pageContainer
}
>
<
UriBar
value
=
{
uri
}
navigation
=
{
navigation
}
/
>
...
...
@@ -1041,6 +1072,17 @@ class FilePage extends React.PureComponent {
tags
=
claim
.
value
.
tags
;
}
if
(
!
isResolvingUri
&&
this
.
state
.
isRepost
)
{
return
null
;
}
// in case we somehow get here without the uri pushed to the drawer stack
if
(
!
isResolvingUri
&&
!
this
.
state
.
isRepost
&&
!
this
.
state
.
uriPushedToDrawerStack
)
{
this
.
setState
({
uriPushedToDrawerStack
:
true
},
()
=>
{
pushDrawerStack
(
uri
);
});
}
const
completed
=
fileInfo
&&
fileInfo
.
completed
;
const
isRewardContent
=
rewardedContentClaimIds
.
includes
(
claim
.
claim_id
);
const
description
=
metadata
.
description
?
metadata
.
description
:
null
;
...
...
src/utils/helper.js
View file @
0db2c7e6
...
...
@@ -116,7 +116,15 @@ function parseUriVars(vars) {
return
uriVars
;
}
export
function
navigateToUri
(
navigation
,
uri
,
additionalParams
,
isNavigatingBack
,
fullUri
,
setPlayerVisible
)
{
export
function
navigateToUri
(
navigation
,
uri
,
additionalParams
,
isNavigatingBack
,
fullUri
,
setPlayerVisible
,
pushStack
=
false
,
)
{
if
(
!
navigation
)
{
return
;
}
...
...
@@ -154,7 +162,7 @@ export function navigateToUri(navigation, uri, additionalParams, isNavigatingBac
}
navigation
.
navigate
({
routeName
:
'
File
'
,
key
:
uri
,
params
});
if
(
store
&&
store
.
dispatch
&&
!
isNavigatingBack
)
{
if
(
pushStack
&&
store
&&
store
.
dispatch
&&
!
isNavigatingBack
)
{
store
.
dispatch
(
doPushDrawerStack
(
uri
));
}
}
...
...
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