From 52d245de964e64a8984b789b69f94d4d0ea6baba Mon Sep 17 00:00:00 2001 From: PanteraPolnocy Date: Thu, 4 Sep 2025 16:46:03 +0200 Subject: [PATCH] Move restoreOpenIMs() from onOpen() to the very end of viewer's startup - This ensures restored sessions are available immediately after the viewer boots, instead of only being added when the Conversations floater is opened. - It also prevents issues where sessions fail to populate properly if the Conversations floater remains closed at startup and the user starts an IM directly from a profile or the People panel. - Only resident-to-resident conversations are restored. Group chat sessions were not always ready in time ("unverified") during startup, making their restoration unreliable. - Clean up some debug code / leftovers. --- indra/newview/fsfloaterimcontainer.cpp | 60 ++----------------- indra/newview/llstartup.cpp | 8 +++ .../default/xui/en/panel_preferences_chat.xml | 2 +- .../default/xui/pl/panel_preferences_chat.xml | 2 +- 4 files changed, 14 insertions(+), 58 deletions(-) diff --git a/indra/newview/fsfloaterimcontainer.cpp b/indra/newview/fsfloaterimcontainer.cpp index 013cc5706f..2ad367287e 100644 --- a/indra/newview/fsfloaterimcontainer.cpp +++ b/indra/newview/fsfloaterimcontainer.cpp @@ -167,7 +167,6 @@ void FSFloaterIMContainer::onOpen(const LLSD& key) { LLMultiFloater::onOpen(key); initTabs(); - restoreOpenIMs(); // Restore open IMs from previous session LLFloater* active_floater = getActiveFloater(); if (active_floater && !active_floater->hasFocus()) { @@ -627,16 +626,13 @@ void FSFloaterIMContainer::startFlashingTab(LLFloater* floater, const std::strin // Restore open IMs from previous session void FSFloaterIMContainer::saveOpenIMs() { - static LLCachedControl fsRestoreOpenIMs(gSavedSettings, "FSRestoreOpenIMs"); - if (!fsRestoreOpenIMs) + if (!gSavedSettings.getBOOL("FSRestoreOpenIMs")) { + gSavedPerAccountSettings.setLLSD("FSLastOpenIMs", LLSD::emptyArray()); return; } LLSD openIMs = LLSD::emptyArray(); - S32 saved_count = 0; - - // Save all open IM sessions (excluding contacts and nearby chat) for (S32 i = 0; i < mTabContainer->getTabCount(); ++i) { FSFloaterIM* floater = dynamic_cast(mTabContainer->getPanelByIndex(i)); @@ -645,102 +641,54 @@ void FSFloaterIMContainer::saveOpenIMs() LLUUID session_id = floater->getKey(); if (session_id.notNull()) { - // Get the session info to save participant details LLIMModel::LLIMSession* session = LLIMModel::getInstance()->findIMSession(session_id); - if (session) + if (session && session->mSessionType == LLIMModel::LLIMSession::P2P_SESSION) { LLSD session_data = LLSD::emptyMap(); - session_data["session_type"] = (S32)session->mSessionType; session_data["other_participant_id"] = session->mOtherParticipantID; session_data["session_name"] = session->mName; - - // For group sessions, also save the group ID - if (session->isGroupSessionType()) - { - session_data["group_id"] = session->mOtherParticipantID; - } - openIMs.append(session_data); - ++saved_count; } } } } gSavedPerAccountSettings.setLLSD("FSLastOpenIMs", openIMs); - LL_DEBUGS("FSFloaterIMContainer") << "Saved " << saved_count << " open IM sessions for restoration" << LL_ENDL; } void FSFloaterIMContainer::restoreOpenIMs() { - static LLCachedControl fsRestoreOpenIMs(gSavedSettings, "FSRestoreOpenIMs"); - if (!fsRestoreOpenIMs) - { - return; - } - LLSD openIMs = gSavedPerAccountSettings.getLLSD("FSLastOpenIMs"); if (!openIMs.isArray() || openIMs.size() == 0) { return; } - S32 restored_count = 0; - - // Restore each saved IM session by creating new sessions with the saved participants for (LLSD::array_const_iterator it = openIMs.beginArray(); it != openIMs.endArray(); ++it) { LLSD session_data = *it; if (session_data.isMap()) { LLUUID other_participant_id = session_data["other_participant_id"].asUUID(); - S32 session_type = session_data["session_type"].asInteger(); std::string session_name = session_data["session_name"].asString(); - if (other_participant_id.notNull()) { LLUUID new_session_id; - - // Create a new session based on the saved type - if (session_type == LLIMModel::LLIMSession::P2P_SESSION) - { - // For P2P sessions, start a new IM with the other participant - new_session_id = LLIMMgr::getInstance()->addSession(session_name, IM_NOTHING_SPECIAL, other_participant_id); - } - else if (session_type == LLIMModel::LLIMSession::GROUP_SESSION) - { - // For group sessions, start a new group IM - new_session_id = LLIMMgr::getInstance()->addSession(session_name, IM_SESSION_GROUP_START, other_participant_id); - } - else if (session_type == LLIMModel::LLIMSession::ADHOC_SESSION) - { - // For ad-hoc sessions, we'd need to restore the participant list - // For now, skip these as they're more complex - continue; - } - + new_session_id = LLIMMgr::getInstance()->addSession(session_name, IM_NOTHING_SPECIAL, other_participant_id); if (new_session_id.notNull()) { - // Create and show the IM floater FSFloaterIM* im_floater = FSFloaterIM::show(new_session_id); if (im_floater) { - // Add to container if not already there if (im_floater->getHost() != this) { addFloater(im_floater, false); } - ++restored_count; } } } } } - - LL_DEBUGS("FSFloaterIMContainer") << "Restored " << restored_count << " IM sessions" << LL_ENDL; - - // Clear the saved list after restoration - gSavedPerAccountSettings.setLLSD("FSLastOpenIMs", LLSD::emptyArray()); } // diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index b8cb56a923..6e0bb1d39d 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -3385,6 +3385,14 @@ bool idle_startup() } // + // Restore open IMs from previous session + if (gSavedSettings.getBOOL("FSRestoreOpenIMs")) + { + FSFloaterIMContainer* floater_imcontainer = FSFloaterIMContainer::getInstance(); + floater_imcontainer->restoreOpenIMs(); + } + // + return true; } diff --git a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml index e4c5770d19..27137d2c16 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml @@ -1153,7 +1153,7 @@ height="18" name="FSRestoreOpenIMs" control_name="FSRestoreOpenIMs" - label="Restore open IM windows from previous session"/> + label="Restore conversations with residents from previous session"/> - + [https://accounts.secondlife.com/change_email Pokaż opcje powiadomień e-mail dla IM-ów offline]