Skip to content

Commit

Permalink
Fix LocalModification flag not properly restored when opening a cloud…
Browse files Browse the repository at this point in the history
… project prior successfully logging into the server
  • Loading branch information
nirvn committed Oct 4, 2024
1 parent d722d80 commit 412c8d0
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/core/qfieldcloudprojectsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ QFieldCloudProjectsModel::QFieldCloudProjectsModel()
refreshProjectModification( mCurrentProjectId );
} );

connect( this, &QFieldCloudProjectsModel::modelReset, this, [=]() {
if ( mCurrentProjectId.isEmpty() || !findProject( mCurrentProjectId ) )
return;

emit currentProjectDataChanged();

refreshProjectModification( mCurrentProjectId );
} );

connect( this, &QFieldCloudProjectsModel::dataChanged, this, [=]( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles ) {
Q_UNUSED( bottomRight )
Q_UNUSED( roles )
Expand Down Expand Up @@ -338,9 +329,13 @@ bool QFieldCloudProjectsModel::canSyncProject( const QString &projectId ) const
return false;

if ( mCurrentProjectId.isEmpty() )
{
return false;
}
else if ( projectStatus( projectId ) == ProjectStatus::Idle )
{
return true;
}

return false;
}
Expand Down Expand Up @@ -1297,10 +1292,14 @@ void QFieldCloudProjectsModel::projectUpload( const QString &projectId, const bo
}

if ( !( project->modification & LocalModification ) )
{
return;
}

if ( !mLayerObserver->deltaFileWrapper()->toFile() )
{
return;
}

if ( deltaFileWrapper->hasError() )
{
Expand Down Expand Up @@ -1714,6 +1713,15 @@ void QFieldCloudProjectsModel::projectListReceived()
{
refreshProjectsList( isPublic, projectFetchOffset + mProjectsPerFetch );
}
else
{
// All projects fetched, refresh current project details if found
if ( !mCurrentProjectId.isEmpty() && findProject( mCurrentProjectId ) )
{
emit currentProjectDataChanged();
refreshProjectModification( mCurrentProjectId );
}
}
}

NetworkReply *QFieldCloudProjectsModel::downloadFile( const QString &projectId, const QString &fileName )
Expand Down

1 comment on commit 412c8d0

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.