Skip to content

Commit

Permalink
Merge pull request #885 from The-Commit-Company/develop
Browse files Browse the repository at this point in the history
Release v1.5.3
  • Loading branch information
nikkothari22 authored Apr 23, 2024
2 parents 233c30f + 4b6fa1b commit 1a31a26
Show file tree
Hide file tree
Showing 64 changed files with 1,105 additions and 400 deletions.
2 changes: 1 addition & 1 deletion mobile/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mobile",
"private": true,
"version": "1.5.2",
"version": "1.5.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export type Member = {
user_image: string | undefined
first_name: string
is_admin?: boolean,
type?: 'User' | 'Bot'
allow_notifications?: 0 | 1,
type?: 'User' | 'Bot',
channel_member_name?: string
}

export type ChannelMembers = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { useGetChannelMembers } from "@/hooks/useGetChannelMembers"
import { UserContext } from "@/utils/auth/UserProvider"
import { IonItem, IonToggle, useIonToast } from "@ionic/react"
import { useFrappeGetCall, useFrappePostCall } from "frappe-react-sdk"
import { useContext, useMemo, useState } from "react"
import { useParams } from "react-router-dom"

export const ChannelPushNotificationToggle = () => {

const { data } = useFrappeGetCall<{ message: boolean }>('raven.api.notification.are_push_notifications_enabled', undefined, undefined, {
revalidateIfStale: false,
revalidateOnFocus: false,
revalidateOnReconnect: false,
})

if (data?.message) {
return (
<ToggleButton />
)
}

return null
}

