Merge and migrate locally-trusted preload scripts to contextBridge
API (#2553)
* Migrate intl_provider to contextBridge * Migrate modalPreload to contextBridge * Migrate loadingScreenPreload to contextBridge * Migrate downloadDropdown preloads to contextBridge * Migrate server dropdown preload to contextBridge * Migrate urlView preload to contextBridge * Merge all desktop API scripts into one * Remove unused communication channel constants
This commit is contained in:
@@ -7,8 +7,6 @@ import classNames from 'classnames';
|
||||
|
||||
import {useIntl} from 'react-intl';
|
||||
|
||||
import {DOWNLOADS_DROPDOWN_OPEN_FILE} from 'common/communication';
|
||||
|
||||
import FileSizeAndStatus from './FileSizeAndStatus';
|
||||
import ProgressBar from './ProgressBar';
|
||||
import ThreeDotButton from './ThreeDotButton';
|
||||
@@ -26,7 +24,7 @@ const DownloadsDropdownItemFile = ({item, activeItem}: OwnProps) => {
|
||||
const onFileClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
e.preventDefault();
|
||||
|
||||
window.postMessage({type: DOWNLOADS_DROPDOWN_OPEN_FILE, payload: {item}}, window.location.href);
|
||||
window.desktop.downloadsDropdown.openFile(item);
|
||||
};
|
||||
|
||||
const itemFilename = item.type === 'update' ?
|
||||
|
@@ -6,8 +6,6 @@ import {DownloadedItem} from 'types/downloads';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
||||
import {TOGGLE_DOWNLOADS_DROPDOWN_MENU} from 'common/communication';
|
||||
|
||||
type OwnProps = {
|
||||
activeItem?: DownloadedItem;
|
||||
item: DownloadedItem;
|
||||
@@ -22,13 +20,10 @@ const ThreeDotButton = ({item, activeItem, visible}: OwnProps) => {
|
||||
e.stopPropagation();
|
||||
|
||||
const coords = buttonElement.current?.getBoundingClientRect();
|
||||
window.postMessage({
|
||||
type: TOGGLE_DOWNLOADS_DROPDOWN_MENU,
|
||||
payload: {
|
||||
coordinates: coords?.toJSON(),
|
||||
item,
|
||||
},
|
||||
}, window.location.href);
|
||||
window.desktop.downloadsDropdown.toggleDownloadsDropdownMenu({
|
||||
coordinates: coords?.toJSON(),
|
||||
item,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
@@ -8,8 +8,6 @@ import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import {Button} from 'react-bootstrap';
|
||||
|
||||
import {START_UPDATE_DOWNLOAD} from 'common/communication';
|
||||
|
||||
import Thumbnail from '../Thumbnail';
|
||||
|
||||
type OwnProps = {
|
||||
@@ -19,7 +17,7 @@ type OwnProps = {
|
||||
const UpdateAvailable = ({item}: OwnProps) => {
|
||||
const onButtonClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e?.preventDefault?.();
|
||||
window.postMessage({type: START_UPDATE_DOWNLOAD}, window.location.href);
|
||||
window.desktop.downloadsDropdown.startUpdateDownload();
|
||||
};
|
||||
|
||||
return (
|
||||
|
@@ -10,8 +10,6 @@ import {Button} from 'react-bootstrap';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
||||
import {START_UPGRADE} from 'common/communication';
|
||||
|
||||
import Thumbnail from '../Thumbnail';
|
||||
import FileSizeAndStatus from '../FileSizeAndStatus';
|
||||
|
||||
@@ -24,7 +22,7 @@ const UpdateAvailable = ({item}: OwnProps) => {
|
||||
|
||||
const onButtonClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e?.preventDefault?.();
|
||||
window.postMessage({type: START_UPGRADE}, window.location.href);
|
||||
window.desktop.downloadsDropdown.startUpgrade();
|
||||
};
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user