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

Mobile drafts #8280

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open

Mobile drafts #8280

wants to merge 30 commits into from

Conversation

Rajat-Dabade
Copy link
Contributor

@Rajat-Dabade Rajat-Dabade commented Oct 22, 2024

Summary

Separate tab for Drafts in mobile.

Ticket Link

https://mattermost.atlassian.net/browse/MM-39356

Checklist

  • Added or updated unit tests (required for all new features)
  • Has UI changes
  • Includes text changes and localization file updates
  • Have tested against the 5 core themes to ensure consistency between them.
  • Have run E2E tests by adding label E2E iOS tests for PR.

Device Information

This PR was tested on: iOS version 17.5 (Both on iPhone and ipad)

Screenshots

Release Note

Added a feature for having a separate tab for Drafts in mobile. 

Note:
Will cover all the test case for this PR in separate PR.

@Rajat-Dabade
Copy link
Contributor Author

/update-branch

@Rajat-Dabade Rajat-Dabade marked this pull request as ready for review November 5, 2024 12:34
Copy link
Contributor

@larkox larkox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Some comments.

Comment on lines +231 to +242
if (!draft) {
const newDraft: Draft = {
channel_id: channelId,
root_id: rootId,
metadata: {
images: imageMetadata,
},
update_at: Date.now(),
};

return operator.handleDraft({drafts: [newDraft], prepareRecordsOnly});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder when this scenario happens, and if we really want to create a new draft.

My initial thought is this happens when we receive the metadata either after the draft is sent (and therefore not yet created) or before the draft is created. If it is already sent, we should just ignore. If it hasn't been added, probably this should not have been called.

Is there any other scenario I may be missing?

const isTablet = useIsTablet();
const showPostPriority = Boolean(isPostPriorityEnabled && draft.metadata?.priority && draft.metadata?.priority?.priority);

const onLongPress = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use useCallback to avoid passing a new function on every render.

underlayColor={changeOpacity(theme.centerChannelColor, 0.1)}
>
<View
style={[style.container]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
style={[style.container]}
style={style.container}

Comment on lines +18 to +19
postId: of$(draftId),
postProps: of$({}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these two needed?


return {
canDownloadFiles: observeCanDownloadFiles(database),
publicLinkEnabled,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why declare the variable instead of doing this here:

Suggested change
publicLinkEnabled,
publicLinkEnabled: observeConfigBooleanValue(database, 'EnablePublicLink'),

@@ -144,10 +144,15 @@ export default function PostInput({
onFocus();
};

const onBlur = useCallback(() => {
const onBlur = useCallback(async () => {
updateDraftMessage(serverUrl, channelId, rootId, value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we wait for this to be done (and make sure it didn't fail) before parsing the images?

Comment on lines +39 to +40
Q.where('type', 'D'), // Channels of type 'D'
Q.where('type', 'G'), // Channels of type 'D'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the comments don't add much here. Would make more sense if we say something like Direct Messages instead of Channels of type 'D'. Nevertheless, if you want to keep it like this, on line 40 it should say Channels of type 'G'.

@@ -27,7 +27,7 @@ type Props = {
globalThreadsTab: GlobalThreadsTab;
};

const edges: Edge[] = ['left', 'right'];
export const edges: Edge[] = ['left', 'right'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this export is needed?

@@ -173,6 +173,7 @@
"channel_info.favorited": "Favorited",
"channel_info.header": "Header:",
"channel_info.ignore_mentions": "Ignore @channel, @here, @all",
"channel_info.in": "In:",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specially To and In are too out of context for translators. Can you make the id a bit more meaningful? Something like... channel_info.drafts.draft_in_channel and channel_info.drafts.draft_to_user.

Comment on lines +319 to +320
"drafts": "Drafts",
"Drafts": "Drafts",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two ids seem off. Can you verify if it is intended?

@Rajat-Dabade Rajat-Dabade added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester 2: UX Review Requires review by a UX Designer labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core commiter 2: UX Review Requires review by a UX Designer 3: QA Review Requires review by a QA tester release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants