mirror of
https://codeberg.org/emersion/gamja
synced 2025-03-12 23:43:42 +01:00
Add button to enable protocol handler in settings
This commit is contained in:
parent
7cabb6f85b
commit
fa80a56516
@ -1697,7 +1697,15 @@ export default class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleOpenSettingsClick() {
|
handleOpenSettingsClick() {
|
||||||
this.openDialog("settings");
|
let showProtocolHandler = false;
|
||||||
|
for (let [id, client] of this.clients) {
|
||||||
|
if (client.caps.enabled.has("soju.im/bouncer-networks")) {
|
||||||
|
showProtocolHandler = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.openDialog("settings", { showProtocolHandler });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSettingsChange(settings) {
|
handleSettingsChange(settings) {
|
||||||
@ -1880,6 +1888,7 @@ export default class App extends Component {
|
|||||||
<${Dialog} title="Settings" onDismiss=${this.dismissDialog}>
|
<${Dialog} title="Settings" onDismiss=${this.dismissDialog}>
|
||||||
<${SettingsForm}
|
<${SettingsForm}
|
||||||
settings=${this.state.settings}
|
settings=${this.state.settings}
|
||||||
|
showProtocolHandler=${dialogData.showProtocolHandler}
|
||||||
onChange=${this.handleSettingsChange}
|
onChange=${this.handleSettingsChange}
|
||||||
onDisconnect=${() => this.disconnectAll()}
|
onDisconnect=${() => this.disconnectAll()}
|
||||||
onClose=${() => this.dismissDialog()}
|
onClose=${() => this.dismissDialog()}
|
||||||
|
@ -26,7 +26,35 @@ export default class SettingsForm extends Component {
|
|||||||
this.props.onClose();
|
this.props.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerProtocol() {
|
||||||
|
let url = window.location.origin + window.location.pathname + "?open=%s";
|
||||||
|
try {
|
||||||
|
navigator.registerProtocolHandler("irc", url);
|
||||||
|
navigator.registerProtocolHandler("ircs", url);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to register protocol handler: ", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let protocolHandler = null;
|
||||||
|
if (this.props.showProtocolHandler) {
|
||||||
|
protocolHandler = html`
|
||||||
|
<div class="protocol-handler">
|
||||||
|
<div class="left">
|
||||||
|
Set gamja as your default IRC client for this browser.
|
||||||
|
IRC links will be automatically opened here.
|
||||||
|
</div>
|
||||||
|
<div class="right">
|
||||||
|
<button type="button" onClick=${() => this.registerProtocol()}>
|
||||||
|
Enable
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br/><br/>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<form onChange=${this.handleChange} onSubmit=${this.handleSubmit}>
|
<form onChange=${this.handleChange} onSubmit=${this.handleSubmit}>
|
||||||
<label>
|
<label>
|
||||||
@ -70,6 +98,8 @@ export default class SettingsForm extends Component {
|
|||||||
</label>
|
</label>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
|
||||||
|
${protocolHandler}
|
||||||
|
|
||||||
<button type="button" class="danger" onClick=${() => this.props.onDisconnect()}>
|
<button type="button" class="danger" onClick=${() => this.props.onDisconnect()}>
|
||||||
Disconnect
|
Disconnect
|
||||||
</button>
|
</button>
|
||||||
|
@ -533,6 +533,14 @@ details summary[role="button"] {
|
|||||||
overflow: auto; /* hack to clear floating elements */
|
overflow: auto; /* hack to clear floating elements */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dialog .protocol-handler {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
.dialog .protocol-handler .left {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
kbd {
|
kbd {
|
||||||
background-color: #f0f0f0;
|
background-color: #f0f0f0;
|
||||||
border: 1px solid #bfbfbf;
|
border: 1px solid #bfbfbf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user