2024-07-20 02:30:45 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
2024-07-22 19:52:08 +02:00
|
|
|
import ConnectionViewModel from "../../ViewModel/Global/connectionViewModel";
|
2024-07-20 03:34:54 +02:00
|
|
|
import { DeletableListItem } from "../Components/deletableListItem";
|
2026-04-09 16:48:22 +00:00
|
|
|
import CoreViewModel from "../../ViewModel/Global/coreViewModel";
|
2024-07-20 02:30:45 +02:00
|
|
|
|
2026-04-09 16:48:22 +00:00
|
|
|
export function ConnectionModal(
|
|
|
|
|
coreViewModel: CoreViewModel,
|
|
|
|
|
connectionViewModel: ConnectionViewModel,
|
|
|
|
|
) {
|
2026-04-01 08:29:39 +00:00
|
|
|
const previousAddressConverter: React.StateItemConverter<string> = (
|
|
|
|
|
address: string,
|
|
|
|
|
) => {
|
|
|
|
|
function connnect() {
|
|
|
|
|
connectionViewModel.connectToAddress(address);
|
|
|
|
|
}
|
2024-07-20 03:39:47 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
const cannotConnect = React.createProxyState(
|
|
|
|
|
[connectionViewModel.isConnected],
|
|
|
|
|
() =>
|
|
|
|
|
connectionViewModel.isConnected.value == true &&
|
2026-04-09 16:48:22 +00:00
|
|
|
connectionViewModel.coreViewModel.connectionModel.address ==
|
|
|
|
|
address,
|
2026-04-01 08:29:39 +00:00
|
|
|
);
|
2024-07-20 03:39:47 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
return DeletableListItem(
|
2026-04-09 16:48:22 +00:00
|
|
|
coreViewModel,
|
2026-04-01 08:29:39 +00:00
|
|
|
address,
|
|
|
|
|
<button
|
|
|
|
|
class="primary"
|
|
|
|
|
on:click={connnect}
|
|
|
|
|
toggle:disabled={cannotConnect}
|
|
|
|
|
aria-label={
|
2026-04-09 16:48:22 +00:00
|
|
|
coreViewModel.translations.connectionModal
|
|
|
|
|
.connectButtonAudioLabel
|
2026-04-01 08:29:39 +00:00
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">link</span>
|
|
|
|
|
</button>,
|
|
|
|
|
() => {
|
|
|
|
|
connectionViewModel.removePreviousAddress(address);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
};
|
2024-07-20 03:34:54 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
class="modal"
|
|
|
|
|
toggle:open={connectionViewModel.isShowingConnectionModal}
|
|
|
|
|
>
|
|
|
|
|
<div>
|
|
|
|
|
<main>
|
|
|
|
|
<h2>
|
2026-04-09 16:48:22 +00:00
|
|
|
{
|
|
|
|
|
coreViewModel.translations.connectionModal
|
|
|
|
|
.connectionModalHeadline
|
|
|
|
|
}
|
2026-04-01 08:29:39 +00:00
|
|
|
</h2>
|
2024-07-20 02:56:44 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
<div
|
|
|
|
|
class="flex-column gap"
|
|
|
|
|
children:append={[
|
|
|
|
|
connectionViewModel.previousAddresses,
|
|
|
|
|
previousAddressConverter,
|
|
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
</main>
|
|
|
|
|
<button on:click={connectionViewModel.hideConnectionModal}>
|
2026-04-09 16:48:22 +00:00
|
|
|
{coreViewModel.translations.general.closeButton}
|
2026-04-01 08:29:39 +00:00
|
|
|
<span class="icon">close</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2024-07-20 02:30:45 +02:00
|
|
|
}
|