Skip to content

Commit

Permalink
Fix attachments not uploaded immediately when hitting the synchronize…
Browse files Browse the repository at this point in the history
… button
  • Loading branch information
nirvn committed Nov 8, 2024
1 parent 7892761 commit 5f19608
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/core/qfieldcloudprojectsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ void QFieldCloudProjectsModel::projectUpload( const QString &projectId, const bo
QgsMessageLog::logMessage( QStringLiteral( "Failed to reset delta file after delta push. %1" ).arg( deltaFileWrapper->errorString() ) );

emit dataChanged( projectIndex, projectIndex, QVector<int>() << StatusRole << ModificationRole << LastLocalPushDeltasRole );
emit pushFinished( projectId, false );
emit pushFinished( projectId, false, false );
projectRefreshData( projectId, ProjectRefreshReason::DeltaUploaded );
}
} );
Expand Down Expand Up @@ -1500,12 +1500,13 @@ void QFieldCloudProjectsModel::projectUpload( const QString &projectId, const bo
// download the updated files, so the files are for sure the same on the client and on the server
if ( shouldDownloadUpdates )
{
emit pushFinished( projectId, true, false );
projectPackageAndDownload( projectId );
}
else
{
emit dataChanged( projectIndex, projectIndex, QVector<int>() << StatusRole );
emit pushFinished( projectId, false );
emit pushFinished( projectId, false, false );
projectRefreshData( projectId, ProjectRefreshReason::DeltaUploaded );
}
}
Expand Down Expand Up @@ -1649,7 +1650,7 @@ void QFieldCloudProjectsModel::projectCancelUpload( const QString &projectId )
project->errorStatus = UploadErrorStatus;

emit dataChanged( projectIndex, projectIndex, QVector<int>() << StatusRole << ErrorStatusRole );
emit pushFinished( projectId, true, project->deltaFileUploadStatusString );
emit pushFinished( projectId, false, true, project->deltaFileUploadStatusString );

return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qfieldcloudprojectsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class QFieldCloudProjectsModel : public QAbstractListModel
void networkAllAttachmentsUploaded( const QString &projectId );
void networkLayerDownloaded( const QString &projectId );
void networkAllLayersDownloaded( const QString &projectId );
void pushFinished( const QString &projectId, bool hasError, const QString &errorString = QString() );
void pushFinished( const QString &projectId, bool isDownloadingProject, bool hasError, const QString &errorString = QString() );

private slots:
void connectionStatusChanged();
Expand Down
6 changes: 4 additions & 2 deletions src/qml/qgismobileapp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3736,12 +3736,14 @@ ApplicationWindow {
return hasError ? displayToast(qsTr("Project %1 failed to download").arg(projectName), 'error') : displayToast(qsTr("Project %1 successfully downloaded, it's now available to open").arg(projectName));
}

onPushFinished: function (projectId, hasError, errorString) {
onPushFinished: function (projectId, isDownloadingProject, hasError, errorString) {
if (hasError) {
displayToast(qsTr("Changes failed to reach QFieldCloud: %1").arg(errorString), 'error');
return;
}
displayToast(qsTr("Changes successfully pushed to QFieldCloud"));
if (!isDownloadingProject) {
displayToast(qsTr("Changes successfully pushed to QFieldCloud"));
}
if (QFieldCloudUtils.hasPendingAttachments()) {
// Go ahead and upload pending attachments in the background
platformUtilities.uploadPendingAttachments(cloudConnection);
Expand Down

0 comments on commit 5f19608

Please sign in to comment.