-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Add option to restore automatic status #29430
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
Changes from 5 commits
527154b
41719c1
e711fcb
b294de2
4e8141c
3130a72
e0cc072
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| <!-- | ||
| - @copyright Copyright (c) 2021 Carl Schwan <carl@carlschwan.eu> | ||
| - @author Carl Schwan <carl@carlschwan.eu> | ||
| - | ||
| - @license GNU AGPL version 3 or any later version | ||
| - | ||
| - This program is free software: you can redistribute it and/or modify | ||
| - it under the terms of the GNU Affero General Public License as | ||
| - published by the Free Software Foundation, either version 3 of the | ||
| - License, or (at your option) any later version. | ||
| - | ||
| - This program is distributed in the hope that it will be useful, | ||
| - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| - GNU Affero General Public License for more details. | ||
| - | ||
| - You should have received a copy of the GNU Affero General Public License | ||
| - along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| - | ||
| --> | ||
|
|
||
| <template> | ||
| <div v-if="hasLoaded && backupStatus.status"> | ||
| {{ $t('user_status', 'Automatically set during calls and events.') }}<br /> | ||
| {{ $t('user_status', 'Reset to') }} | ||
| <a | ||
| href="#" | ||
| role="button" | ||
| @click.prevent.stop="revertCurrentStatus"> | ||
| {{ message }} | ||
| </a> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per https://docs.nextcloud.com/server/latest/developer_manual/basics/front-end/l10n.html#improving-your-translations please make the message a parameter in the translation, or use another line break and make the translated string "complete" e.g. |
||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { mapState } from 'vuex' | ||
| import { subscribe, unsubscribe } from '@nextcloud/event-bus' | ||
| import { getCurrentUser } from '@nextcloud/auth' | ||
|
|
||
| export default { | ||
| name: 'ResetStatus', | ||
| computed: { | ||
| ...mapState({ | ||
| backupStatus: state => state.backupStatus, | ||
| userStatus: state => state.userStatus, | ||
| }), | ||
| /** | ||
| * Indicator whether the backup status has already been loaded | ||
| * | ||
| * @returns {boolean} | ||
| */ | ||
| hasLoaded() { | ||
| return this.backupStatus.status !== null | ||
| }, | ||
| message() { | ||
| if (this.backupStatus.icon && this.backupStatus.message) { | ||
| return `${this.backupStatus.icon} ${this.backupStatus.message}` | ||
| } | ||
|
|
||
| if (this.backupStatus.message) { | ||
| return this.backupStatus.message | ||
| } | ||
|
|
||
| switch (this.backupStatus.status) { | ||
| case 'online': | ||
| return this.$t('user_status', 'Online') | ||
|
|
||
| case 'away': | ||
| return this.$t('user_status', 'Away') | ||
|
|
||
| case 'dnd': | ||
| return this.$t('user_status', 'Do not disturb') | ||
|
|
||
| case 'invisible': | ||
| return this.$t('user_status', 'Invisible') | ||
|
|
||
| case 'offline': | ||
| return this.$t('user_status', 'Offline') | ||
| } | ||
| return '' | ||
| }, | ||
| }, | ||
| /** | ||
| * Loads all predefined statuses from the server | ||
| * when this component is mounted | ||
| */ | ||
| mounted() { | ||
| this.$store.dispatch('loadBackupStatus') | ||
| subscribe('user_status:status.updated', this.handleUserStatusUpdated) | ||
| }, | ||
| beforeDestroy() { | ||
| unsubscribe('user_status:status.updated', this.handleUserStatusUpdated) | ||
| }, | ||
| methods: { | ||
| /** | ||
| * Revert the current status. | ||
| */ | ||
| revertCurrentStatus() { | ||
| this.$store.dispatch('revertStatus', { | ||
| status: this.userStatus, | ||
| backupStatus: this.backupStatus, | ||
| }) | ||
| }, | ||
| /** | ||
| * Handle change of status, and check if we still need to display the | ||
| * option to revert the current status. | ||
| * @param {Object} status The current status | ||
| */ | ||
| handleUserStatusUpdated(status) { | ||
| if (getCurrentUser().uid === status.userId) { | ||
| // Update backup information | ||
| this.$store.dispatch('loadBackupStatus') | ||
| } | ||
| }, | ||
| }, | ||
| } | ||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
| a { | ||
| font-weight: bold; | ||
| &:focus, &:hover { | ||
| text-decoration: underline; | ||
| } | ||
| } | ||
| </style> | ||
Uh oh!
There was an error while loading. Please reload this page.