previewMessage: Hide the button once a message is sent (#1692)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
		
							parent
							
								
									0d18b44ba7
								
							
						
					
					
						commit
						faeb4fb585
					
				
					 1 changed files with 3 additions and 4 deletions
				
			
		| 
						 | 
					@ -20,7 +20,7 @@ import { sendBotMessage } from "@api/Commands";
 | 
				
			||||||
import ErrorBoundary from "@components/ErrorBoundary";
 | 
					import ErrorBoundary from "@components/ErrorBoundary";
 | 
				
			||||||
import { Devs } from "@utils/constants";
 | 
					import { Devs } from "@utils/constants";
 | 
				
			||||||
import definePlugin from "@utils/types";
 | 
					import definePlugin from "@utils/types";
 | 
				
			||||||
import { Button, ButtonLooks, ButtonWrapperClasses, DraftStore, DraftType, SelectedChannelStore, Tooltip, UserStore } from "@webpack/common";
 | 
					import { Button, ButtonLooks, ButtonWrapperClasses, DraftStore, DraftType, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface Props {
 | 
					interface Props {
 | 
				
			||||||
    type: {
 | 
					    type: {
 | 
				
			||||||
| 
						 | 
					@ -31,10 +31,9 @@ interface Props {
 | 
				
			||||||
const getDraft = (channelId: string) => DraftStore.getDraft(channelId, DraftType.ChannelMessage);
 | 
					const getDraft = (channelId: string) => DraftStore.getDraft(channelId, DraftType.ChannelMessage);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function PreviewButton(chatBoxProps: Props) {
 | 
					export function PreviewButton(chatBoxProps: Props) {
 | 
				
			||||||
    if (chatBoxProps.type.analyticsName !== "normal") return null;
 | 
					 | 
				
			||||||
    const channelId = SelectedChannelStore.getChannelId();
 | 
					    const channelId = SelectedChannelStore.getChannelId();
 | 
				
			||||||
    const draft = getDraft(channelId);
 | 
					    const draft = useStateFromStores([DraftStore], () => getDraft(channelId));
 | 
				
			||||||
 | 
					    if (chatBoxProps.type.analyticsName !== "normal") return null;
 | 
				
			||||||
    if (!draft) return null;
 | 
					    if (!draft) return null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue