Skip to content

Commit

Permalink
fix: logout failed (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serein207 committed Aug 1, 2024
1 parent 1705c99 commit 65efdfd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ endif()

find_package(Qt6 6.5 REQUIRED COMPONENTS Quick Multimedia)

add_subdirectory(libs/mbedtls)

qt_standard_project_setup(REQUIRES 6.5)

set(CMAKE_AUTORCC ON)
Expand All @@ -27,8 +29,8 @@ set(FLUENTUI_BUILD_EXAMPLES OFF)
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND LINUX)
set(FLUENTUI_QML_PLUGIN_DIRECTORY /usr/lib/qt6/qml/FluentUI)
endif()

add_subdirectory(libs/FluentUI)
add_subdirectory(libs/mbedtls)

file(GLOB_RECURSE SOURCE_FILES
${CMAKE_SOURCE_DIR}/src/*.cpp
Expand Down
1 change: 0 additions & 1 deletion src/ViewModel/LoginViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ void LoginViewModel::logout() {
emit logoutFailed(result.unwrapErr().message);
return;
}
auto entity = result.unwrap();
emit logoutSuccess();
});
}
Expand Down
9 changes: 8 additions & 1 deletion src/ViewModel/UserProfileViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ using namespace NeteaseCloudMusic;
UserProfileViewModel::UserProfileViewModel(QObject* parent) : QObject(parent) {
isLogin = !(SettingsUtils::getInstance()->value("Cookies").isNull() &&
SettingsUtils::getInstance()->value("Cookies").toByteArray().isEmpty());
connect(this, &UserProfileViewModel::isLoginChanged, this, [this]() {
if (!isLogin) {
setUserProfileModel(UserProfile());
emit loadUserProfileSuccess();
}
});
}

UserProfileViewModel* UserProfileViewModel::create(QQmlEngine*, QJSEngine*) {
Expand All @@ -24,6 +30,7 @@ void UserProfileViewModel::loadUserProfile() {
auto entity = result.unwrap();
if (!entity.account.has_value() || entity.account.value().anonimousUser) {
setIsLogin(false);
return;
} else {
setIsLogin(true);
}
Expand Down Expand Up @@ -59,7 +66,7 @@ bool UserProfileViewModel::getDefaultAvatar() const {
return userProfileModel.defaultAvatar;
}

void UserProfileViewModel::setUserProfileModel(const UserProfile& model) {
void UserProfileViewModel::setUserProfileModel(UserProfile model) {
userProfileModel = std::move(model);
emit userIdChanged();
emit nicknameChanged();
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModel/UserProfileViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UserProfileViewModel : public QObject {

bool getDefaultAvatar() const;

void setUserProfileModel(const UserProfile& model);
void setUserProfileModel(UserProfile model);

signals:
void isLoginChanged();
Expand Down

0 comments on commit 65efdfd

Please sign in to comment.