Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(conversations): add backend support of compact list #13994

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,4 @@
* `config => conversations => force-passwords` - Whether passwords are enforced for public rooms
* `conversation-creation-password` - Whether the endpoints for creating public conversations or making a conversation public support setting a password
* `call-notification-state-api` (local) - Whether the endpoints exists for checking if a call notification should be dismissed
* `config => conversations => list-style` - Whether conversation list should appear in certain way
4 changes: 4 additions & 0 deletions docs/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
* `0` Everyone (default) - All participants can mention using `@all`
* `1` Moderators - Only moderators can mention using `@all`

### Conversation list style
* `two-lines` Normal (default) - two-line elements (with display name and last message)
* `compact` Compact - one-line elements (with display name)

## Participants

### Participant types
Expand Down
1 change: 1 addition & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Instead, the server API `POST /ocs/v2.php/apps/provisioning_api/api/v1/config/us
| `play_sounds` | | `'yes'` | `'yes'` and `'no'` |
| `calls_start_without_media` | `config => call => start-without-media` | `''` falling back to app config with the same name | `'yes'` and `'no'` |
| `blur_virtual_background` | `config => call => blur-virtual-background` | `'no'` | `'yes'` and `'no'` |
| `conversations_list_style` | `config => conversations => list-style` | `'two-lines'` | One of the constants from the [constants list](constants.md#conversation-list-style) |

## Set SIP settings

Expand Down
2 changes: 2 additions & 0 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class Capabilities implements IPublicCapability {
],
'conversations' => [
'can-create',
'list-style',
],
'federation' => [
'enabled',
Expand Down Expand Up @@ -229,6 +230,7 @@ public function getCapabilities(): array {
'conversations' => [
'can-create' => $user instanceof IUser && !$this->talkConfig->isNotAllowedToCreateConversations($user),
'force-passwords' => $this->talkConfig->isPasswordEnforced(),
'list-style' => $this->talkConfig->getConversationsListStyle($user?->getUID()),
],
'federation' => [
'enabled' => false,
Expand Down
17 changes: 17 additions & 0 deletions lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,23 @@ public function getBlurVirtualBackground(?string $userId): bool {
return false;
}

/**
* User setting for conversations list style
*
* @param ?string $userId
* @return string
*/
public function getConversationsListStyle(?string $userId): string {
if ($userId !== null) {
$userSetting = $this->config->getUserValue($userId, 'spreed', UserPreference::CONVERSATIONS_LIST_STYLE);
if (!empty($userSetting)) {
return $userSetting;
}
return 'two-lines';
}
return 'two-lines';
}

/**
* User setting falling back to admin defined app config
*/
Expand Down
3 changes: 3 additions & 0 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2539,6 +2539,9 @@ public function getCapabilities(): DataResponse {
if (isset($data['config']['call']['blur-virtual-background'])) {
$data['config']['call']['blur-virtual-background'] = $this->talkConfig->getBlurVirtualBackground($this->userId);
}
if (isset($data['config']['conversations']['list-style'])) {
$data['config']['conversations']['list-style'] = $this->talkConfig->getConversationsListStyle($this->userId);
}

if ($response->getHeaders()['X-Nextcloud-Talk-Hash']) {
$headers['X-Nextcloud-Talk-Proxy-Hash'] = $response->getHeaders()['X-Nextcloud-Talk-Hash'];
Expand Down
5 changes: 4 additions & 1 deletion lib/Federation/Proxy/TalkV1/ProxyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ public function overwrittenRemoteTalkHash(string $hash): string {
],
'call' => [
'blur-virtual-background',
]
],
'conversations' => [
'list-style',
],
],
]
]));
Expand Down
1 change: 1 addition & 0 deletions lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
* conversations: array{
* can-create: bool,
* force-passwords: bool,
* list-style: string,
* },
* federation: array{
* enabled: bool,
Expand Down
5 changes: 5 additions & 0 deletions lib/Settings/BeforePreferenceSetEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public function validatePreference(string $userId, string $key, string|int|null
return $valid;
}

// "list-style" 'two-lines' / 'compact'
if ($key === UserPreference::CONVERSATIONS_LIST_STYLE) {
return $value === 'two-lines' || $value === 'compact';
}

return false;
}

Expand Down
1 change: 1 addition & 0 deletions lib/Settings/UserPreference.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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 PLAY_SOUNDS = 'play_sounds';
public const TYPING_PRIVACY = 'typing_privacy';
public const READ_STATUS_PRIVACY = 'read_status_privacy';
Expand Down
6 changes: 5 additions & 1 deletion openapi-administration.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,18 @@
"type": "object",
"required": [
"can-create",
"force-passwords"
"force-passwords",
"list-style"
],
"properties": {
"can-create": {
"type": "boolean"
},
"force-passwords": {
"type": "boolean"
},
"list-style": {
"type": "string"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-backend-recording.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,18 @@
"type": "object",
"required": [
"can-create",
"force-passwords"
"force-passwords",
"list-style"
],
"properties": {
"can-create": {
"type": "boolean"
},
"force-passwords": {
"type": "boolean"
},
"list-style": {
"type": "string"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-backend-signaling.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,18 @@
"type": "object",
"required": [
"can-create",
"force-passwords"
"force-passwords",
"list-style"
],
"properties": {
"can-create": {
"type": "boolean"
},
"force-passwords": {
"type": "boolean"
},
"list-style": {
"type": "string"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-backend-sipbridge.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,18 @@
"type": "object",
"required": [
"can-create",
"force-passwords"
"force-passwords",
"list-style"
],
"properties": {
"can-create": {
"type": "boolean"
},
"force-passwords": {
"type": "boolean"
},
"list-style": {
"type": "string"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-bots.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,18 @@
"type": "object",
"required": [
"can-create",
"force-passwords"
"force-passwords",
"list-style"
],
"properties": {
"can-create": {
"type": "boolean"
},
"force-passwords": {
"type": "boolean"
},
"list-style": {
"type": "string"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-federation.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,18 @@
"type": "object",
"required": [
"can-create",
"force-passwords"
"force-passwords",
"list-style"
],
"properties": {
"can-create": {
"type": "boolean"
},
"force-passwords": {
"type": "boolean"
},
"list-style": {
"type": "string"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,18 @@
"type": "object",
"required": [
"can-create",
"force-passwords"
"force-passwords",
"list-style"
],
"properties": {
"can-create": {
"type": "boolean"
},
"force-passwords": {
"type": "boolean"
},
"list-style": {
"type": "string"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,18 @@
"type": "object",
"required": [
"can-create",
"force-passwords"
"force-passwords",
"list-style"
],
"properties": {
"can-create": {
"type": "boolean"
},
"force-passwords": {
"type": "boolean"
},
"list-style": {
"type": "string"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/__mocks__/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const mockedCapabilities: Capabilities = {
conversations: {
'can-create': true,
'force-passwords': false,
'list-style': 'two-lines',
},
federation: {
enabled: false,
Expand Down Expand Up @@ -167,6 +168,7 @@ export const mockedCapabilities: Capabilities = {
],
conversations: [
'can-create',
'list-style',
],
federation: [],
previews: [
Expand Down
36 changes: 35 additions & 1 deletion src/components/SettingsDialog/SettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@
@close="showFilePicker = false" />
</div>
</NcAppSettingsSection>
<NcAppSettingsSection v-if="!isGuest && supportConversationsListStyle"
id="talk_appearance"
:name="t('spreed', 'Appearance')"
class="app-settings-section">
<NcCheckboxRadioSwitch id="conversations_list_style"
:model-value="conversationsListStyle"
:disabled="appearanceLoading"
type="switch"
class="checkbox"
@update:modelValue="toggleConversationsListStyle">
{{ t('spreed', 'Show my conversations list in compact mode') }}
</NcCheckboxRadioSwitch>
</NcAppSettingsSection>
<NcAppSettingsSection v-if="!isGuest"
id="privacy"
:name="t('spreed', 'Privacy')"
Expand Down Expand Up @@ -212,7 +225,7 @@ import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadi

import MediaDevicesPreview from './MediaDevicesPreview.vue'

import { PRIVACY } from '../../constants.js'
import { CONVERSATION, PRIVACY } from '../../constants.js'
import BrowserStorage from '../../services/BrowserStorage.js'
import { getTalkConfig } from '../../services/CapabilitiesManager.ts'
import { useCustomSettings } from '../../services/SettingsAPI.ts'
Expand All @@ -230,6 +243,8 @@ const isBackgroundBlurredState = serverSupportsBackgroundBlurred
: BrowserStorage.getItem('background-blurred') // 'true', 'false', null
const supportTypingStatus = getTalkConfig('local', 'chat', 'typing-privacy') !== undefined
const supportStartWithoutMedia = getTalkConfig('local', 'call', 'start-without-media') !== undefined
const supportConversationsListStyle = getTalkConfig('local', 'conversations', 'list-style') !== undefined

export default {
name: 'SettingsDialog',

Expand Down Expand Up @@ -258,6 +273,7 @@ export default {
serverSupportsBackgroundBlurred,
customSettingsSections,
supportStartWithoutMedia,
supportConversationsListStyle,
}
},

Expand All @@ -266,6 +282,7 @@ export default {
showSettings: false,
showFilePicker: false,
attachmentFolderLoading: true,
appearanceLoading: false,
privacyLoading: false,
playSoundsLoading: false,
mediaLoading: false,
Expand Down Expand Up @@ -301,6 +318,10 @@ export default {
return this.settingsStore.startWithoutMedia
},

conversationsListStyle() {
return this.settingsStore.conversationsListStyle !== CONVERSATION.LIST_STYLE.TWO_LINES
},

settingsUrl() {
return generateUrl('/settings/user/notifications')
},
Expand Down Expand Up @@ -390,6 +411,19 @@ export default {
this.privacyLoading = false
},

async toggleConversationsListStyle(value) {
this.appearanceLoading = true
try {
await this.settingsStore.setConversationsListStyle(
value ? CONVERSATION.LIST_STYLE.COMPACT : CONVERSATION.LIST_STYLE.TWO_LINES
)
showSuccess(t('spreed', 'Your personal setting has been saved'))
} catch (exception) {
showError(t('spreed', 'Error while setting personal setting'))
}
this.appearanceLoading = false
},

/**
* Fallback method for versions before v29.0.4
* @param {boolean} value whether background should be blurred
Expand Down
5 changes: 5 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ export const CONVERSATION = {
DEFAULT: '',
},

LIST_STYLE: {
TWO_LINES: 'two-lines',
COMPACT: 'compact',
},

MAX_NAME_LENGTH: 255,
MAX_DESCRIPTION_LENGTH: 500,
}
Expand Down
Loading
Loading