Skip to content

Commit

Permalink
ensuring user role is cached/updated each time we open a project
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Dec 10, 2024
1 parent eabfc85 commit 6596705
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 7 additions & 3 deletions app/activeproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ bool ActiveProject::load( const QString &filePath )

bool ActiveProject::forceLoad( const QString &filePath, bool force )
{
// update user's role each time a project is opened, following #3174
mMerginApi->updateProjectMetadataRole( projectFullName() );

CoreUtils::log( QStringLiteral( "Project loading" ), filePath + " " + ( force ? "true" : "false" ) );

// clear autosync
Expand Down Expand Up @@ -204,6 +201,7 @@ bool ActiveProject::forceLoad( const QString &filePath, bool force )
updateRecordingLayers();
updateActiveLayer();
updateMapSettingsLayers();
updateUserRoleInActiveProject();

emit localProjectChanged( mLocalProject );
emit projectReloaded( mQgsProject );
Expand Down Expand Up @@ -588,3 +586,9 @@ void ActiveProject::setProjectRole( const QString &role )
emit projectRoleChanged();
}
}

void ActiveProject::updateUserRoleInActiveProject()
{
// update user's role each time a project is opened, following #3174
mMerginApi->updateProjectMetadataRole( projectFullName() );
}
5 changes: 5 additions & 0 deletions app/activeproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ class ActiveProject: public QObject

void setProjectRole( const QString &role );

/**
* Calls Mergin API to update current project’s role
*/
void updateUserRoleInActiveProject();

signals:
void qgsProjectChanged();
void localProjectChanged( LocalProject project );
Expand Down
4 changes: 2 additions & 2 deletions app/qml/project/MMProjectController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ Item {
function setupProjectOpen( projectPath ) {
if ( projectPath === __activeProject.localProject.qgisProjectFilePath )
{
// update user's role in project ( in case user has changed )
__activeProject.updateUserRoleInActiveProject()
// just hide the panel - project already loaded
hidePanel()
// update user's role in project ( in case user has changed )
__merginApi.updateProjectMetadataRole( __activeProject.projectFullName() )
}
else
{
Expand Down

0 comments on commit 6596705

Please sign in to comment.