feat(splitview): Define user setting and capability

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2025-11-07 10:56:57 +01:00
parent e3bd61fbd5
commit c0d534fd4e
No known key found for this signature in database
GPG key ID: F72FA5B49FFA96B0
9 changed files with 47 additions and 0 deletions

View file

@ -201,3 +201,4 @@
## 23
* `pinned-messages` - Whether messages can be pinned
* `federated-shared-items` - Whether shared items endpoints can be called in a federated conversation
* `config => chat => style` (local) - User selected chat style (split or unified for now)

View file

@ -176,6 +176,7 @@ class Capabilities implements IPublicCapability {
'has-translation-task-providers',
'typing-privacy',
'summary-threshold',
'style',
],
'conversations' => [
'can-create',
@ -263,6 +264,7 @@ class Capabilities implements IPublicCapability {
'has-translation-task-providers' => false,
'typing-privacy' => Participant::PRIVACY_PUBLIC,
'summary-threshold' => max(1, $this->appConfig->getAppValueInt('summary_threshold', 100)),
'style' => $this->talkConfig->getChatStyle($user?->getUID()),
],
'conversations' => [
'can-create' => $user instanceof IUser && !$this->talkConfig->isNotAllowedToCreateConversations($user),

View file

@ -757,6 +757,28 @@ class Config {
return UserPreference::CONVERSATION_LIST_STYLE_TWO_LINES;
}
/**
* User setting for chat style
*
* @param ?string $userId
* @return UserPreference::CHAT_STYLE_*
*/
public function getChatStyle(?string $userId): string {
if ($userId !== null) {
$userSetting = $this->config->getUserValue(
$userId,
'spreed',
UserPreference::CHAT_STYLE,
UserPreference::CHAT_STYLE_SPLIT
);
if (in_array($userSetting, [UserPreference::CHAT_STYLE_SPLIT, UserPreference::CHAT_STYLE_UNIFIED], true)) {
return $userSetting;
}
}
return UserPreference::CHAT_STYLE_SPLIT;
}
/**
* User setting falling back to admin defined app config
*/

View file

@ -31,6 +31,7 @@ class ConfigLexicon implements ILexicon {
public function getUserConfigs(): array {
return [
new Entry(UserPreference::PLAY_SOUNDS, ValueType::BOOL, true),
new Entry(UserPreference::CHAT_STYLE, ValueType::STRING, UserPreference::CHAT_STYLE_SPLIT),
];
}
}

View file

@ -524,6 +524,7 @@ namespace OCA\Talk;
* has-translation-task-providers: bool,
* typing-privacy: int,
* summary-threshold: positive-int,
* style: 'split'|'unified',
* },
* conversations: array{
* can-create: bool,

View file

@ -81,6 +81,9 @@ class BeforePreferenceSetEventListener implements IEventListener {
if ($key === UserPreference::CONVERSATIONS_LIST_STYLE) {
return $value === UserPreference::CONVERSATION_LIST_STYLE_TWO_LINES || $value === UserPreference::CONVERSATION_LIST_STYLE_COMPACT;
}
if ($key === UserPreference::CHAT_STYLE) {
return $value === UserPreference::CHAT_STYLE_SPLIT || $value === UserPreference::CHAT_STYLE_UNIFIED;
}
return false;
}

View file

@ -13,6 +13,7 @@ class UserPreference {
public const BLUR_VIRTUAL_BACKGROUND = 'blur_virtual_background';
public const CALLS_START_WITHOUT_MEDIA = 'calls_start_without_media';
public const CONVERSATIONS_LIST_STYLE = 'conversations_list_style';
public const CHAT_STYLE = 'chat_style';
public const PLAY_SOUNDS = 'play_sounds';
public const TYPING_PRIVACY = 'typing_privacy';
public const READ_STATUS_PRIVACY = 'read_status_privacy';
@ -20,4 +21,7 @@ class UserPreference {
public const CONVERSATION_LIST_STYLE_TWO_LINES = 'two-lines';
public const CONVERSATION_LIST_STYLE_COMPACT = 'compact';
public const CHAT_STYLE_SPLIT = 'split';
public const CHAT_STYLE_UNIFIED = 'unified';
}

View file

@ -159,6 +159,7 @@ export const mockedCapabilities: Capabilities = {
'has-translation-task-providers': true,
'typing-privacy': 0,
'summary-threshold': 100,
'style': 'split',
},
conversations: {
'can-create': true,

View file

@ -104,6 +104,11 @@ class CapabilitiesTest extends TestCase {
->method('isBreakoutRoomsEnabled')
->willReturn(false);
$this->talkConfig->expects($this->once())
->method('getChatStyle')
->with(null)
->willReturn('split');
$this->serverConfig->expects($this->any())
->method('getAppValue')
->willReturnMap([
@ -181,6 +186,7 @@ class CapabilitiesTest extends TestCase {
'has-translation-task-providers' => false,
'typing-privacy' => 0,
'summary-threshold' => 100,
'style' => 'split',
],
'conversations' => [
'can-create' => false,
@ -247,6 +253,11 @@ class CapabilitiesTest extends TestCase {
->with('uid')
->willReturn('/Talk');
$this->talkConfig->expects($this->once())
->method('getChatStyle')
->with('uid')
->willReturn('split');
$this->talkConfig->expects($this->once())
->method('isNotAllowedToCreateConversations')
->with($user)
@ -353,6 +364,7 @@ class CapabilitiesTest extends TestCase {
'has-translation-task-providers' => false,
'typing-privacy' => 0,
'summary-threshold' => 100,
'style' => 'split',
],
'conversations' => [
'can-create' => $canCreate,