Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
a7f85622
Commit
a7f85622
authored
6 years ago
by
DD
Browse files
Options
Downloads
Patches
Plain Diff
preload fonts
parent
42196205
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/containers/gui.jsx
+35
-12
35 additions, 12 deletions
src/containers/gui.jsx
with
35 additions
and
12 deletions
src/containers/gui.jsx
+
35
−
12
View file @
a7f85622
...
...
@@ -4,6 +4,7 @@ import React from 'react';
import
VM
from
'
scratch-vm
'
;
import
{
connect
}
from
'
react-redux
'
;
import
ReactModal
from
'
react-modal
'
;
import
bindAll
from
'
lodash.bindall
'
;
import
ErrorBoundaryHOC
from
'
../lib/error-boundary-hoc.jsx
'
;
import
{
openExtensionLibrary
}
from
'
../reducers/modals
'
;
...
...
@@ -28,6 +29,9 @@ import GUIComponent from '../components/gui/gui.jsx';
class
GUI
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
bindAll
(
this
,
[
'
loadProject
'
]);
this
.
state
=
{
loading
:
!
props
.
vm
.
initialized
,
loadingError
:
false
,
...
...
@@ -42,19 +46,24 @@ class GUI extends React.Component {
if
(
this
.
props
.
vm
.
initialized
)
return
;
this
.
audioEngine
=
new
AudioEngine
();
this
.
props
.
vm
.
attachAudioEngine
(
this
.
audioEngine
);
this
.
props
.
vm
.
loadProject
(
this
.
props
.
projectData
)
.
then
(()
=>
{
this
.
setState
({
loading
:
false
},
()
=>
{
this
.
props
.
vm
.
setCompatibilityMode
(
true
);
this
.
props
.
vm
.
start
();
});
})
.
catch
(
e
=>
{
// Need to catch this error and update component state so that
// error page gets rendered if project failed to load
this
.
setState
({
loadingError
:
true
,
errorMessage
:
e
});
});
this
.
props
.
vm
.
initialized
=
true
;
const
fontPromises
=
[];
if
(
document
.
fonts
&&
document
.
fonts
.
values
.
length
)
{
for
(
const
fontFace
of
document
.
fonts
.
values
())
{
fontPromises
.
push
(
fontFace
.
loaded
);
fontFace
.
load
();
}
}
if
(
document
.
readyState
===
'
complete
'
)
{
Promise
.
all
(
fontPromises
).
then
(
this
.
loadProject
);
}
else
{
document
.
onreadystatechange
=
()
=>
{
if
(
document
.
readyState
!==
'
complete
'
)
return
;
document
.
onreadystatechange
=
null
;
Promise
.
all
(
fontPromises
).
then
(
this
.
loadProject
);
};
}
}
componentWillReceiveProps
(
nextProps
)
{
if
(
this
.
props
.
projectData
!==
nextProps
.
projectData
)
{
...
...
@@ -74,6 +83,20 @@ class GUI extends React.Component {
this
.
props
.
onUpdateReduxProjectTitle
(
nextProps
.
projectTitle
);
}
}
loadProject
()
{
return
this
.
props
.
vm
.
loadProject
(
this
.
props
.
projectData
)
.
then
(()
=>
{
this
.
setState
({
loading
:
false
},
()
=>
{
this
.
props
.
vm
.
setCompatibilityMode
(
true
);
this
.
props
.
vm
.
start
();
});
})
.
catch
(
e
=>
{
// Need to catch this error and update component state so that
// error page gets rendered if project failed to load
this
.
setState
({
loadingError
:
true
,
errorMessage
:
e
});
});
}
render
()
{
if
(
this
.
state
.
loadingError
)
{
throw
new
Error
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment