diff --git a/app/src/components/home/assemblies/ChatInput.tsx b/app/src/components/home/assemblies/ChatInput.tsx index 27a393d2..c71e8805 100644 --- a/app/src/components/home/assemblies/ChatInput.tsx +++ b/app/src/components/home/assemblies/ChatInput.tsx @@ -40,12 +40,36 @@ function ChatInput({ placeholder={sender ? t("chat.placeholder-enter") : t("chat.placeholder")} onKeyDown={async (e) => { if (e.key === "Enter") { - if (sender || e.ctrlKey) { - // condition sender: Ctrl + Enter if false, Enter if true - // condition e.ctrlKey: Ctrl + Enter if true, Enter if false + if (sender) { + // on Enter, clear the input + // on Ctrl + Enter, keep the input - e.preventDefault(); - onEnterPressed(); + if (!e.ctrlKey) { + e.preventDefault(); + onEnterPressed(); + } else { + // add Enter to the input + e.preventDefault(); + + if (!target || !target.current) return; + const input = target.current as HTMLTextAreaElement; + const value = input.value; + const selectionStart = input.selectionStart; + const selectionEnd = input.selectionEnd; + input.value = + value.slice(0, selectionStart) + + "\n" + + value.slice(selectionEnd); + input.selectionStart = input.selectionEnd = selectionStart + 1; + onValueChange(input.value); + } + } else { + // on Enter, keep the input + // on Ctrl + Enter, clear the input + if (e.ctrlKey) { + e.preventDefault(); + onEnterPressed(); + } } } }} diff --git a/app/src/conf/env.ts b/app/src/conf/env.ts index ff239826..c287a303 100644 --- a/app/src/conf/env.ts +++ b/app/src/conf/env.ts @@ -115,7 +115,7 @@ export function setAnnouncement(announcement: string): void { * set the announcement in localStorage */ if (!announcement || announcement.trim() === "") return; - + const firstReceived = getMemory("announcement") !== announcement; setMemory("announcement", announcement); diff --git a/app/src/dialogs/ApikeyDialog.tsx b/app/src/dialogs/ApikeyDialog.tsx index 5dbb75a8..5081086f 100644 --- a/app/src/dialogs/ApikeyDialog.tsx +++ b/app/src/dialogs/ApikeyDialog.tsx @@ -2,7 +2,6 @@ import { Dialog, DialogContent, DialogDescription, - DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog.tsx"; @@ -11,7 +10,6 @@ import "@/assets/pages/api.less"; import { useTranslation } from "react-i18next"; import { useDispatch, useSelector } from "react-redux"; import { - closeDialog, dialogSelector, setDialog, keySelector, @@ -133,11 +131,6 @@ function ApikeyDialog() { </div> </DialogDescription> </DialogHeader> - <DialogFooter> - <Button variant={`outline`} onClick={() => dispatch(closeDialog())}> - {t("close")} - </Button> - </DialogFooter> </DialogContent> </Dialog> ); diff --git a/app/src/routes/Sharing.tsx b/app/src/routes/Sharing.tsx index 2d469d2f..3f800a39 100644 --- a/app/src/routes/Sharing.tsx +++ b/app/src/routes/Sharing.tsx @@ -183,7 +183,12 @@ function Sharing() { }, []); return ( - <div className={cn(`sharing-page`, loading && "flex flex-row items-center justify-center")}> + <div + className={cn( + `sharing-page`, + loading && "flex flex-row items-center justify-center", + )} + > {loading ? ( <div className={`animate-spin select-none`}> <Loader2 className={`loader w-12 h-12`} /> diff --git a/auth/subscription.go b/auth/subscription.go index 5409c9b6..cc5ec638 100644 --- a/auth/subscription.go +++ b/auth/subscription.go @@ -26,7 +26,12 @@ func (u *User) GetSubscription(db *sql.DB) (time.Time, int) { return time.Unix(0, 0), 0 } - u.Subscription = utils.ConvertTime(expiredAt) + t := utils.ConvertTime(expiredAt) + if t == nil { + t = utils.ToPtr(time.Unix(0, 0)) + } + + u.Subscription = t return *u.Subscription, u.Level }