Fix lingering draft when switching channels while never leaving the channel screen (#6417)
* Fix lingering draft when switching channels while never leaving the channel screen * Listen to changes on missing prop
This commit is contained in:
parent
f3c082d58c
commit
b97fd550f1
2 changed files with 8 additions and 2 deletions
|
|
@ -28,7 +28,7 @@ type OwnProps = {
|
|||
|
||||
const observeFirst = (v: DraftModel[]) => v[0]?.observe() || of$(undefined);
|
||||
|
||||
const enhanced = withObservables([], (ownProps: WithDatabaseArgs & OwnProps) => {
|
||||
const enhanced = withObservables(['channelId', 'rootId', 'channelIsArchived'], (ownProps: WithDatabaseArgs & OwnProps) => {
|
||||
const {database, rootId = ''} = ownProps;
|
||||
let channelId = of$(ownProps.channelId);
|
||||
if (!ownProps.channelId) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import React, {RefObject, useState} from 'react';
|
||||
import React, {RefObject, useEffect, useState} from 'react';
|
||||
import {Platform, View} from 'react-native';
|
||||
import {KeyboardTrackingView, KeyboardTrackingViewRef} from 'react-native-keyboard-tracking-view';
|
||||
|
||||
|
|
@ -51,6 +51,12 @@ function PostDraft({
|
|||
const [postInputTop, setPostInputTop] = useState(0);
|
||||
const isTablet = useIsTablet();
|
||||
|
||||
// Update draft in case we switch channels or threads
|
||||
useEffect(() => {
|
||||
setValue(message);
|
||||
setCursorPosition(message.length);
|
||||
}, [channelId, rootId]);
|
||||
|
||||
if (channelIsArchived || deactivatedChannel) {
|
||||
const archivedTestID = `${testID}.archived`;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue