-
Notifications
You must be signed in to change notification settings - Fork 1.4k
improvement: private message #6734
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
base: develop
Are you sure you want to change the base?
Changes from all commits
97d485c
1bb4f84
2369b25
5cafd31
09b497d
04866c6
af5a0f2
564eeb2
1ebd43e
c8f6cfd
93a31e5
648c2d9
1aea7d2
220136b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| appId: chat.rocket.reactnative | ||
| name: Private Message | ||
| onFlowStart: | ||
| - runFlow: '../../helpers/setup.yaml' | ||
| onFlowComplete: | ||
| - evalScript: ${output.utils.deleteCreatedUsers()} | ||
| tags: | ||
| - test-13 | ||
|
|
||
| --- | ||
| - evalScript: ${output.user = output.utils.createUser()} | ||
| - evalScript: ${output.channel = output.utils.createRandomRoom(output.user.username, output.user.password)} | ||
|
|
||
| - runFlow: | ||
| file: '../../helpers/login-with-deeplink.yaml' | ||
| env: | ||
| USERNAME: ${output.user.username} | ||
| PASSWORD: ${output.user.password} | ||
| - tapOn: | ||
| id: rooms-list-view-item-${output.channel.name} | ||
|
|
||
| # send a private slash command and dismiss it manually | ||
| - tapOn: | ||
| id: message-composer-input | ||
| - inputText: '/status' | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: autocomplete-item-status | ||
| timeout: 15000 | ||
| - tapOn: | ||
| id: autocomplete-item-status | ||
| - extendedWaitUntil: | ||
| notVisible: | ||
| id: autocomplete-item-status | ||
| timeout: 15000 | ||
| - tapOn: | ||
| id: message-composer-send | ||
| - extendedWaitUntil: | ||
| visible: | ||
| text: 'Status message changed successfully.' | ||
| timeout: 60000 | ||
| - extendedWaitUntil: | ||
| visible: | ||
| text: 'Dismiss message' | ||
| timeout: 15000 | ||
| - tapOn: | ||
| id: dismiss-private-message | ||
| - extendedWaitUntil: | ||
| notVisible: | ||
| text: 'Status message changed successfully.' | ||
| timeout: 15000 | ||
|
|
||
| # send a private slash command, go back to room list and return to same channel | ||
| - tapOn: | ||
| id: message-composer-input | ||
| - inputText: '/status' | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: autocomplete-item-status | ||
| timeout: 15000 | ||
| - tapOn: | ||
| id: autocomplete-item-status | ||
| - extendedWaitUntil: | ||
| notVisible: | ||
| id: autocomplete-item-status | ||
| timeout: 15000 | ||
| - tapOn: | ||
| id: message-composer-send | ||
| - extendedWaitUntil: | ||
| visible: | ||
| text: 'Status message changed successfully.' | ||
| timeout: 60000 | ||
| - extendedWaitUntil: | ||
| visible: | ||
| text: 'Dismiss message' | ||
| timeout: 15000 | ||
| - tapOn: | ||
| id: header-back | ||
| - tapOn: | ||
| id: rooms-list-view-item-${output.channel.name} | ||
| - extendedWaitUntil: | ||
| notVisible: | ||
| text: 'Status message changed successfully.' | ||
| timeout: 15000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -410,7 +410,8 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC | |
| replies, | ||
| md, | ||
| comment, | ||
| pinned | ||
| pinned, | ||
| private: isPrivate | ||
|
Collaborator
Author
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. we can't use private as variable name in class... |
||
| } = item; | ||
|
|
||
| let message = msg; | ||
|
|
@@ -505,6 +506,7 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC | |
| isBeingEdited={isBeingEdited} | ||
| isPreview={isPreview} | ||
| pinned={pinned} | ||
| private={isPrivate} | ||
| autoTranslateLanguage={autoTranslateLanguage} | ||
| /> | ||
| <MessageSeparator ts={dateSeparator} unread={showUnreadSeparator} /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Q } from '@nozbe/watermelondb'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import database from '../database'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import log from './helpers/log'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function deletePrivateMessages(id?: string): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const db = database.active; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const messages = id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? await db.get('messages').query(Q.where('id', id)).fetch() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : await db.get('messages').query(Q.where('private', true)).fetch(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const messagesToBeDeleted = messages.map(message => message.prepareDestroyPermanently()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await db.write(async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await db.batch(...messagesToBeDeleted); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log('e', e); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Do nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+22
Contributor
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. Improve error handling - don't silently swallow batch errors. The inner try-catch at lines 16-21 swallows errors with only a Consider these improvements: await db.write(async () => {
- try {
- await db.batch(...messagesToBeDeleted);
- } catch (e) {
- console.log('e', e);
- // Do nothing
- }
+ await db.batch(...messagesToBeDeleted);
});If you need to handle specific batch errors, re-throw them so the outer catch can log properly: await db.write(async () => {
try {
await db.batch(...messagesToBeDeleted);
} catch (e) {
- console.log('e', e);
- // Do nothing
+ log(e);
+ throw e; // Re-throw so caller knows deletion failed
}
});📝 Committable suggestion
Suggested change
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log(e); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add user feedback and error handling for dismiss action.
The dismiss action calls
deletePrivateMessageswithout awaiting or providing feedback. Users won't know if the dismissal succeeded or failed.Consider these improvements:
Example implementation: