Skip to content

Commit

Permalink
do not use batch route for updating document revision
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelljkotler committed Jan 10, 2024
1 parent 038cadb commit cbc27b9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
11 changes: 4 additions & 7 deletions src/api/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,15 @@ export async function changeAccess(ids, access) {
);
}

export async function changeRevisionControl(ids, revision_control) {
// Enable or disable revision control on specified documents
export async function changeRevisionControl(id, revision_control) {
// Enable or disable revision control on specified document
const { data } = await session.patch(
apiUrl(
queryBuilder(`documents/`, {
queryBuilder(`documents/${id}/`, {
expand: [DEFAULT_EXPAND, "revisions"].join(","),
}),
),
ids.map((id) => ({
id,
revision_control,
})),
{revision_control}
);
return data;
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/dialog/RevisionsDialogContainer.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { changeRevisionControlForDocuments } from "../../manager/documents";
import { changeRevisionControlForDocument } from "../../manager/documents";
import { viewer } from "../../viewer/viewer.js";
import RevisionsDialog from "./RevisionsDialog.svelte";
import emitter from "../../emit.js";
Expand All @@ -13,7 +13,7 @@
const revisions = document?.revisions;
const enabled = document?.revisionControl;
const onSave = async (enabled: boolean) => {
await changeRevisionControlForDocuments([document], enabled);
await changeRevisionControlForDocument(document, enabled);
emit.dismiss();
};
const onCancel = () => {
Expand Down
18 changes: 8 additions & 10 deletions src/manager/documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,22 +434,20 @@ export async function changeAccessForDocuments(
hideAccess();
}

export async function changeRevisionControlForDocuments(
documents,
export async function changeRevisionControlForDocument(
document,
revision_control,
) {
await wrapLoad(layout, async () => {
await changeRevisionControl(
documents.map((doc) => doc.id),
document.id,
revision_control,
);
documents.forEach((doc) => {
updateInCollection(doc, (d) => {
d.doc = {
...d.doc,
revision_control,
};
});
updateInCollection(document, (d) => {
d.doc = {
...d.doc,
revision_control,
};
});
});
hideRevisions();
Expand Down

0 comments on commit cbc27b9

Please sign in to comment.