Address valid Greptile portability follow-ups
This commit is contained in:
parent
92c29f27c3
commit
87b3cacc8f
3 changed files with 15 additions and 12 deletions
|
|
@ -13,7 +13,7 @@ import type {
|
||||||
} from "@paperclipai/shared";
|
} from "@paperclipai/shared";
|
||||||
import { ApiRequestError } from "../../client/http.js";
|
import { ApiRequestError } from "../../client/http.js";
|
||||||
import { openUrl } from "../../client/board-auth.js";
|
import { openUrl } from "../../client/board-auth.js";
|
||||||
import { readZipArchive } from "./zip.js";
|
import { binaryContentTypeByExtension, readZipArchive } from "./zip.js";
|
||||||
import {
|
import {
|
||||||
addCommonClientOptions,
|
addCommonClientOptions,
|
||||||
formatInlineRecord,
|
formatInlineRecord,
|
||||||
|
|
@ -109,15 +109,6 @@ type ImportSelectionState = {
|
||||||
skills: Set<string>;
|
skills: Set<string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const binaryContentTypeByExtension: Record<string, string> = {
|
|
||||||
".gif": "image/gif",
|
|
||||||
".jpeg": "image/jpeg",
|
|
||||||
".jpg": "image/jpeg",
|
|
||||||
".png": "image/png",
|
|
||||||
".svg": "image/svg+xml",
|
|
||||||
".webp": "image/webp",
|
|
||||||
};
|
|
||||||
|
|
||||||
function readPortableFileEntry(filePath: string, contents: Buffer): CompanyPortabilityFileEntry {
|
function readPortableFileEntry(filePath: string, contents: Buffer): CompanyPortabilityFileEntry {
|
||||||
const contentType = binaryContentTypeByExtension[path.extname(filePath).toLowerCase()];
|
const contentType = binaryContentTypeByExtension[path.extname(filePath).toLowerCase()];
|
||||||
if (!contentType) return contents.toString("utf8");
|
if (!contentType) return contents.toString("utf8");
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import type { CompanyPortabilityFileEntry } from "@paperclipai/shared";
|
||||||
|
|
||||||
const textDecoder = new TextDecoder();
|
const textDecoder = new TextDecoder();
|
||||||
|
|
||||||
const binaryContentTypeByExtension: Record<string, string> = {
|
export const binaryContentTypeByExtension: Record<string, string> = {
|
||||||
".gif": "image/gif",
|
".gif": "image/gif",
|
||||||
".jpeg": "image/jpeg",
|
".jpeg": "image/jpeg",
|
||||||
".jpg": "image/jpeg",
|
".jpg": "image/jpeg",
|
||||||
|
|
|
||||||
|
|
@ -356,6 +356,7 @@ function applyImportedSidebarOrder(
|
||||||
) {
|
) {
|
||||||
const sidebar = preview?.manifest.sidebar;
|
const sidebar = preview?.manifest.sidebar;
|
||||||
if (!sidebar) return;
|
if (!sidebar) return;
|
||||||
|
if (!userId?.trim()) return;
|
||||||
|
|
||||||
const agentIdBySlug = new Map(
|
const agentIdBySlug = new Map(
|
||||||
result.agents
|
result.agents
|
||||||
|
|
@ -846,7 +847,18 @@ export function CompanyImport() {
|
||||||
onSuccess: async (result) => {
|
onSuccess: async (result) => {
|
||||||
await queryClient.invalidateQueries({ queryKey: queryKeys.companies.all });
|
await queryClient.invalidateQueries({ queryKey: queryKeys.companies.all });
|
||||||
const importedCompany = await companiesApi.get(result.company.id);
|
const importedCompany = await companiesApi.get(result.company.id);
|
||||||
applyImportedSidebarOrder(importPreview, result, currentUserId);
|
const refreshedSession = currentUserId
|
||||||
|
? null
|
||||||
|
: await queryClient.fetchQuery({
|
||||||
|
queryKey: queryKeys.auth.session,
|
||||||
|
queryFn: () => authApi.getSession(),
|
||||||
|
});
|
||||||
|
const sidebarOrderUserId =
|
||||||
|
currentUserId
|
||||||
|
?? refreshedSession?.user?.id
|
||||||
|
?? refreshedSession?.session?.userId
|
||||||
|
?? null;
|
||||||
|
applyImportedSidebarOrder(importPreview, result, sidebarOrderUserId);
|
||||||
setSelectedCompanyId(importedCompany.id);
|
setSelectedCompanyId(importedCompany.id);
|
||||||
pushToast({
|
pushToast({
|
||||||
tone: "success",
|
tone: "success",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue