2024-07-09 17:23:29 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
|
|
|
|
import { Chat } from "../Model/chatModel";
|
2024-07-09 22:03:04 +02:00
|
|
|
import { closeChatView } from "../Model/model";
|
2024-07-09 17:23:29 +02:00
|
|
|
import { translation } from "../translations";
|
|
|
|
|
|
|
|
|
|
export function ChatOptionModal(chat: Chat, isPresented: React.State<boolean>) {
|
|
|
|
|
function closeModal() {
|
|
|
|
|
isPresented.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-09 17:32:51 +02:00
|
|
|
function deleteChat() {
|
2024-07-09 18:23:35 +02:00
|
|
|
chat.deleteSelf();
|
2024-07-09 17:32:51 +02:00
|
|
|
closeModal();
|
2024-07-09 22:03:04 +02:00
|
|
|
closeChatView();
|
2024-07-09 17:32:51 +02:00
|
|
|
}
|
|
|
|
|
|
2024-07-09 19:50:43 +02:00
|
|
|
const shouldShowKey = new React.State(false);
|
|
|
|
|
const inputType = React.createProxyState([shouldShowKey], () =>
|
|
|
|
|
shouldShowKey.value == true ? "text" : "password"
|
|
|
|
|
);
|
|
|
|
|
|
2024-07-09 17:23:29 +02:00
|
|
|
const secondaryChannelConverter: React.ListItemConverter<string> = (
|
|
|
|
|
secondaryChannel
|
|
|
|
|
) => {
|
|
|
|
|
function remove() {
|
|
|
|
|
chat.removeSecondaryChannel(secondaryChannel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="tile width-input padding-0">
|
|
|
|
|
<div class="flex-row justify-apart align-center">
|
|
|
|
|
<b class="padding-h">{secondaryChannel}</b>
|
|
|
|
|
<button
|
|
|
|
|
class="danger"
|
|
|
|
|
aria-label={translation.removeSecondaryChannel}
|
|
|
|
|
on:click={remove}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">delete</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="modal" toggle:open={isPresented}>
|
|
|
|
|
<div>
|
|
|
|
|
<main>
|
|
|
|
|
<h2>{translation.configureChatTitle}</h2>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<label class="tile">
|
|
|
|
|
<span class="icon">forum</span>
|
|
|
|
|
<div>
|
|
|
|
|
<span>{translation.primaryChannel}</span>
|
|
|
|
|
<input
|
|
|
|
|
bind:value={chat.primaryChannelInput}
|
|
|
|
|
placeholder={translation.primaryChannelPlaceholder}
|
|
|
|
|
on:enter={chat.setChannel}
|
|
|
|
|
></input>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="flex-row width-input">
|
|
|
|
|
<button
|
|
|
|
|
aria-label={translation.undoChanges}
|
|
|
|
|
class="flex justify-center"
|
|
|
|
|
on:click={chat.undoChannelChange}
|
|
|
|
|
toggle:disabled={chat.cannotUndoChannel}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">undo</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
aria-label={translation.set}
|
|
|
|
|
class="flex justify-center primary"
|
|
|
|
|
on:click={chat.setChannel}
|
|
|
|
|
toggle:disabled={chat.cannotSetChannel}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">check</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
|
|
|
|
<div class="flex-row margin-bottom width-input">
|
|
|
|
|
<input
|
|
|
|
|
aria-label={translation.secondaryChannel}
|
|
|
|
|
placeholder={translation.secondaryChannelPlaceholder}
|
|
|
|
|
bind:value={chat.newSecondaryChannelName}
|
|
|
|
|
on:enter={chat.addSecondaryChannel}
|
|
|
|
|
></input>
|
|
|
|
|
<button
|
|
|
|
|
class="primary"
|
|
|
|
|
toggle:disabled={chat.cannotAddSecondaryChannel}
|
|
|
|
|
aria-label={translation.addSecondaryChannel}
|
|
|
|
|
on:click={chat.addSecondaryChannel}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">add</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="flex-column gap"
|
|
|
|
|
children:prepend={[
|
|
|
|
|
chat.secondaryChannels,
|
|
|
|
|
secondaryChannelConverter,
|
|
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
2024-07-09 18:46:02 +02:00
|
|
|
<div>
|
|
|
|
|
<label class="tile">
|
|
|
|
|
<span class="icon">key</span>
|
|
|
|
|
<div>
|
|
|
|
|
<span>{translation.encryptionKey}</span>
|
|
|
|
|
<input
|
|
|
|
|
placeholder={translation.encryptionKeyPlaceholder}
|
|
|
|
|
bind:value={chat.encryptionKey}
|
2024-07-09 19:50:43 +02:00
|
|
|
set:type={inputType}
|
2024-07-09 18:46:02 +02:00
|
|
|
></input>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
2024-07-09 19:50:43 +02:00
|
|
|
|
|
|
|
|
<label class="inline margin-0">
|
|
|
|
|
<input type="checkbox" bind:checked={shouldShowKey}></input>
|
|
|
|
|
{translation.showKey}
|
|
|
|
|
</label>
|
2024-07-09 18:46:02 +02:00
|
|
|
</div>
|
2024-07-09 17:32:51 +02:00
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
2024-07-09 18:23:35 +02:00
|
|
|
<div class="flex-column gap">
|
2024-07-09 21:56:00 +02:00
|
|
|
<button
|
|
|
|
|
class="danger"
|
|
|
|
|
on:click={chat.clearMessages}
|
|
|
|
|
toggle:disabled={chat.cannotClearMessages}
|
|
|
|
|
>
|
2024-07-09 18:23:35 +02:00
|
|
|
{translation.clearChatMessages}
|
|
|
|
|
<span class="icon">delete_sweep</span>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<button class="danger" on:click={deleteChat}>
|
|
|
|
|
{translation.removeChat}
|
|
|
|
|
<span class="icon">delete</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2024-07-09 17:23:29 +02:00
|
|
|
</main>
|
2024-07-09 17:32:51 +02:00
|
|
|
<button on:click={closeModal}>
|
2024-07-09 17:23:29 +02:00
|
|
|
{translation.close}
|
|
|
|
|
<span class="icon">close</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|