Skip to content

Commit

Permalink
chore: Allow undefined property values
Browse files Browse the repository at this point in the history
This is testing that we can store data in Repliache that has an object
with undefined values.

Without the package.json changes, updating the status of an issue fails.
  • Loading branch information
arv committed Jan 10, 2024
1 parent 2e6bc65 commit 8a542da
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 50 deletions.
70 changes: 28 additions & 42 deletions frontend/app.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
import React, { memo, useCallback, useEffect, useReducer } from "react";
import type { UndoManager } from "@rocicorp/undo";
import classnames from "classnames";
import { generateKeyBetween } from "fractional-indexing";
import { isEqual, minBy, partial, pickBy, sortBy, sortedIndexBy } from "lodash";
import { useQueryState } from "next-usequerystate";
import { memo, useCallback, useEffect, useReducer, useState } from "react";
import { HotKeys } from "react-hotkeys";
import type {
ExperimentalDiff as Diff,
ReadonlyJSONValue,
ReadTransaction,
ReadonlyJSONValue,
Replicache,
} from "replicache";
import LeftMenu from "./left-menu";
import type { M } from "./mutators";
import { useSubscribe } from "replicache-react";
import { getPartialSyncState } from "./control";
import {
Issue,
issueFromKeyAndValue,
Comment,
Description,
ISSUE_KEY_PREFIX,
Issue,
IssueUpdate,
IssueUpdateWithID,
Order,
orderEnumSchema,
Priority,
priorityEnumSchema,
Status,
statusEnumSchema,
Description,
Comment,
IssueUpdate,
issueFromKeyAndValue,
orderEnumSchema,
priorityEnumSchema,
priorityOrderValues,
reverseTimestampSortKey,
statusEnumSchema,
statusOrderValues,
priorityOrderValues,
IssueUpdateWithID,
} from "./issue";
import { useState } from "react";
import TopFilter from "./top-filter";
import IssueList from "./issue-list";
import { useQueryState } from "next-usequerystate";
import IssueBoard from "./issue-board";
import { isEqual, minBy, partial, pickBy, sortBy, sortedIndexBy } from "lodash";
import IssueDetail from "./issue-detail";
import { generateKeyBetween } from "fractional-indexing";
import { useSubscribe } from "replicache-react";
import classnames from "classnames";
import { getPartialSyncState } from "./control";
import type { UndoManager } from "@rocicorp/undo";
import { HotKeys } from "react-hotkeys";
import IssueList from "./issue-list";
import LeftMenu from "./left-menu";
import type { M } from "./mutators";
import TopFilter from "./top-filter";

class Filters {
private readonly _viewStatuses: Set<Status> | undefined;
Expand Down Expand Up @@ -438,35 +437,22 @@ const App = ({ rep, undoManager }: AppProps) => {
issueUpdate.issue,
(_, key) => key in issueUpdate.issueChanges
);
const rv: IssueUpdateWithID = {
return {
id: issueUpdate.issue.id,
issueChanges: undoChanges,
descriptionChange: issueUpdate.descriptionUpdate?.description,
};
const { descriptionUpdate } = issueUpdate;
if (descriptionUpdate) {
return {
...rv,
descriptionChange: descriptionUpdate.description,
};
}
return rv;
}
);
await undoManager.add({
execute: () =>
rep.mutate.updateIssues(
issueUpdates.map(({ issue, issueChanges, descriptionUpdate }) => {
const rv: IssueUpdateWithID = {
return {
id: issue.id,
issueChanges,
descriptionChange: descriptionUpdate?.description,
};
if (descriptionUpdate) {
return {
...rv,
descriptionChange: descriptionUpdate.description,
};
}
return rv;
})
),
undo: () => rep.mutate.updateIssues(uChanges),
Expand Down
2 changes: 1 addition & 1 deletion frontend/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export type IssueUpdate = {
export type IssueUpdateWithID = Immutable<{
id: string;
issueChanges: Partial<IssueValue>;
descriptionChange?: Description;
descriptionChange?: Description | undefined;
}>;

export async function getIssue(
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react-remark": "^2.1.0",
"react-virtualized-auto-sizer": "^1.0.6",
"react-window": "^1.8.6",
"replicache": ">=14.0.3",
"replicache": "file:../mono/replicache-14.0.3.tgz",
"replicache-react": "5.0.1",
"zod": "^3.13.4"
},
Expand Down

0 comments on commit 8a542da

Please sign in to comment.