Skip to content

Commit

Permalink
feat: pushUpdates revision fix
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldas committed Feb 13, 2024
1 parent 5c1561f commit ad717c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"body-parser": "^1.20.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"document-drive": "0.0.28",
"document-model": "1.0.29",
"document-drive": "^0.0.29",
"document-model": "^1.0.29",
"document-model-libs": "1.1.43",
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
Expand Down
13 changes: 10 additions & 3 deletions api/src/modules/document-drive/drive-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {
} from 'document-drive';
import { OperationScope } from 'document-model/document';
import stringify from 'json-stringify-deterministic';
import { getChildLogger } from '../../logger';

const logger = getChildLogger({ msgPrefix: 'Drive' });

export const Node = objectType({
name: 'Node',
Expand Down Expand Up @@ -199,7 +202,7 @@ export const syncType = objectType({
})),
}));
} catch (e) {
console.error(e)
logger.error(e);
throw new Error('Failed to fetch strands');
}
},
Expand Down Expand Up @@ -290,13 +293,16 @@ export const pushUpdates = mutationField('pushUpdates', {
s.documentId ?? undefined,
);

if (result.status !== "SUCCESS") logger.error(result.error);

const revision = result.document.operations[s.scope].slice().pop()?.index ?? -1;
return {
revision,
branch: s.branch,
documentId: s.documentId ?? '',
driveId: s.driveId,
revision: result.operations.pop()?.index ?? -1,
scope: s.scope as OperationScope,
status: (result.success ? "SUCCESS" : "ERROR") as IUpdateStatus,
status: result.status,
};
}));

Expand Down Expand Up @@ -332,6 +338,7 @@ export const acknowledge = mutationField('acknowledge', {

return result;
} catch (e) {
logger.error(e)
return false;
}
},
Expand Down

0 comments on commit ad717c4

Please sign in to comment.