feat: configure toast timeout - #62689
Conversation
| $this->initialState->provideLazyInitialState('toastTimeout', function () { | ||
| if ($this->userSession->getUser()) { | ||
| $uid = $this->userSession->getUser()->getUID(); | ||
| $value = $this->config->getUserValue($uid, Application::APP_ID, 'toast_timeout', '7000'); |
There was a problem hiding this comment.
please use IUserConfig in new code
There was a problem hiding this comment.
Yes and ideally config lexicon
| return false; | ||
| }); | ||
|
|
||
| $this->initialState->provideLazyInitialState('toastTimeout', function () { |
There was a problem hiding this comment.
| $this->initialState->provideLazyInitialState('toastTimeout', function () { | |
| $this->initialState->provideLazyInitialState('toastTimeout', function (): int { |
| * | ||
| * @var string[] | ||
| */ | ||
| public const TOAST_TIMEOUT_VALUES = ['15000', '30000', '-1']; |
There was a problem hiding this comment.
| public const TOAST_TIMEOUT_VALUES = ['15000', '30000', '-1']; | |
| public const array TOAST_TIMEOUT_VALUES = ['15000', '30000', '-1']; |
susnux
left a comment
There was a problem hiding this comment.
seems to be ok, but its an integer. So there is no reason to store it as string.
Especially for new code the proper type should directly be used.
| * | ||
| * @var string[] | ||
| */ | ||
| public const TOAST_TIMEOUT_VALUES = ['15000', '30000', '-1']; |
| $this->initialState->provideLazyInitialState('toastTimeout', function () { | ||
| if ($this->userSession->getUser()) { | ||
| $uid = $this->userSession->getUser()->getUID(); | ||
| $value = $this->config->getUserValue($uid, Application::APP_ID, 'toast_timeout', '7000'); |
There was a problem hiding this comment.
Same here please use the correct type, there is no reason for string
| $this->initialState->provideLazyInitialState('toastTimeout', function () { | ||
| if ($this->userSession->getUser()) { | ||
| $uid = $this->userSession->getUser()->getUID(); | ||
| $value = $this->config->getUserValue($uid, Application::APP_ID, 'toast_timeout', '7000'); |
There was a problem hiding this comment.
Yes and ideally config lexicon
| const TOAST_TIMEOUT_DEFAULT = String(TOAST_DEFAULT_TIMEOUT) | ||
| const TOAST_TIMEOUT_15S = '15000' | ||
| const TOAST_TIMEOUT_30S = '30000' | ||
| const TOAST_TIMEOUT_NEVER = String(TOAST_PERMANENT_TIMEOUT) | ||
|
|
||
| const toastTimeout = ref(String(loadState('theming', 'toastTimeout', TOAST_DEFAULT_TIMEOUT))) |
There was a problem hiding this comment.
As mentioned above there is no reason for string type, this is an int so also pass it as integer
Signed-off-by: Kristian Zendato <kristian.zendato@nextcloud.com>
1bdb4e5 to
4e7b2d3
Compare
| $this->initialState->provideLazyInitialState('toastTimeout', function (): int { | ||
| if ($this->userSession->getUser()) { | ||
| $uid = $this->userSession->getUser()->getUID(); | ||
| $value = $this->userConfig->getValueInt($uid, Application::APP_ID, ConfigLexicon::TOAST_TIMEOUT, ConfigLexicon::TOAST_TIMEOUT_DEFAULT); | ||
| if (in_array($value, BeforePreferenceListener::TOAST_TIMEOUT_VALUES, true) || $value === ConfigLexicon::TOAST_TIMEOUT_DEFAULT) { | ||
| return $value; | ||
| } | ||
| } | ||
| return ConfigLexicon::TOAST_TIMEOUT_DEFAULT; | ||
| }); |
There was a problem hiding this comment.
I think this is better to exposed as a capability instead - because this might also be used by clients.
| $this->initialState->provideLazyInitialState('toastTimeout', function (): int { | ||
| if ($this->userSession->getUser()) { | ||
| $uid = $this->userSession->getUser()->getUID(); | ||
| $value = $this->userConfig->getValueInt($uid, Application::APP_ID, ConfigLexicon::TOAST_TIMEOUT, ConfigLexicon::TOAST_TIMEOUT_DEFAULT); |
There was a problem hiding this comment.
| $value = $this->userConfig->getValueInt($uid, Application::APP_ID, ConfigLexicon::TOAST_TIMEOUT, ConfigLexicon::TOAST_TIMEOUT_DEFAULT); | |
| $value = $this->userConfig->getValueInt($uid, Application::APP_ID, ConfigLexicon::TOAST_TIMEOUT); |
no need to specify the default as this is handled by the config lexicon
Summary
Adds a personal theming setting to configure how long toast notifications remain visible.
Checklist
3. to review, feature component)stable32)AI (if applicable)