Skip to content

Commit

Permalink
Additional review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Feb 25, 2024
1 parent d495763 commit e478a00
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/deltafilewrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ void DeltaFileWrapper::appendDelta( const QJsonObject &delta )

void DeltaFileWrapper::mergeCreateDelta( const QJsonObject &delta )
{
Q_ASSERT( delta.value( QStringLiteral( "method" ) ) == "create" );

const QString localPk = delta.value( QStringLiteral( "localPk" ) ).toString();
const QString localLayerId = delta.value( QStringLiteral( "localLayerId" ) ).toString();
mLocalPkDeltaIdx[localLayerId][localPk] = static_cast<int>( mDeltas.count() );
Expand All @@ -808,6 +810,8 @@ void DeltaFileWrapper::mergeCreateDelta( const QJsonObject &delta )

void DeltaFileWrapper::mergeDeleteDelta( const QJsonObject &delta )
{
Q_ASSERT( delta.value( QStringLiteral( "method" ) ) == "delete" );

const QString localLayerId = delta.value( QStringLiteral( "localLayerId" ) ).toString();
QMap<QString, int> layerPkDeltaIdx = mLocalPkDeltaIdx.value( localLayerId );
QString localPk = delta.value( QStringLiteral( "localPk" ) ).toString();
Expand All @@ -828,6 +832,8 @@ void DeltaFileWrapper::mergeDeleteDelta( const QJsonObject &delta )

void DeltaFileWrapper::mergePatchDelta( const QJsonObject &delta )
{
Q_ASSERT( delta.value( QStringLiteral( "method" ) ) == "patch" );

QJsonObject oldData = delta.value( QStringLiteral( "old" ) ).toObject();
QJsonObject newData = delta.value( QStringLiteral( "new" ) ).toObject();

Expand Down
14 changes: 14 additions & 0 deletions src/core/deltafilewrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,22 @@ class DeltaFileWrapper : public QObject
*/
void mergeDelta( const QJsonObject &delta );


/**
* Merge the generated create \a delta into stored deltas. Should only be called from `mergeDelta` method.
*/
void mergeCreateDelta( const QJsonObject &delta );


/**
* Merge the generated delete \a delta into stored deltas. Should only be called from `mergeDelta` method.
*/
void mergeDeleteDelta( const QJsonObject &delta );


/**
* Merge the generated patch \a delta into stored deltas. Should only be called from `mergeDelta` method.
*/
void mergePatchDelta( const QJsonObject &delta );


Expand Down

0 comments on commit e478a00

Please sign in to comment.