Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions codex-vscode/src/helpers/notifications.helper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import * as vscode from "vscode";

import { Notification } from "@usecodex/common-library";
import { Context, Notification } from "@usecodex/common-library";
import { CodexService } from "../services/codex.service";
import { UserService } from "../services/user.service";
import { getNotificationDetails } from "./format.helper";
import { openContext } from "./goto.helper";
import { updateStatusBar } from "./misc.helper";
import { UserService } from "../services/user.service";
import { SidebarService } from "../services/sidebar.service";
import { MESSAGE_TYPES } from "../globals";

const OPEN = "Open";
const OK = "Ok";

async function handleStatusBarUpdate(): Promise<vscode.Disposable> {
const notifications = await UserService.getInstance().getNotifications();
Expand All @@ -25,9 +32,26 @@ function formatStatusBarMessage(notifications: Array<Notification>) {
}

function displayInformationMessage(notification: Notification) {
const acknowledgement = ["Ok"];
const contextId = notification.codexNotificationObject?.contextId;
const action = contextId ? OPEN : OK;
const acknowledgement = [action];
const description = getNotificationDetails(notification).title;
description && vscode.window.showInformationMessage(description, ...acknowledgement);
description &&
vscode.window.showInformationMessage(description, ...acknowledgement).then(async (selection) => {
if (selection == OPEN) {
await vscode.commands.executeCommand("workbench.view.extension.codex-sidebar-view");
try {
const codexService = new CodexService(
notification.codexNotificationObject.codexId,
UserService.getInstance()
);
const context: Context = ((await codexService.getContextService().getOneById(contextId)) as Context[])[0];
openContext(context);
} catch {
SidebarService.getInstance().postMessage(MESSAGE_TYPES.notFound, { message: "Context is not found." });
}
}
});
}

export { handleStatusBarUpdate, handleSetStatusBarMessage, formatStatusBarMessage, displayInformationMessage };
7 changes: 3 additions & 4 deletions codex-webview/src/views/pages/ContextItemPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
$: contextId = parseInt($params.contextId);
$: context = $contextStore.contexts.get(contextId);

defaultCodicesStore.subscribe((defaultCodices: Codex[]) => {
codex = defaultCodices.find((codex) => context?.codexId === codex.id);
});

onMount(() => {
// TODO: Fetch context data here - COD-982
defaultCodicesStore.subscribe((defaultCodices: Codex[]) => {
codex = defaultCodices.find((codex) => context?.codexId === codex.id);
});
});

</script>
Expand Down