This commit is contained in:
Enrico Ros
2023-12-12 18:24:59 -08:00
parent 30c17a9b73
commit 084d77cd78
5 changed files with 18 additions and 11 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ export function AppNews() {
{!!news && <Container disableGutters maxWidth='sm'>
{news?.map((ni, idx) => {
const firstCard = idx === 0;
// const firstCard = idx === 0;
const hasCardAfter = news.length < NewsItems.length;
const showExpander = hasCardAfter && (idx === news.length - 1);
const addPadding = false; //!firstCard; // || showExpander;
+3 -4
View File
@@ -1,14 +1,13 @@
import * as React from 'react';
import { shallow } from 'zustand/shallow';
import { useRouter } from 'next/router';
import { navigateToNews } from '~/common/app.routes';
import { useAppStateStore } from '~/common/state/store-appstate';
import { incrementalVersion } from './news.data';
export function useShowNewsOnUpdate() {
const { push: routerPush } = useRouter();
const { usageCount, lastSeenNewsVersion } = useAppStateStore(state => ({
usageCount: state.usageCount,
lastSeenNewsVersion: state.lastSeenNewsVersion,
@@ -17,9 +16,9 @@ export function useShowNewsOnUpdate() {
const isNewsOutdated = (lastSeenNewsVersion || 0) < incrementalVersion;
if (isNewsOutdated && usageCount > 2) {
// Disable for now
void routerPush('/news');
void navigateToNews();
}
}, [lastSeenNewsVersion, routerPush, usageCount]);
}, [lastSeenNewsVersion, usageCount]);
}
export function useMarkNewsAsSeen() {
+11 -3
View File
@@ -15,7 +15,7 @@ export const ROUTE_APP_LINK_CHAT = '/link/chat/:linkId';
export const ROUTE_APP_NEWS = '/news';
const ROUTE_CALLBACK_OPENROUTER = '/link/callback_openrouter';
export const getIndexLink = () => ROUTE_INDEX;
// Get Paths
export const getCallbackUrl = (source: 'openrouter') => {
const callbackUrl = new URL(window.location.href);
@@ -31,10 +31,11 @@ export const getCallbackUrl = (source: 'openrouter') => {
export const getChatLinkRelativePath = (chatLinkId: string) => ROUTE_APP_LINK_CHAT.replace(':linkId', chatLinkId);
const navigateFn = (path: string) => (replace?: boolean): Promise<boolean> =>
Router[replace ? 'replace' : 'push'](path);
/// Simple Navigation
export const navigateToIndex = navigateFn(ROUTE_INDEX);
export const navigateToChat = async (conversationId?: DConversationId) => {
if (conversationId) {
await Router.push(
@@ -54,6 +55,13 @@ export const navigateToNews = navigateFn(ROUTE_APP_NEWS);
export const navigateBack = Router.back;
function navigateFn(path: string) {
return (replace?: boolean): Promise<boolean> => Router[replace ? 'replace' : 'push'](path);
}
/// Launch Apps
export interface AppCallQueryParams {
conversationId: string;
personaId: string;
+1 -1
View File
@@ -42,7 +42,7 @@ export const backendRouter = createTRPCRouter({
/* Exchange the OpenrRouter 'code' (from PKCS) for an OpenRouter API Key */
exchangeOpenRouterKey: publicProcedure
.input(z.object({ code: z.string() }))
.query(async ({ ctx, input }) => {
.query(async ({ input }) => {
// Documented here: https://openrouter.ai/docs#oauth
return await fetchJsonOrTRPCError<{ key: string }, { code: string }>('https://openrouter.ai/api/v1/auth/keys', 'POST', {}, {
code: input.code,
+2 -2
View File
@@ -18,7 +18,7 @@ const MISTRAL_REG_LINK = 'https://console.mistral.ai/';
export function MistralSourceSetup(props: { sourceId: DModelSourceId }) {
// external state
const { source, sourceSetupValid, sourceHasLLMs, access, updateSetup } =
const { source, sourceSetupValid, access, updateSetup } =
useSourceSetup(props.sourceId, ModelVendorMistral);
// derived state
@@ -30,7 +30,7 @@ export function MistralSourceSetup(props: { sourceId: DModelSourceId }) {
// fetch models
const { isFetching, refetch, isError, error } = apiQuery.llmOpenAI.listModels.useQuery({ access }, {
enabled: false,
enabled: shallFetchSucceed,
onSuccess: models => source && useModelsStore.getState().setLLMs(
models.models.map(model => modelDescriptionToDLLM(model, source)),
props.sourceId,