Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ReplyMessageBox = ({ message, onPress }: ReplyMessageBoxProps) => {
return (
<View className="flex-row items-start gap-1">
<BarChart width={18} height={18} fill={colors.icon} />
<Text className="text-[15px] line-clamp-2 text-ellipsis overflow-hidden">
<Text className="text-[15px] line-clamp-2 text-ellipsis overflow-hidden flex-1" numberOfLines={2} ellipsizeMode="tail">
Poll: {replyMessageDetails.content?.split("\n")?.[0]}
</Text>
</View>
Expand All @@ -49,7 +49,7 @@ const ReplyMessageBox = ({ message, onPress }: ReplyMessageBoxProps) => {
return <ImageFileReplyBlock file={replyMessageDetails.file} messageType={replyMessageDetails.message_type} owner={replyMessageDetails.owner} />

default:
return <Text className="text-base text-foreground line-clamp-2 text-ellipsis overflow-hidden">
return <Text className="text-base text-foreground line-clamp-2 text-ellipsis overflow-hidden flex-1" numberOfLines={2} ellipsizeMode="tail">
{replyMessageDetails.content}
</Text>
}
Expand Down Expand Up @@ -122,4 +122,4 @@ const ImageFileReplyBlock = ({ file, messageType, owner }: { file: string, messa
)
}

export default ReplyMessageBox
export default ReplyMessageBox
74 changes: 66 additions & 8 deletions apps/mobile/components/features/workspaces/WorkspaceSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import SiteSwitcher from '../auth/SiteSwitcher'
import { getSiteNameFromUrl } from '@raven/lib/utils/operations'
import ServerIcon from '@assets/icons/ServerIcon.svg'
import AddSite from '../auth/AddSite'
import { FrappeError, useFrappePostCall, useSWRConfig } from 'frappe-react-sdk'
import { toast } from 'sonner-native'
import { getErrorMessage } from '@components/common/ErrorBanner'
import { ActivityIndicator } from '@components/nativewindui/ActivityIndicator'

const WorkspaceSwitcher = ({ workspace, setWorkspace }: { workspace: string, setWorkspace: (workspace: string) => Promise<void> }) => {

Expand Down Expand Up @@ -108,6 +112,9 @@ interface SelectWorkspaceSheetProps {

const SelectWorkspaceSheet = ({ selectedWorkspace, workspaces, setWorkspace }: SelectWorkspaceSheetProps) => {

const { call: joinWorkspace, loading: joiningWorkspace } = useFrappePostCall('raven.api.workspaces.join_workspace')
const { mutate } = useSWRConfig()

const { myWorkspaces, otherWorkspaces } = useMemo(() => {
const myWorkspaces: Workspace[] = []
const otherWorkspaces: Workspace[] = []
Expand All @@ -127,6 +134,26 @@ const SelectWorkspaceSheet = ({ selectedWorkspace, workspaces, setWorkspace }: S
return { myWorkspaces, otherWorkspaces }
}, [workspaces, selectedWorkspace])

const handleJoinOtherWorkspace = useCallback(
(workspaceName: string) => {
const displayName =
workspaces.find((w) => w.name === workspaceName)?.workspace_name ?? workspaceName

joinWorkspace({ workspace: workspaceName })
.then(() => Promise.all([mutate('workspaces_list'), mutate('channel_list')]))
.then(() => setWorkspace(workspaceName))
.then(() => {
toast.success(`You have joined ${displayName}.`)
})
.catch((error: unknown) => {
toast.error(
getErrorMessage(error as FrappeError) || 'Failed to join the workspace.'
)
})
},
[joinWorkspace, setWorkspace, workspaces]
)

const siteInfo = useSiteContext()

const urlWithoutProtocol = useMemo(() => {
Expand Down Expand Up @@ -163,6 +190,8 @@ const SelectWorkspaceSheet = ({ selectedWorkspace, workspaces, setWorkspace }: S
workspace={workspace}
setWorkspace={setWorkspace}
isOtherWorkspace
isJoining={joiningWorkspace}
onJoinOtherWorkspace={handleJoinOtherWorkspace}
isLast={index === otherWorkspaces.length - 1}
/>
))}
Expand All @@ -173,18 +202,45 @@ const SelectWorkspaceSheet = ({ selectedWorkspace, workspaces, setWorkspace }: S
)
}

const WorkspaceRow = ({ workspace, isLast, setWorkspace, isOtherWorkspace = false }: { workspace: Workspace, isLast: boolean, setWorkspace: (workspace: string) => Promise<void>, isOtherWorkspace?: boolean }) => {
type WorkspaceRowProps = {
workspace: Workspace
isLast: boolean
setWorkspace: (workspace: string) => Promise<void>
isOtherWorkspace?: boolean
/** True while this row's join request is in flight */
isJoining?: boolean
onJoinOtherWorkspace?: (workspaceName: string) => void
}

const WorkspaceRow = ({
workspace,
isLast,
setWorkspace,
isOtherWorkspace = false,
isJoining = false,
onJoinOtherWorkspace,
}: WorkspaceRowProps) => {
const { colors } = useColorScheme()

const onClick = () => {
const onPress = () => {
if (isOtherWorkspace && onJoinOtherWorkspace) {
void onJoinOtherWorkspace(workspace.name)
return
}
if (!isOtherWorkspace) {
setWorkspace(workspace.name)
void setWorkspace(workspace.name)
}
}

const disabled = isOtherWorkspace && isJoining

return (
<Pressable className='flex flex-col gap-2' onPress={onClick}>
<View className='flex-row items-center gap-2'>
<Pressable
className='flex flex-col gap-2'
onPress={onPress}
disabled={disabled}
>
<View className={`flex-row items-center gap-2 ${disabled ? 'opacity-60' : ''}`}>
<UserAvatar
alt={workspace.workspace_name}
src={getLogo(workspace)}
Expand All @@ -194,11 +250,13 @@ const WorkspaceRow = ({ workspace, isLast, setWorkspace, isOtherWorkspace = fals
<Text className='text-sm font-semibold'>{workspace.workspace_name}</Text>
<Text className='text-sm text-gray-500'>{workspace.type}</Text>
</View>
{workspace.isSelected &&
{isJoining ? (
<ActivityIndicator size="small" color={colors.primary} />
) : workspace.isSelected ? (
<View className='mr-2'>
<CheckFilledIcon fill={colors.primary} height={20} width={20} />
</View>
}
) : null}
</View>
{!isLast && <Divider className='mx-0' />}
</Pressable>
Expand All @@ -216,4 +274,4 @@ const getLogo = (workspace: WorkspaceFields) => {
return logo
}

export default WorkspaceSwitcher
export default WorkspaceSwitcher
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "raven-web",
"private": true,
"license": "AGPL-3.0-only",
"version": "2.8.10",
"version": "2.8.11",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
24 changes: 14 additions & 10 deletions frontend/public/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,25 @@ try {
}

onBackgroundMessage(messaging, (payload) => {
const notificationTitle = payload.notification.title
const data = payload.data || {}
const notification = payload.notification || {}

const notificationTitle = data.title || notification.title
let notificationOptions = {
body: payload.notification.body || "",
body: data.body || notification.body || "",
}
if (payload.data.image) {
notificationOptions["icon"] = payload.data.image

if (data.image) {
notificationOptions["icon"] = data.image
}

if (payload.data.creation) {
notificationOptions["timestamp"] = payload.data.creation
if (data.creation) {
notificationOptions["timestamp"] = data.creation
}
let url = `${payload.data.base_url}/raven/channel/${payload.data.channel_id}`
let url = `${data.base_url}/raven/channel/${data.channel_id}`

if (payload.data.message_url) {
url = payload.data.message_url
if (data.message_url) {
url = data.message_url
}

if (isChrome()) {
Expand Down Expand Up @@ -68,4 +72,4 @@ try {

self.skipWaiting()
clientsClaim()
console.log("Service Worker Initialized")
console.log("Service Worker Initialized")
4 changes: 2 additions & 2 deletions frontend/src/components/layout/Sidebar/WorkspacesSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ const WorkspaceItem = ({ workspace }: { workspace: WorkspaceFields & { unread_co
</Tooltip>
</Flex>
{workspace.unread_count > 0 &&
<Box className='rounded-full absolute -right-2 -bottom-1 bg-red-11 dark:bg-red-9 text-white w-4 h-4 flex items-center justify-center'>
<Text as='span' size='1' weight='medium'>{workspace.unread_count}</Text>
<Box className='rounded-lg absolute -right-2 -bottom-1 bg-red-11 dark:bg-red-9 text-white min-w-4 p-0.5 h-4 flex items-center justify-center'>
<Text as='span' size='1' weight='medium'>{workspace.unread_count > 99 ? '99+' : workspace.unread_count}</Text>
</Box>
}
</HStack>
Expand Down
24 changes: 14 additions & 10 deletions frontend/src/utils/pushNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ export const showNotification = (payload: any) => {
const registration = window.frappePushNotification.serviceWorkerRegistration
if (!registration) return

const notificationTitle = payload?.notification?.title
const data = payload?.data ?? {}
const notification = payload?.notification ?? {}


const notificationTitle = data.title || notification.title
const notificationOptions = {
body: payload?.notification?.body || "",
}
if (payload?.data?.image) {
if (data.image) {
// @ts-ignore
notificationOptions["icon"] = payload.data.image
notificationOptions["icon"] = data.image
}

if (payload.data.creation) {
if (data.creation) {
// @ts-ignore
notificationOptions["timestamp"] = payload.data.creation
notificationOptions["timestamp"] = data.creation
}
let url = `${payload.data.base_url}/raven/channel/${payload.data.channel_id}`
let url = `${data.base_url}/raven/channel/${data.channel_id}`

if (payload.data.message_url) {
url = payload.data.message_url
if (data.message_url) {
url = data.message_url
}

if (isChrome()) {
Expand All @@ -31,7 +35,7 @@ export const showNotification = (payload: any) => {
url: url,
}
} else {
if (payload?.data?.click_action) {
if (data.click_action) {
// @ts-ignore
notificationOptions["actions"] = [
{
Expand All @@ -43,4 +47,4 @@ export const showNotification = (payload: any) => {
}

registration.showNotification(notificationTitle, notificationOptions)
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "raven",
"version": "2.8.10",
"version": "2.8.11",
"description": "Messaging Application",
"workspaces": [
"frontend",
Expand Down
2 changes: 1 addition & 1 deletion raven/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.8.10"
__version__ = "2.8.11"

from raven.raven_integrations.doctype.raven_incoming_webhook.raven_incoming_webhook import ( # noqa
handle_incoming_webhook as webhook,
Expand Down
12 changes: 6 additions & 6 deletions raven/api/preview_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ def get_preview_link(urls: list[str] | str):
# TODO: We need to replace these special characters with the actual emojis

data = {
"title": preview.title,
"description": preview.description,
"image": preview.image,
"force_title": preview.force_title,
"absolute_image": preview.absolute_image,
"site_name": preview.site_name,
"title": str(preview.title or ""),
"description": str(preview.description or ""),
"image": str(preview.image or ""),
"force_title": str(preview.force_title or ""),
"absolute_image": str(preview.absolute_image or ""),
"site_name": str(preview.site_name or ""),
}
frappe.cache().set_value(url, data)
message_links.append(data)
Expand Down
6 changes: 3 additions & 3 deletions raven/api/raven_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def save_message(message_id: str, add: str | bool = False):
"""
Save the message as a bookmark
"""

if isinstance(add, str):
add = add.lower() == "yes" or add == "1"
# no need to check if arg add is string, as Yes is being passed, which is what is expected by toggle_like
if isinstance(add, bool):
add = "Yes" if add else "No"

if not frappe.has_permission(doctype="Raven Message", doc=message_id, ptype="read"):
frappe.throw(_("You don't have permission to save this message"), frappe.PermissionError)
Expand Down
2 changes: 1 addition & 1 deletion raven/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raven-app",
"version": "2.8.10",
"version": "2.8.11",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
Loading