-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(userStatus): migrate util to Typescript
Signed-off-by: Maksim Sukharev <[email protected]>
- Loading branch information
Showing
7 changed files
with
92 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
import { t } from '@nextcloud/l10n' | ||
|
||
import type { | ||
Conversation, | ||
Participant, | ||
ParticipantSearchResult, | ||
ParticipantStatus, | ||
} from '../types/index.ts' | ||
|
||
/** | ||
* Generate full status message for user according to its status data | ||
* | ||
* @param userData user data (from conversation, participant, search result) | ||
*/ | ||
export function getStatusMessage(userData?: ParticipantStatus | ''): string { | ||
if (!userData) { | ||
return '' | ||
} | ||
|
||
let status = userData.icon ?? '' | ||
|
||
if (userData.message) { | ||
status += ' ' + userData.message | ||
} else if (userData.status === 'dnd') { | ||
status += ' ' + t('spreed', 'Do not disturb') | ||
} else if (userData.status === 'away') { | ||
status += ' ' + t('spreed', 'Away') | ||
} | ||
|
||
return status | ||
} | ||
|
||
/** | ||
* Check if current status is "Do not disturb" | ||
* | ||
* @param userData user data | ||
*/ | ||
export function isDoNotDisturb(userData: Conversation | Participant | ParticipantSearchResult): boolean { | ||
return userData?.status === 'dnd' | ||
} |