@@ -1601,30 +1601,44 @@ class ChatViewModel @Inject constructor(
16011601 return @launch
16021602 }
16031603
1604- val targetId = if (spaceView.spaceUxType == SpaceUxType .CHAT ) {
1605- // For chat spaces, update the space view object
1606- spaceView.id
1604+ if (spaceView.spaceUxType == SpaceUxType .CHAT ) {
1605+ // For chat spaces, update space details
1606+ setSpaceDetails.async(
1607+ SetSpaceDetails .Params (
1608+ space = vmParams.space,
1609+ details = mapOf (Relations .NAME to newName)
1610+ )
1611+ ).onSuccess {
1612+ Timber .d(" Successfully updated chat space name to: $newName " )
1613+ // Update local state
1614+ val currentHeader = header.value
1615+ if (currentHeader is HeaderView .Default ) {
1616+ header.value = currentHeader.copy(title = newName)
1617+ }
1618+ sendToast(" Chat name updated" )
1619+ }.onFailure { e ->
1620+ Timber .e(e, " Error while updating chat space name" )
1621+ sendToast(" Failed to update chat name" )
1622+ }
16071623 } else {
16081624 // For non-chat spaces, update the chat object
1609- vmParams.ctx
1610- }
1611-
1612- setObjectDetails.async(
1613- SetObjectDetails .Params (
1614- ctx = targetId,
1615- details = mapOf (Relations .NAME to newName)
1616- )
1617- ).onSuccess {
1618- Timber .d(" Successfully updated chat name to: $newName " )
1619- // Update local state
1620- val currentHeader = header.value
1621- if (currentHeader is HeaderView .Default ) {
1622- header.value = currentHeader.copy(title = newName)
1625+ setObjectDetails.async(
1626+ SetObjectDetails .Params (
1627+ ctx = vmParams.ctx,
1628+ details = mapOf (Relations .NAME to newName)
1629+ )
1630+ ).onSuccess {
1631+ Timber .d(" Successfully updated chat name to: $newName " )
1632+ // Update local state
1633+ val currentHeader = header.value
1634+ if (currentHeader is HeaderView .Default ) {
1635+ header.value = currentHeader.copy(title = newName)
1636+ }
1637+ sendToast(" Chat name updated" )
1638+ }.onFailure { e ->
1639+ Timber .e(e, " Error while updating chat name" )
1640+ sendToast(" Failed to update chat name" )
16231641 }
1624- sendToast(" Chat name updated" )
1625- }.onFailure { e ->
1626- Timber .e(e, " Error while updating chat name" )
1627- sendToast(" Failed to update chat name" )
16281642 }
16291643 }
16301644 }
0 commit comments