Forum photos, a one-row bottom menu, and the site's own question windows
Photos in posts and replies: a "Fotó" button in the new thread form and the reply boxes. The browser makes the picture small before uploading it (1600 pixels at most, WebP, JPEG where WebP cannot be made); the forum checks it is a still picture, strips its metadata and makes a square preview (forum-photos/ in the storage). Five a member a day, five a post; one taken off before sending is deleted and does not count. Under the post a row of square previews; a click opens a viewer paged with arrows, swipes and keys. Seen by whoever may read the thread (long public cache only for public topics). Unsent photos go after a day, those of removed posts after a year; removed with the account and listed in the data export. Terms and privacy notice updated. The forum's bottom menu keeps its five items in one row (the fifth wrapped to a second row). On iPhones, when the keyboard goes away without the usual tap (a photo picker opening over it), the page is put back in place instead of the menu floating mid-screen over an empty strip. The browser's own confirm() and prompt() windows (23 places: deleting, revoking, blocking, muting, moderators' reasons, admin actions) are replaced by a question window in the site's look, following the forum's light or dark theme, with named buttons and a text box for reasons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -3,10 +3,12 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
import { api } from "@/lib/api";
|
||||
import { usePhotoUploads } from "@/lib/photos";
|
||||
import { convertEmoticons, withEmoji } from "@/lib/emoticons";
|
||||
import type { ForumAuthor } from "@/lib/forum";
|
||||
|
||||
import { Avatar } from "./Avatar";
|
||||
import { PhotoButton, PickedPhotos } from "./Photos";
|
||||
|
||||
/** "@Ho" right before the caret: what was typed after the "@", and where it starts. */
|
||||
function mentionAt(text: string, caret: number): { query: string; start: number } | null {
|
||||
@@ -22,6 +24,7 @@ function mentionAt(text: string, caret: number): { query: string; start: number
|
||||
* `onTyping`: called on every keystroke (the "… gépel" notice).
|
||||
* `mentions`: typing "@Ho" offers the members whose nickname starts so.
|
||||
* `onChange`: the text as it is typed (to keep a draft when the box moves).
|
||||
* `photos`: a "Fotó" button; the uploaded photos' ids go with the text.
|
||||
*/
|
||||
export function Composer({
|
||||
id,
|
||||
@@ -35,6 +38,7 @@ export function Composer({
|
||||
onTyping,
|
||||
onChange,
|
||||
mentions = false,
|
||||
photos = false,
|
||||
rows = 3,
|
||||
autoFocus = false,
|
||||
}: {
|
||||
@@ -44,17 +48,19 @@ export function Composer({
|
||||
initial?: string;
|
||||
submitLabel?: string;
|
||||
busy: boolean;
|
||||
onSubmit: (text: string) => Promise<boolean>;
|
||||
onSubmit: (text: string, photos: string[]) => Promise<boolean>;
|
||||
onCancel?: () => void;
|
||||
onTyping?: () => void;
|
||||
onChange?: (text: string) => void;
|
||||
mentions?: boolean;
|
||||
photos?: boolean;
|
||||
rows?: number;
|
||||
autoFocus?: boolean;
|
||||
}) {
|
||||
const [text, setText] = useState(initial);
|
||||
const [suggest, setSuggest] = useState<{ query: string; start: number; members: ForumAuthor[] } | null>(null);
|
||||
const area = useRef<HTMLTextAreaElement>(null);
|
||||
const picked = usePhotoUploads();
|
||||
const timer = useRef<number | undefined>(undefined);
|
||||
|
||||
useEffect(() => () => window.clearTimeout(timer.current), []);
|
||||
@@ -92,11 +98,12 @@ export function Composer({
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!text.trim() || busy) return;
|
||||
if (!text.trim() || busy || picked.busy) return;
|
||||
const final = convertEmoticons(text, text.length, true).text;
|
||||
if (await onSubmit(final)) {
|
||||
if (await onSubmit(final, picked.ids)) {
|
||||
setText("");
|
||||
setSuggest(null);
|
||||
picked.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +155,14 @@ export function Composer({
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{photos && <PickedPhotos items={picked.items} onRemove={picked.remove} />}
|
||||
{photos && picked.error && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{picked.error}
|
||||
</p>
|
||||
)}
|
||||
<div className="fc-actions">
|
||||
{photos && <PhotoButton onFiles={(files) => void picked.add(files)} disabled={picked.full} />}
|
||||
<span className="fc-spacer" />
|
||||
{onCancel && (
|
||||
<button type="button" className="btn btn-ghost btn-sm" onClick={onCancel}>
|
||||
@@ -158,7 +172,7 @@ export function Composer({
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary btn-sm"
|
||||
disabled={busy || !text.trim()}
|
||||
disabled={busy || picked.busy || !text.trim()}
|
||||
onClick={() => void submit()}
|
||||
>
|
||||
{busy ? "Küldés…" : submitLabel}
|
||||
|
||||
Reference in New Issue
Block a user