Get rid of shared browser instance
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.moco-bx-bubble {
|
.moco-bx-bubble {
|
||||||
|
box-sizing: content-box;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 2rem;
|
bottom: 2rem;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ class App extends Component {
|
|||||||
subdomain: PropTypes.string,
|
subdomain: PropTypes.string,
|
||||||
apiKey: PropTypes.string,
|
apiKey: PropTypes.string,
|
||||||
version: PropTypes.string
|
version: PropTypes.string
|
||||||
}),
|
})
|
||||||
browser: PropTypes.object.isRequired
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@observable projects = []
|
@observable projects = []
|
||||||
@@ -102,7 +101,7 @@ class App extends Component {
|
|||||||
this.lastTaskId = data.lastTaskId
|
this.lastTaskId = data.lastTaskId
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(error)
|
this.sendMessage({ type: 'closeForm' })
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
@@ -161,7 +160,7 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendMessage = action =>
|
sendMessage = action =>
|
||||||
this.props.browser.tabs.query(
|
chrome.tabs.query(
|
||||||
{ active: true, currentWindow: true },
|
{ active: true, currentWindow: true },
|
||||||
tabs => chrome.tabs.sendMessage(tabs[0].id, action)
|
tabs => chrome.tabs.sendMessage(tabs[0].id, action)
|
||||||
)
|
)
|
||||||
@@ -176,7 +175,7 @@ class App extends Component {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="moco-bx-logo__container">
|
<div className="moco-bx-logo__container">
|
||||||
<img className="moco-bx-logo" src={this.props.browser.extension.getURL(logoUrl)} />
|
<img className="moco-bx-logo" src={chrome.extension.getURL(logoUrl)} />
|
||||||
<h1>MOCO Zeiterfassung</h1>
|
<h1>MOCO Zeiterfassung</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ class Bubble extends Component {
|
|||||||
subdomain: PropTypes.string,
|
subdomain: PropTypes.string,
|
||||||
apiKey: PropTypes.string,
|
apiKey: PropTypes.string,
|
||||||
version: PropTypes.string
|
version: PropTypes.string
|
||||||
}),
|
})
|
||||||
browser: PropTypes.object.isRequired,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#apiClient;
|
#apiClient;
|
||||||
@@ -64,12 +63,12 @@ class Bubble extends Component {
|
|||||||
fireImmediately: true
|
fireImmediately: true
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
this.props.browser.runtime.onMessage.addListener(this.receiveMessage)
|
chrome.runtime.onMessage.addListener(this.receiveMessage)
|
||||||
window.addEventListener("keydown", this.handleKeyDown, true)
|
window.addEventListener("keydown", this.handleKeyDown, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.props.browser.runtime.onMessage.removeListener(this.receiveMessage)
|
chrome.runtime.onMessage.removeListener(this.receiveMessage)
|
||||||
window.removeEventListener("keydown", this.handleKeyDown)
|
window.removeEventListener("keydown", this.handleKeyDown)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,11 +136,11 @@ class Bubble extends Component {
|
|||||||
return <Spinner />
|
return <Spinner />
|
||||||
}
|
}
|
||||||
|
|
||||||
const { service, settings, browser } = this.props
|
const { service, settings } = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="moco-bx-bubble" onClick={this.open} style={service.position}>
|
<div className="moco-bx-bubble" onClick={this.open} style={service.position}>
|
||||||
<img className="moco-bx-logo" src={this.props.browser.extension.getURL(logoUrl)} />
|
<img className="moco-bx-logo" src={chrome.extension.getURL(logoUrl)} />
|
||||||
{this.bookedHours > 0
|
{this.bookedHours > 0
|
||||||
? <span className="moco-bx-badge">{this.bookedHours}h</span>
|
? <span className="moco-bx-badge">{this.bookedHours}h</span>
|
||||||
: null
|
: null
|
||||||
@@ -150,7 +149,6 @@ class Bubble extends Component {
|
|||||||
<Popup
|
<Popup
|
||||||
service={service}
|
service={service}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
browser={browser}
|
|
||||||
unauthorizedError={this.unauthorizedError}
|
unauthorizedError={this.unauthorizedError}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const Popup = props => {
|
|||||||
{props.unauthorizedError
|
{props.unauthorizedError
|
||||||
? <InvalidConfigurationError />
|
? <InvalidConfigurationError />
|
||||||
: <iframe
|
: <iframe
|
||||||
src={props.browser.extension.getURL(`popup.html?${queryString.stringify(serializedProps)}`)}
|
src={chrome.extension.getURL(`popup.html?${queryString.stringify(serializedProps)}`)}
|
||||||
width={styles.width}
|
width={styles.width}
|
||||||
height={styles.height} />
|
height={styles.height} />
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,6 @@ const Popup = props => {
|
|||||||
|
|
||||||
Popup.propTypes = {
|
Popup.propTypes = {
|
||||||
service: PropTypes.object.isRequired,
|
service: PropTypes.object.isRequired,
|
||||||
browser: PropTypes.object.isRequired,
|
|
||||||
unauthorizedError: PropTypes.bool.isRequired
|
unauthorizedError: PropTypes.bool.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user