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.
master
PanteraPolnocy 2025-09-04 16:46:03 +02:00
parent dc0d75039b
commit 52d245de96
4 changed files with 14 additions and 58 deletions

View File

@ -167,7 +167,6 @@ void FSFloaterIMContainer::onOpen(const LLSD& key)
{
LLMultiFloater::onOpen(key);
initTabs();
restoreOpenIMs(); // <FS:PP> 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
// <FS:PP> Restore open IMs from previous session
void FSFloaterIMContainer::saveOpenIMs()
{
static LLCachedControl<bool> 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<FSFloaterIM*>(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<bool> 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());
}
// </FS:PP>

View File

@ -3385,6 +3385,14 @@ bool idle_startup()
}
// </FS:PP>
// <FS:PP> Restore open IMs from previous session
if (gSavedSettings.getBOOL("FSRestoreOpenIMs"))
{
FSFloaterIMContainer* floater_imcontainer = FSFloaterIMContainer::getInstance();
floater_imcontainer->restoreOpenIMs();
}
// </FS:PP>
return true;
}

View File

@ -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"/>
<check_box
enabled="false"
layout="topleft"

View File

@ -172,7 +172,7 @@
</text>
<spinner tool_tip="-1 dla pełnej nazwy grupy, 0 aby wyłączyć" name="FSShowGroupNameLength"/>
<check_box name="FSOpenIMContainerOnOfflineMessage" label="Otwórz okno Rozmów, gdy pojawia się wiadomość offline"/>
<check_box name="FSRestoreOpenIMs" label="Przywróć otwarte okna IM z poprzedniej sesji" />
<check_box name="FSRestoreOpenIMs" label="Przywróć rozmowy z rezydentami z poprzedniej sesji" />
<check_box label="Ślij IM-y na mój e-mail, gdy jestem offline ([EMAIL])" name="send_im_to_email"/>
<text name="email_settings">
[https://accounts.secondlife.com/change_email Pokaż opcje powiadomień e-mail dla IM-ów offline]