* Viewing Files in Edit mode in mobile with ability to delete and save * Added upload attachment to keyboard tracker view * using state instread of use ref * Minor * Added tests * intl extract * new function getFiles ById, batch file deletion and tests * Files fetching in edit options and tests * Removed DeviceEventEmitter and used React context * Added support to check minimum required version to show edit file attachments * resolve forward ref issue * Minor * memotized props for context and observe config with value * Import fixes
31 lines
837 B
TypeScript
31 lines
837 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {createContext, useContext, useMemo, type ReactNode} from 'react';
|
|
|
|
type EditPostContextType = {
|
|
onFileRemove?: (fileId: string) => void;
|
|
};
|
|
|
|
const EditPostContext = createContext<EditPostContextType>({});
|
|
|
|
type EditPostProviderProps = {
|
|
children: ReactNode;
|
|
onFileRemove?: (fileId: string) => void;
|
|
};
|
|
|
|
export const EditPostProvider = ({children, onFileRemove}: EditPostProviderProps) => {
|
|
const contextValue = useMemo(() => ({
|
|
onFileRemove,
|
|
}), [onFileRemove]);
|
|
|
|
return (
|
|
<EditPostContext.Provider value={contextValue}>
|
|
{children}
|
|
</EditPostContext.Provider>
|
|
);
|
|
};
|
|
|
|
export const useEditPost = () => {
|
|
return useContext(EditPostContext);
|
|
};
|