Skip to content

Commit

Permalink
Merged branch bugfix/hail-mary into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
horia141 committed Mar 4, 2024
1 parent aced73f commit f89e36e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/webui/app/components/doc-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { isNoErrorSomeData } from "~/logic/action-result";
import type { OneOfNoteContentBlock } from "~/logic/domain/notes";
import type { BlockEditorProps } from "./infra/block-editor";
import { FieldError, GlobalError } from "./infra/errors";
import { Buffer } from 'buffer';

const BlockEditor = lazy(() =>
import("~/components/infra/block-editor.js").then((module) => ({
Expand Down Expand Up @@ -45,14 +46,15 @@ export function DocEditor({

const act = useCallback(() => {
setIsActing(true);
const base64Content = Buffer.from(JSON.stringify(noteContent), 'utf-8').toString('base64');
if (docId && noteId) {
// We already created this thing, we just need to update!
cardActionFetcher.submit(
{
docId: docId,
noteId: noteId,
name: noteName || "Untitled",
content: btoa(JSON.stringify(noteContent)),
content: base64Content,
},
{
method: "post",
Expand All @@ -64,7 +66,7 @@ export function DocEditor({
cardActionFetcher.submit(
{
name: noteName || "Untitled",
content: btoa(JSON.stringify(noteContent)),
content: base64Content,
},
{
method: "post",
Expand Down
4 changes: 3 additions & 1 deletion src/webui/app/components/entity-note-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { SomeErrorNoData } from "~/logic/action-result";
import type { OneOfNoteContentBlock } from "~/logic/domain/notes";
import type { BlockEditorProps } from "./infra/block-editor";
import { FieldError, GlobalError } from "./infra/errors";
import { Buffer } from 'buffer';

const BlockEditor = lazy(() =>
import("~/components/infra/block-editor.js").then((module) => ({
Expand Down Expand Up @@ -35,11 +36,12 @@ export function EntityNoteEditor({

const act = useCallback(() => {
setIsActing(true);
const base64Content = Buffer.from(JSON.stringify(noteContent), 'utf-8').toString('base64');
// We already created this thing, we just need to update!
cardActionFetcher.submit(
{
id: initialNote.ref_id,
content: btoa(JSON.stringify(noteContent)),
content: base64Content,
},
{
method: "post",
Expand Down
6 changes: 5 additions & 1 deletion src/webui/app/routes/workspace/core/notes/update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import {
} from "~/logic/action-result";
import { NoteContentParser } from "~/logic/domain/notes";
import { getSession } from "~/sessions";
import { Buffer } from "buffer";

const UpdateForEntityFormSchema = {
id: z.string(),
content: z.preprocess(
(value) => JSON.parse(atob(String(value))),
(value) => {
const utf8Buffer = Buffer.from(String(value), 'base64');
return JSON.parse(utf8Buffer.toString("utf-8"));
}
NoteContentParser
),
};
Expand Down
6 changes: 5 additions & 1 deletion src/webui/app/routes/workspace/docs/create-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import {
} from "~/logic/action-result";
import { NoteContentParser } from "~/logic/domain/notes";
import { getSession } from "~/sessions";
import { Buffer } from "buffer";

const CreateFormSchema = {
name: z.string(),
content: z.preprocess(
(value) => JSON.parse(atob(String(value))),
(value) => {
const utf8Buffer = Buffer.from(String(value), 'base64');
return JSON.parse(utf8Buffer.toString('utf-8'));
},
NoteContentParser
),
};
Expand Down
6 changes: 5 additions & 1 deletion src/webui/app/routes/workspace/docs/update-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ import {
} from "~/logic/action-result";
import { NoteContentParser } from "~/logic/domain/notes";
import { getSession } from "~/sessions";
import { Buffer } from "buffer";

const UpdateFormSchema = {
docId: z.string(),
noteId: z.string(),
name: z.string(),
content: z.preprocess(
(value) => JSON.parse(atob(String(value))),
(value) => {
const utf8Buffer = Buffer.from(String(value), 'base64');
return JSON.parse(utf8Buffer.toString("utf-8"));
},
NoteContentParser
),
};
Expand Down
1 change: 1 addition & 0 deletions src/webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"js-cookie": "^3.0.5",
"jupiter-gen": "^0.0.1",
"luxon": "^3.2.0",
"buffer": "^6.0.3",
"notistack": "^3.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down

0 comments on commit f89e36e

Please sign in to comment.