-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Rajat-Dabade
wants to merge
30
commits into
main
Choose a base branch
from
mobile-drafts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,154
−208
Open
Mobile drafts #8280
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
7a954e7
refactor: started with draft, done until new tabs for draft
Rajat-Dabade bf64bce
refactor: change the query and added the screen for draft
Rajat-Dabade d7e3aea
added condition for fetching draft for channel delete or not
Rajat-Dabade 421fdf2
refactor: added draft screen
Rajat-Dabade c32df46
linter fixes
Rajat-Dabade 1eefbde
Added draft post component
Rajat-Dabade 6cb3094
added avatar and header display name for the draft post list
Rajat-Dabade 1dbe020
added channel info component
Rajat-Dabade 978a8cb
channel info completed
Rajat-Dabade f069326
proper naming
Rajat-Dabade 9b4d50f
added image file markdown acknowledgement support
Rajat-Dabade 743d994
draft actions
Rajat-Dabade bf7767e
Fix the draft receiver in drafts
Rajat-Dabade 0aae855
separated send message handler
Rajat-Dabade bf446e3
Done with send drafts
Rajat-Dabade cf37827
done with delete drafts
Rajat-Dabade 0a1fc59
change save to send draft
Rajat-Dabade b7b5053
handle lengthy message with show more button
Rajat-Dabade 594f167
done with persistent message edit, send and delete drafts
Rajat-Dabade ea46f34
added alert for sending message
Rajat-Dabade b895070
added update at time for the drafts
Rajat-Dabade b93b340
Merge branch 'main' into mobile-drafts
mattermost-build 086ec82
en.json extract fix
Rajat-Dabade 98d58c3
Updated dependencies for useCallback
Rajat-Dabade 902e2ea
refactor: added drafts list to animated list
Rajat-Dabade 3fea445
added swipeable component and delete conformation for drafts
Rajat-Dabade 2607869
done with rendering of images in markdown for drafts
Rajat-Dabade 5e99dce
en.json issue fixed
Rajat-Dabade d26155c
fix en.json issue
Rajat-Dabade c7e36be
refactor: en.json fix
Rajat-Dabade File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {Image} from 'expo-image'; | ||
import React from 'react'; | ||
import {StyleSheet, View} from 'react-native'; | ||
|
||
import {buildAbsoluteUrl} from '@actions/remote/file'; | ||
import {buildProfileImageUrlFromUser} from '@actions/remote/user'; | ||
import {useServerUrl} from '@app/context/server'; | ||
import CompassIcon from '@components/compass_icon'; | ||
import {changeOpacity} from '@utils/theme'; | ||
|
||
import type UserModel from '@typings/database/models/servers/user'; | ||
|
||
type Props = { | ||
author: UserModel; | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
avatarContainer: { | ||
backgroundColor: 'rgba(255, 255, 255, 0.4)', | ||
margin: 2, | ||
width: 20, | ||
height: 20, | ||
}, | ||
avatar: { | ||
height: 20, | ||
width: 20, | ||
}, | ||
avatarRadius: { | ||
borderRadius: 18, | ||
}, | ||
}); | ||
|
||
const Avatar = ({ | ||
author, | ||
}: Props) => { | ||
const serverUrl = useServerUrl(); | ||
|
||
let uri = ''; | ||
if (!uri && author) { | ||
uri = buildProfileImageUrlFromUser(serverUrl, author); | ||
} | ||
|
||
let picture; | ||
if (uri) { | ||
picture = ( | ||
<Image | ||
source={{uri: buildAbsoluteUrl(serverUrl, uri)}} | ||
style={[styles.avatar, styles.avatarRadius]} | ||
/> | ||
); | ||
} else { | ||
picture = ( | ||
<CompassIcon | ||
name='account-outline' | ||
size={20} | ||
color={changeOpacity('#fff', 0.48)} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<View style={[styles.avatarContainer, styles.avatarRadius]}> | ||
{picture} | ||
</View> | ||
); | ||
}; | ||
|
||
export default Avatar; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React, {type ReactNode} from 'react'; | ||
import {Text, View} from 'react-native'; | ||
|
||
import {General} from '@app/constants'; | ||
import {useTheme} from '@app/context/theme'; | ||
import {changeOpacity, makeStyleSheetFromTheme} from '@app/utils/theme'; | ||
import {typography} from '@app/utils/typography'; | ||
import {getUserTimezone} from '@app/utils/user'; | ||
import FormattedText from '@components/formatted_text'; | ||
import FormattedTime from '@components/formatted_time'; | ||
|
||
import CompassIcon from '../compass_icon'; | ||
|
||
import Avatar from './avatar'; | ||
|
||
import type ChannelModel from '@typings/database/models/servers/channel'; | ||
import type PostModel from '@typings/database/models/servers/post'; | ||
import type UserModel from '@typings/database/models/servers/user'; | ||
|
||
type Props = { | ||
channel: ChannelModel; | ||
draftReceiverUser?: UserModel; | ||
updateAt: number; | ||
rootId?: PostModel['rootId']; | ||
testID?: string; | ||
currentUser?: UserModel; | ||
isMilitaryTime: boolean; | ||
} | ||
|
||
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { | ||
return { | ||
container: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
}, | ||
infoContainer: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
gap: 5, | ||
alignItems: 'center', | ||
}, | ||
channelInfo: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
gap: 5, | ||
alignItems: 'center', | ||
}, | ||
displayName: { | ||
fontSize: 12, | ||
fontWeight: '600', | ||
color: changeOpacity(theme.centerChannelColor, 0.64), | ||
lineHeight: 16, | ||
fontFamily: 'Open Sans', | ||
}, | ||
timeInfo: { | ||
fontSize: 12, | ||
fontWeight: '400', | ||
color: changeOpacity(theme.centerChannelColor, 0.64), | ||
lineHeight: 16, | ||
}, | ||
time: { | ||
color: theme.centerChannelColor, | ||
marginTop: 5, | ||
opacity: 0.5, | ||
...typography('Body', 75, 'Regular'), | ||
}, | ||
}; | ||
}); | ||
|
||
const ChannelInfo: React.FC<Props> = ({ | ||
channel, | ||
draftReceiverUser, | ||
updateAt, | ||
rootId, | ||
testID, | ||
currentUser, | ||
isMilitaryTime, | ||
}) => { | ||
const theme = useTheme(); | ||
const style = getStyleSheet(theme); | ||
const isChannelTypeDM = channel.type === General.DM_CHANNEL; | ||
|
||
let headerComponent: ReactNode = null; | ||
const profileComponent = draftReceiverUser ? <Avatar author={draftReceiverUser}/> : ( | ||
<CompassIcon | ||
color={changeOpacity(theme.centerChannelColor, 0.64)} | ||
name='globe' | ||
size={18} | ||
/>); | ||
|
||
if (rootId) { | ||
headerComponent = ( | ||
<View style={style.channelInfo}> | ||
<FormattedText | ||
id='channel_info.thread_in' | ||
defaultMessage={'Thread in:'} | ||
style={style.displayName} | ||
/> | ||
{profileComponent} | ||
</View> | ||
); | ||
} else if (isChannelTypeDM) { | ||
headerComponent = ( | ||
<View style={style.channelInfo}> | ||
<FormattedText | ||
id='channel_info.to' | ||
defaultMessage={'To:'} | ||
style={style.displayName} | ||
/> | ||
{profileComponent} | ||
</View> | ||
); | ||
} else { | ||
headerComponent = ( | ||
<View style={style.channelInfo}> | ||
<FormattedText | ||
id='channel_info.in' | ||
defaultMessage={'In:'} | ||
style={style.displayName} | ||
/> | ||
{profileComponent} | ||
</View> | ||
); | ||
} | ||
|
||
return ( | ||
|
||
<View | ||
style={style.container} | ||
testID={testID} | ||
> | ||
<View style={style.infoContainer}> | ||
{headerComponent} | ||
<Text style={style.displayName}> | ||
{channel.displayName} | ||
</Text> | ||
</View> | ||
<FormattedTime | ||
timezone={getUserTimezone(currentUser)} | ||
isMilitaryTime={isMilitaryTime} | ||
value={updateAt} | ||
style={style.time} | ||
testID='post_header.date_time' | ||
/> | ||
</View> | ||
); | ||
}; | ||
|
||
export default ChannelInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {withDatabase, withObservables} from '@nozbe/watermelondb/react'; | ||
import {map} from 'rxjs/operators'; | ||
|
||
import {getDisplayNamePreferenceAsBool} from '@app/helpers/api/preference'; | ||
import {queryDisplayNamePreferences} from '@app/queries/servers/preference'; | ||
import {observeCurrentUser} from '@app/queries/servers/user'; | ||
|
||
import ChannelInfo from './channel_info'; | ||
|
||
const enhance = withObservables([], ({database}) => { | ||
const currentUser = observeCurrentUser(database); | ||
const preferences = queryDisplayNamePreferences(database). | ||
observeWithColumns(['value']); | ||
const isMilitaryTime = preferences.pipe(map((prefs) => getDisplayNamePreferenceAsBool(prefs, 'use_military_time'))); | ||
|
||
return { | ||
currentUser, | ||
isMilitaryTime, | ||
}; | ||
}); | ||
|
||
export default withDatabase(enhance(ChannelInfo)); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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?