const ToggleButton = () => {

const { channelID } = useParams<{ channelID: string }>()

const { currentUser } = useContext(UserContext)

const { channelMembers, mutate } = useGetChannelMembers(channelID)

const { call } = useFrappePostCall('raven.api.notification.toggle_push_notification_for_channel')

const { member, isNotificationEnabled } = useMemo(() => {
const member = channelMembers?.find(member => member.name === currentUser)
return {
member,
isNotificationEnabled: member?.allow_notifications
}
}, [channelMembers, currentUser])

const [loading, setLoading] = useState(false)

const [present] = useIonToast()

const onToggle = () => {
if (member && member.channel_member_name) {
setLoading(true)
call({
member: member.channel_member_name,
allow_notifications: isNotificationEnabled ? 0 : 1
})
.catch(() => {
present({
message: 'Failed to update notification settings',
duration: 1500,
color: 'danger',
position: 'bottom',
})
})
.then(() => mutate())
.finally(() => setLoading(false))

}
}

if (!member || !member.channel_member_name) {
return null
}



return <IonItem color='light'>
<IonToggle
onIonChange={onToggle}
disabled={loading}
checked={isNotificationEnabled ? true : false}>
Enable Push Notifications
</IonToggle>
</IonItem>
}
23 changes: 20 additions & 3 deletions mobile/src/components/features/chat-input/FileUploadModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { IonButton, IonButtons, IonContent, IonHeader, IonIcon, IonItem, IonLabe
import { addSharp, alertCircle, checkmarkCircle, closeCircleOutline } from 'ionicons/icons';
import { getFileExtension } from '../../../../../raven-app/src/utils/operations';
import { getFileExtensionIcon } from '../../../utils/layout/fileExtensions';
import { useFrappeCreateDoc, useFrappeFileUpload, useFrappeUpdateDoc } from 'frappe-react-sdk';
import { useFrappeFileUpload } from 'frappe-react-sdk';
import { useGetUser } from '@/hooks/useGetUser';
import { useGetChannelData } from '@/hooks/useGetChannelData';
import { DMChannelListItem } from '@/utils/channel/ChannelListProvider';

type Props = {
files: File[],
Expand All @@ -21,7 +24,21 @@ export const FileUploadModal = ({ files, setFiles, pickFiles, channelID, onMessa

const [loading, setLoading] = useState(false)
const [errorMap, setErrorMap] = React.useState<{ [key: string]: string }>({})

const { channel } = useGetChannelData(channelID)

const generateDescriptionMessage = (channel: DMChannelListItem) =>{
let text = "Files will be shared with "
if(channel.is_direct_message===1 && channel.is_self_message===0){
const user = useGetUser(channel.peer_user_id)
return text + user?.full_name || user?.first_name
}else if(channel.is_direct_message===1 && channel.is_self_message===1){
// ** should the line be changed?
return "Files will be stored here for your reference"
} else{
return text + "all channel members"
}
}


const uploadFiles = async () => {
setLoading(true)
Expand Down Expand Up @@ -81,7 +98,7 @@ export const FileUploadModal = ({ files, setFiles, pickFiles, channelID, onMessa
</IonHeader>
<IonContent>
<div className='py-2 mt-2 px-4 text-sm'>
<IonText color='medium'>Files will be shared with all channel members.</IonText>
<IonText color='medium'>{generateDescriptionMessage(channel as DMChannelListItem)}.</IonText>
</div>
<IonList>
{files.map((f, i) => <IonItem key={f.name + i}>
Expand Down
16 changes: 5 additions & 11 deletions mobile/src/components/features/chat-space/ChatInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const ChatInterface = ({ channel }: { channel: ChannelListItem | DMChanne
}
});

const { data: channelMembers } = useFrappeGetCall<{ message: ChannelMembersMap }>('raven.api.chat.get_channel_members', {
const { data: channelMembers, isLoading: channelMembersLoading } = useFrappeGetCall<{ message: ChannelMembersMap }>('raven.api.chat.get_channel_members', {
channel_id: channel.name
}, `raven.api.chat.get_channel_members.${channel.name}`, {
revalidateOnFocus: false,
Expand Down Expand Up @@ -123,15 +123,9 @@ export const ChatInterface = ({ channel }: { channel: ChannelListItem | DMChanne
</div>
<div className='flex items-center justify-between gap-2 w-full'>
<div className='grow p-1'>
{
isOpenChannel ?

<ChatHeader channel={channel} /> :
<Link to={`${channel.name}/channel-settings`}>
<ChatHeader channel={channel} />
</Link>

}
<Link to={`${channel.name}/channel-settings`}>
<ChatHeader channel={channel} />
</Link>
</div>
{/* TO-DO: Add Other optional buttons here later */}
{/* <div hidden aria-hidden>
Expand Down Expand Up @@ -212,7 +206,7 @@ export const ChatInterface = ({ channel }: { channel: ChannelListItem | DMChanne
hidden={!!error}
className='block relative z-10 order-1 w-full'
>
{channel && channel.is_archived === 0 && !isDM && !isUserInChannel && channel.type !== 'Open' ?
{channel && !channelMembersLoading && channel.is_archived === 0 && !isDM && !isUserInChannel && channel.type !== 'Open' ?
<JoinChannelButton channelData={channel} /> :

<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export const NonContinuationMessageBlock = ({ message, onMessageSelect, isScroll
isScrolling ? `focus:bg-transparent active:bg-transparent` : '')} {...longPressEvent}>
<MessageSenderAvatar user={user} userID={message.owner} isActive={isActive} />
<div>
<div className='flex items-baseline'>
<Text as='span' className='font-semibold' size='3'>{user?.full_name ?? message.owner}</Text>
<div className='flex items-baseline pb-1'>
<Text as='span' className='font-semibold' size='2'>{user?.full_name ?? message.owner}</Text>
{isBot && <Badge className='ml-2' color='gray'>Bot</Badge>}
<Text as='span' size='1' className='pl-1.5 text-gray-10'>{DateObjectToTimeString(message.creation)}</Text>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import { Skeleton } from '@/components/common/Skeleton';
// import { Box, Flex, Text } from '@radix-ui/themes';
import TiptapLink from '@tiptap/extension-link'
import { mergeAttributes, useCurrentEditor } from "@tiptap/react";
import { mergeAttributes } from "@tiptap/react";
// import { useFrappeGetCall } from 'frappe-react-sdk';
// import { memo, useMemo } from 'react';

Expand All @@ -10,7 +10,7 @@ export const CustomLink = TiptapLink.extend({
return [
"a",
mergeAttributes(HTMLAttributes, {
class: 'rt-Text rt-reset rt-Link rt-underline-auto break-all'
class: 'rt-Text rt-reset rt-Link rt-underline-always break-all'
}), // mergeAttributes is a exported function from @tiptap/core
0,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ export const TiptapRenderer = ({ message, user, isScrolling = false, isTruncated
italic: false,
listItem: {
HTMLAttributes: {
class: 'ml-5 rt-Text text-base'
class: 'ml-5 rt-Text text-sm'
}
},
paragraph: {
HTMLAttributes: {
class: 'rt-Text text-base'
class: 'rt-Text text-sm'
}
},
blockquote: {
Expand Down
6 changes: 3 additions & 3 deletions mobile/src/hooks/useGetChannelMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { useMemo } from "react"
import { ChannelMembers } from "@/components/features/channels/channel-members/AddChannelMembers"
import { useFrappeGetCall } from "frappe-react-sdk"

export const useGetChannelMembers = (channelID: string) =>{
export const useGetChannelMembers = (channelID: string) => {

const { data, error, mutate } = useFrappeGetCall<{ message: ChannelMembers }>('raven.api.chat.get_channel_members', {
channel_id: channelID
}, undefined, {
}, `raven.api.chat.get_channel_members:${channelID}`, {
revalidateOnFocus: false,
revalidateIfStale: false,
})
Expand All @@ -19,7 +19,7 @@ export const useGetChannelMembers = (channelID: string) =>{
}
}, [data])

return{
return {
channelMembers,
mutate,
error
Expand Down
6 changes: 6 additions & 0 deletions mobile/src/pages/channels/ChannelSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { UserContext } from "@/utils/auth/UserProvider"
import { ChatHeader } from "@/components/features/chat-space/chat-header"
import { Heading, Text } from "@radix-ui/themes"
import { UserAvatar } from "@/components/common/UserAvatar"
import { ChannelPushNotificationToggle } from "@/components/features/channels/channel-members/ChannelPushNotificationToggle"

export const ChannelSettings = () => {

Expand Down Expand Up @@ -99,6 +100,11 @@ export const ChannelSettings = () => {
}
</div>
</div>

{!isDM && <IonList inset>
<ChannelPushNotificationToggle />
</IonList>
}
<IonList inset>
{canAddMembers && <AddChannelMembersButton pageRef={pageRef} channelID={channelID} />}
{canLeaveChannel && <LeaveChannelButton channelID={channelID}
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/pages/profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const Profile = () => {
</IonItem>
</IonList>
<div className="ion-text-center mt-16">
<Text as='span'><Text as='span' size='6' className='cal-sans'>raven</Text> <Text as='span' color='gray'>v1.5.2</Text></Text>
<Text as='span'><Text as='span' size='6' className='cal-sans'>raven</Text> <Text as='span' color='gray'>v1.5.3</Text></Text>
<br />
<Text as='span' color='gray'>Made by The Commit Company</Text>
</div>
Expand Down
23 changes: 23 additions & 0 deletions mobile/src/types/RavenChannelManagement/RavenChannelMember.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

export interface RavenChannelMember{
creation: string
name: string
modified: string
owner: string
modified_by: string
docstatus: 0 | 1 | 2
parent?: string
parentfield?: string
parenttype?: string
idx?: number
/** Channel : Link - Raven Channel */
channel_id: string
/** User : Link - Raven User */
user_id: string
/** Is Admin : Check */
is_admin?: 0 | 1
/** Last Visit : Datetime */
last_visit: string
/** Allow notifications : Check */
allow_notifications?: 0 | 1
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raven",
"version": "1.5.2",
"version": "1.5.3",
"description": "Messaging Application",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions raven-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<script>window.csrf_token = '{{ csrf_token }}';
if (!window.frappe) window.frappe = {};

window.app_name = "{{ app_name }}";

frappe.boot = JSON.parse({{ boot }});
</script>
<script type="module" src="/src/main.tsx"></script>
Expand Down
2 changes: 1 addition & 1 deletion raven-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "raven-app",
"private": true,
"version": "1.5.2",
"version": "1.5.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
10 changes: 5 additions & 5 deletions raven-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ const router = createBrowserRouter(
<Route path="saved-messages" lazy={() => import('./components/feature/saved-messages/SavedMessages')} />
<Route path=":channelID" lazy={() => import('@/pages/ChatSpace')} />
</Route>
{/* <Route path='settings' lazy={() => import('./pages/settings/Settings')}>
<Route path='settings' lazy={() => import('./pages/settings/Settings')}>
<Route path='integrations'>
<Route path='webhooks' lazy={() => import('./pages/settings/Webhooks/WebhookList')} />
<Route path='webhooks/create' lazy={() => import('./pages/settings/Webhooks/CreateWebhook')} />
<Route path='webhooks/:ID' lazy={() => import('./pages/settings/Webhooks/ViewWebhook')} />
<Route path='scheduled-messages' element={<TemporalEvents />} />
<Route path='scheduled-messages/create' element={<CreateSchedulerEvent />} />
<Route path='scheduled-messages/:ID' element={<ViewSchedulerEvent />} />
<Route path='scheduled-messages' lazy={() => import('./pages/settings/ServerScripts/SchedulerEvents/SchedulerEvents')} />
<Route path='scheduled-messages/create' lazy={() => import('./pages/settings/ServerScripts/SchedulerEvents/CreateSchedulerEvent')} />
<Route path='scheduled-messages/:ID' lazy={() => import('./pages/settings/ServerScripts/SchedulerEvents/ViewSchedulerEvent')} />
</Route>
</Route> */}
</Route>
</Route>
</Route>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const LeaveChannelButton = ({ channelData, onClose: onParentClose }: Leav
return (
<AlertDialog.Root open={open} onOpenChange={setOpen}>
<AlertDialog.Trigger>
<Button color='red' variant='ghost' className={'text-left w-fit'}>
<Button variant='ghost' className={'text-left text-red-700 hover:bg-red-3 w-fit not-cal'}>
Leave channel
</Button>
</AlertDialog.Trigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { UserContext } from "../../../utils/auth/UserProvider"
import { ChannelListItem } from "@/utils/channel/ChannelListProvider"
import { ChannelMembers } from "@/utils/channel/ChannelMembersProvider"
import { AddMembersButton } from "./add-members/AddMembersButton"
import { RemoveMemberButton } from "./remove-members/RemoveMemberButton"
import { Box, Flex, TextField, Text } from "@radix-ui/themes"
import { BiSearch, BiCircle, BiSolidCrown } from "react-icons/bi"
import { UserAvatar } from "@/components/common/UserAvatar"
import { UserActionsMenu } from "./UserActions/UserActionsMenu"

interface MemberDetailsProps {
channelData: ChannelListItem,
channelMembers: ChannelMembers,
Expand Down Expand Up @@ -90,11 +91,10 @@ export const ChannelMemberDetails = ({ channelData, channelMembers, activeUsers,
member.name !== currentUser &&
channelData?.type !== 'Open' && channelData.is_archived == 0 &&
<Flex align="center">
<RemoveMemberButton
<UserActionsMenu
channelData={channelData}
channelMembers={channelMembers}
updateMembers={updateMembers}
selectedMember={member.name} />
selectedMember={member} />
</Flex>
}
</Flex>
Expand Down
Loading

0 comments on commit 1a31a26

Please sign in to comment.