mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
Add a function to know the user id matching a given account
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
parent
e3b97b0a04
commit
c42f4abd25
2 changed files with 16 additions and 0 deletions
|
@ -810,6 +810,20 @@ User *UserModel::currentUser() const
|
|||
return _users[currentUserId()];
|
||||
}
|
||||
|
||||
int UserModel::findUserIdForAccount(AccountState *account) const
|
||||
{
|
||||
const auto it = std::find_if(std::cbegin(_users), std::cend(_users), [=](const User *user) {
|
||||
return user->account()->id() == account->account()->id();
|
||||
});
|
||||
|
||||
if (it == std::cend(_users)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const auto id = std::distance(std::cbegin(_users), it);
|
||||
return id;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
|
||||
ImageProvider::ImageProvider()
|
||||
|
|
|
@ -107,6 +107,8 @@ public:
|
|||
|
||||
User *currentUser() const;
|
||||
|
||||
int findUserIdForAccount(AccountState *account) const;
|
||||
|
||||
Q_INVOKABLE void fetchCurrentActivityModel();
|
||||
Q_INVOKABLE void openCurrentAccountLocalFolder();
|
||||
Q_INVOKABLE void openCurrentAccountTalk();
|
||||
|
|
Loading…
Reference in a new issue