forked from r.muellner/velum-raycast
feat: choose project or session for text commands
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { LocalStorage } from "@raycast/api";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { getPreferences } from "./preferences";
|
||||
import type { PlaceholderMapping, SessionMode, VelumSession } from "./types";
|
||||
import type { PlaceholderMapping, VelumSession } from "./types";
|
||||
|
||||
const SESSIONS_STORAGE_KEY = "velum.sessions.v1";
|
||||
const ACTIVE_SESSION_STORAGE_KEY = "velum.sessions.active.v1";
|
||||
@@ -10,10 +10,6 @@ function nowIso(): string {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
|
||||
function dayKey(date = new Date()): string {
|
||||
return date.toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
function sessionSort(a: VelumSession, b: VelumSession): number {
|
||||
return Date.parse(b.updatedAt) - Date.parse(a.updatedAt);
|
||||
}
|
||||
@@ -85,32 +81,6 @@ export async function getActiveSession(): Promise<VelumSession> {
|
||||
return createSession();
|
||||
}
|
||||
|
||||
export async function resolveSessionForMode(
|
||||
mode: SessionMode,
|
||||
): Promise<VelumSession> {
|
||||
if (mode === "new-each-request") {
|
||||
return createSession(`Anfrage ${new Date().toLocaleString()}`);
|
||||
}
|
||||
|
||||
if (mode === "daily") {
|
||||
const name = `Tag ${dayKey()}`;
|
||||
const existing = (await listSessions()).find(
|
||||
(session) => session.name === name,
|
||||
);
|
||||
if (existing) {
|
||||
await setActiveSession(existing.id);
|
||||
return existing;
|
||||
}
|
||||
return createSession(name);
|
||||
}
|
||||
|
||||
return getActiveSession();
|
||||
}
|
||||
|
||||
export async function resolveDefaultSession(): Promise<VelumSession> {
|
||||
return resolveSessionForMode(getPreferences().sessionMode);
|
||||
}
|
||||
|
||||
export async function updateSessionMapping(
|
||||
id: string,
|
||||
mapping: PlaceholderMapping,
|
||||
|
||||
Reference in New Issue
Block a user