Skip to content
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

show 'edited' label when message is edited by user #638

Merged
merged 4 commits into from
Feb 15, 2024
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 @@ -57,6 +57,7 @@ export const NonContinuationMessageBlock = ({ message, user }: { message: Messag
<IonText className='text-xs pl-1.5 text-zinc-500'>{DateObjectToTimeString(message.data.creation)}</IonText>
</div>
<MessageContent message={message} />
{message.data.is_edited === 1 && <IonText className='text-xs' color={'medium'}>(edited)</IonText>}
</div>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const MessageItem = ({ message, setDeleteMessage, onReplyMessageClick, se
{message.link_doctype && message.link_document && <Box className={clsx(message.is_continuation ? 'ml-0.5' : '-ml-0.5')}>
<DoctypeLinkRenderer doctype={message.link_doctype} docname={message.link_document} />
</Box>}

{message.is_edited === 1 && <Text size='1' className='text-gray-10'>(edited)</Text>}
{message_reactions?.length &&
<MessageReactions
messageID={name}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EditorContent, EditorContext, useEditor } from '@tiptap/react'
import { Message, TextMessage } from '../../../../../../../../types/Messaging/Message'
import { TextMessage } from '../../../../../../../../types/Messaging/Message'
import { UserFields } from '@/utils/users/UserListProvider'
import { BoxProps } from '@radix-ui/themes/dist/cjs/components/box'
import { Box } from '@radix-ui/themes'
import { Box, Text } from '@radix-ui/themes'
import Highlight from '@tiptap/extension-highlight'
import StarterKit from '@tiptap/starter-kit'
import css from 'highlight.js/lib/languages/css'
Expand Down
2 changes: 1 addition & 1 deletion raven/api/raven_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def get_messages(channel_id):
fields=['name', 'owner', 'creation', 'modified', 'text',
'file', 'message_type', 'message_reactions', 'is_reply', 'linked_message', '_liked_by', 'channel_id',
'thumbnail_width', 'thumbnail_height', 'file_thumbnail', 'link_doctype', 'link_document',
'replied_message_details', 'content'],
'replied_message_details', 'content', 'is_edited'],
order_by='creation asc'
)

Expand Down
10 changes: 9 additions & 1 deletion raven/raven_messaging/doctype/raven_message/raven_message.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"thumbnail_width",
"thumbnail_height",
"link_doctype",
"link_document"
"link_document",
"content",
"is_edited"
],
"fields": [
{
Expand Down Expand Up @@ -119,6 +121,12 @@
"label": "Content",
"read_only": 1
},
{
"default": "0",
"fieldname": "is_edited",
"fieldtype": "Check",
"label": "Is Edited"
},
{
"fieldname": "column_break_wvje",
"fieldtype": "Column Break"
Expand Down
8 changes: 8 additions & 0 deletions raven/raven_messaging/doctype/raven_message/raven_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class RavenMessage(Document):
file_thumbnail: DF.Attach | None
image_height: DF.Data | None
image_width: DF.Data | None
is_edited: DF.Check
is_reply: DF.Check
json: DF.JSON | None
link_doctype: DF.Link | None
Expand All @@ -43,6 +44,13 @@ def before_validate(self):
self.content = content.rstrip()
except Exception:
pass

if not self.is_new():
# this is not a new message, so it's a previous message being edited
old_doc = self.get_doc_before_save()
if old_doc.text != self.text:
self.is_edited = True

def validate(self):
'''
1. Message can be created if the channel is open
Expand Down
3 changes: 2 additions & 1 deletion types/Messaging/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export interface BaseMessage {
is_reply: 1 | 0
linked_message?: string | null
link_doctype?: string
link_document?: string,
link_document?: string
is_edited: 1 | 0
/** JSON as string */
replied_message_details?: string
}
Expand Down
Loading