focus object title input automatically, update handling of untitled objects

This commit is contained in:
marlon-erler
2024-07-11 21:02:28 +02:00
parent cf0d327110
commit 7aa32a6c51
6 changed files with 450 additions and 449 deletions
+6 -2
View File
@@ -14,6 +14,7 @@ import { decryptString, encryptString } from "../cryptUtility";
import { Message } from "udn-frontend";
import { storageKeys } from "../utility";
import { translation } from "../translations";
// TYPES
// message
@@ -174,8 +175,7 @@ export class Chat {
this.encryptionKey.value
);
const messageObject = JSON.parse(decryptedMessageObjectString);
if (messageObject.id && messageObject.title)
return this.handleMessageObject(messageObject);
if (messageObject.id) return this.handleMessageObject(messageObject);
}
this.handleMessage({
@@ -400,6 +400,10 @@ export class Chat {
return messageObject.contentVersions[contentId];
};
getObjectTitle = (messageObject: MessageObject) => {
return messageObject.title || translation.untitledObject;
};
// channel
setChannel = (): void => {
if (this.cannotSetChannel.value == true) return;
+1 -1
View File
@@ -20,7 +20,7 @@ export function AllObjectsView(
return (
<button class="tile" on:click={select}>
<div>
<b>{messageObject.title}</b>
<b>{chat.getObjectTitle(messageObject)}</b>
<span class="secondary">{messageObject.id}</span>
</div>
</button>
+2 -5
View File
@@ -46,7 +46,7 @@ export function ChatObjectView(chat: Chat) {
// methods
function createObject() {
const newObject = chat.createObjectFromTitle(translation.untitledObject);
const newObject = chat.createObjectFromTitle("");
chat.addObjectAndSend(newObject);
selectedObject.value = newObject;
isShowingObjectModal.value = true;
@@ -69,10 +69,7 @@ export function ChatObjectView(chat: Chat) {
)}
</div>
<button
class="height-100"
disabled
>
<button class="height-100" disabled>
<span class="icon">visibility</span>
</button>
</div>
+1 -1
View File
@@ -22,7 +22,7 @@ export function NoteObjectsView(
return (
<button class="tile" on:click={select}>
<div>
<b>{messageObject.title}</b>
<b>{chat.getObjectTitle(messageObject)}</b>
<span class="secondary ellipsis">
{latest.noteContent!.split("\n")[0]}
</span>
+10 -6
View File
@@ -68,11 +68,19 @@ export function ObjectDetailModal(
closeModal();
}
const input = (
<input
bind:value={editingTitle}
placeholder={translation.objectTitlePlaceholder}
></input>
);
isPresented.subscribe(() => setTimeout(() => input.focus(), 100));
return (
<div class="modal" toggle:open={isPresented} on:keydown={handleKeyDown}>
<div>
<main>
<h2>{messageObject.title}</h2>
<h2>{chat.getObjectTitle(messageObject)}</h2>
<span class="secondary">{messageObject.id}</span>
<hr></hr>
@@ -82,11 +90,7 @@ export function ObjectDetailModal(
<span class="icon">label</span>
<div>
<span>{translation.objectTitle}</span>
<input
autofocus
bind:value={editingTitle}
placeholder={translation.objectTitlePlaceholder}
></input>
{input}
</div>
</label>