Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set Explore defaults on app load #2268

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"ipfs-css": "^1.4.0",
"ipfs-geoip": "^9.1.0",
"ipfs-provider": "^2.1.0",
"ipld-explorer-components": "^7.0.2",
"ipld-explorer-components": "^7.0.3",
"is-ipfs": "^8.0.1",
"istextorbinary": "^6.0.0",
"it-all": "^1.0.5",
Expand Down
7 changes: 7 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import FilesExploreForm from './files/explore-form/FilesExploreForm.js'

export class App extends Component {
static propTypes = {
doSetupLocalStorage: PropTypes.func.isRequired,
doTryInitIpfs: PropTypes.func.isRequired,
doInitHelia: PropTypes.func.isRequired,
doUpdateUrl: PropTypes.func.isRequired,
Expand All @@ -32,6 +33,11 @@ export class App extends Component {
isOver: PropTypes.bool.isRequired
}

constructor (props) {
super(props)
props.doSetupLocalStorage()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to work on initial page load.
If you use empty browser profile and load webui, and then go to ipld explorer and click on wikipedia example you will see spinner forever, and no request:

2024-09-24_00-25_1
2024-09-24_00-25

If you then force-reload the page (F5) the helia will initialize with local gateway and work fine:

2024-09-24_00-29

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think landing directly on explore page might cause the issue?

Issue doesn't happen if you land on status page first

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to call the localStorage fn in router / component loader

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

landing directly on explore page works for me with the latest.

2024-09-24.at.9.53.41.-.Blue.Bobolink.mp4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that was it. New version works fine.

ps. TIL Firefox does not support HEVC while it is encumbered by patents, so inline player does not work (but i played fine with external player):

image

}

componentDidMount () {
this.props.doTryInitIpfs()
this.props.doInitHelia()
Expand Down Expand Up @@ -131,6 +137,7 @@ export default connect(
'doExploreUserProvidedPath',
'doUpdateUrl',
'doUpdateHash',
'doSetupLocalStorage',
'doTryInitIpfs',
'doInitHelia',
'doFilesWrite',
Expand Down
19 changes: 19 additions & 0 deletions src/bundles/ipfs-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,25 @@ const selectors = {
*/

const actions = {

doSetupLocalStorage: () => async () => {
/** For the Explore page (i.e. ipld-explorer-components) */
const useRemoteGatewaysToExplore = localStorage.getItem('explore.ipld.gatewayEnabled')
if (useRemoteGatewaysToExplore === null) {
// by default, disable remote gateways for the Explore page (i.e. ipld-explorer-components)
await writeSetting('explore.ipld.gatewayEnabled', false)
}

const kuboGateway = readSetting('kuboGateway')
if (kuboGateway === null || typeof kuboGateway === 'string' || typeof kuboGateway === 'boolean' || typeof kuboGateway === 'number') {
// empty or invalid, set defaults
await writeSetting('kuboGateway', { trustlessBlockBrokerConfig: { init: { allowLocal: true, allowInsecure: false } } })
} else if (/** @type {Record<string, any>} */(kuboGateway).trustlessBlockBrokerConfig == null) {
// missing trustlessBlockBrokerConfig, set defaults
await writeSetting('kuboGateway', { ...kuboGateway, trustlessBlockBrokerConfig: { init: { allowLocal: true, allowInsecure: false } } })
}
},

/**
* @returns {function(Context):Promise<boolean>}
*/
Expand Down
Loading