feat: close #1072 share mask as link

This commit is contained in:
Yidadaa
2023-07-05 23:19:54 +08:00
parent 1197521921
commit 5c8be2a8f6
5 changed files with 52 additions and 17 deletions

View File

@@ -15,6 +15,7 @@ import { useAppConfig, useChatStore } from "../store";
import { MaskAvatar } from "./mask";
import { useCommand } from "../command";
import { showConfirm } from "./ui-lib";
import { BUILTIN_MASK_STORE } from "../masks";
function getIntersectionArea(aRect: DOMRect, bRect: DOMRect) {
const xmin = Math.max(aRect.x, bRect.x);
@@ -93,14 +94,17 @@ export function NewChat() {
const { state } = useLocation();
const startChat = (mask?: Mask) => {
chatStore.newSession(mask);
setTimeout(() => navigate(Path.Chat), 1);
setTimeout(() => {
chatStore.newSession(mask);
navigate(Path.Chat);
}, 10);
};
useCommand({
mask: (id) => {
try {
const mask = maskStore.get(parseInt(id));
const intId = parseInt(id);
const mask = maskStore.get(intId) ?? BUILTIN_MASK_STORE.get(intId);
startChat(mask ?? undefined);
} catch {
console.error("[New Chat] failed to create chat from mask id=", id);