tips working and optimized
This commit is contained in:
+13
-12
@@ -5,7 +5,7 @@ import { EmbedAuthWrapper } from './components/EmbedAuthWrapper';
|
||||
import { CriticalView } from './views/CriticalView';
|
||||
import { AuthCallback } from './components/Auth';
|
||||
import { pb } from './lib/pocketbase';
|
||||
import { initStore, setStore, store, appendAIHelpTipHistory } from './store';
|
||||
import { initStore, setStore, store, advanceAIHelpTipSectionIndex } from './store';
|
||||
import { generateAIHelpTip, hasFireworksApiKey } from './lib/ai-help';
|
||||
|
||||
// const CriticalView = lazy(() => import('./views/CriticalView').then(m => ({ default: m.CriticalView })));
|
||||
@@ -45,19 +45,23 @@ const App: Component = () => {
|
||||
|
||||
createEffect(() => {
|
||||
const userId = authUserId();
|
||||
const ready = isAuthenticated() && !!userId && isDesktop() && !store.isInitializing;
|
||||
if (!ready) return;
|
||||
if (!hasFireworksApiKey()) return;
|
||||
if (tipGeneratedForUserId() === userId) return;
|
||||
const authenticated = isAuthenticated();
|
||||
const desktop = isDesktop();
|
||||
const initializing = store.isInitializing;
|
||||
const hasApiKey = hasFireworksApiKey();
|
||||
const alreadyGeneratedForUser = tipGeneratedForUserId() === userId;
|
||||
const prefsLoadedForUser = !!userId && store.prefId === userId;
|
||||
|
||||
if (!authenticated || !userId || !desktop || initializing || !prefsLoadedForUser || !hasApiKey || alreadyGeneratedForUser) return;
|
||||
|
||||
setTipGeneratedForUserId(userId);
|
||||
const historySnapshot = untrack(() => [...store.aiHelpTipHistory]);
|
||||
const sectionIndex = untrack(() => store.aiHelpTipSectionIndex);
|
||||
void (async () => {
|
||||
try {
|
||||
const nextTip = await generateAIHelpTip(historySnapshot);
|
||||
const nextTip = await generateAIHelpTip(sectionIndex);
|
||||
if (!nextTip) return;
|
||||
setAiHelpTip(nextTip);
|
||||
await appendAIHelpTipHistory(nextTip);
|
||||
await advanceAIHelpTipSectionIndex();
|
||||
} catch (err) {
|
||||
console.warn("Tip generation skipped", err);
|
||||
}
|
||||
@@ -162,9 +166,7 @@ const App: Component = () => {
|
||||
const url = new URL(loc);
|
||||
const path = url.pathname;
|
||||
const hash = url.hash;
|
||||
const res = path.startsWith('/embed/') || hash.startsWith('#/embed/');
|
||||
console.log('[DEBUG] isEmbed check:', { res, path, hash, href: loc });
|
||||
return res;
|
||||
return path.startsWith('/embed/') || hash.startsWith('#/embed/');
|
||||
};
|
||||
|
||||
const getEmbedView = () => {
|
||||
@@ -174,7 +176,6 @@ const App: Component = () => {
|
||||
let view = null;
|
||||
if (fullPath.includes('/notes')) view = 'embed_notes';
|
||||
else if (fullPath.includes('/quick-add')) view = 'embed_quick_add';
|
||||
console.log('[DEBUG] getEmbedView detected:', view, 'Full URL context:', fullPath);
|
||||
return view;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user