feat: remove broadcasting Extensions Manager events from ComponentView (#703)

* feat: remove `broadcast` from `ComponentView`

As "Extensions Manager" is removed, the related events' broadcasting is not needed anymore

* fix: restore `manualDealloc`
This commit is contained in:
Vardan Hakobyan
2021-10-25 17:08:37 +04:00
committed by GitHub
parent d5a81c6648
commit b898e886a5
8 changed files with 6 additions and 19 deletions

View File

@@ -2,7 +2,7 @@ import { FunctionalComponent } from 'preact';
interface IProps { interface IProps {
expiredDate: string; expiredDate: string;
reloadStatus: (doManualReload?: boolean) => void; reloadStatus: () => void;
} }
export const IsExpired: FunctionalComponent<IProps> = ({ export const IsExpired: FunctionalComponent<IProps> = ({
@@ -35,7 +35,7 @@ export const IsExpired: FunctionalComponent<IProps> = ({
</div> </div>
</div> </div>
<div className={'right'}> <div className={'right'}>
<div className={'sk-app-bar-item'} onClick={() => reloadStatus(true)}> <div className={'sk-app-bar-item'} onClick={() => reloadStatus()}>
<button className={'sn-button small info'}>Reload</button> <button className={'sn-button small info'}>Reload</button>
</div> </div>
<div className={'sk-app-bar-item'}> <div className={'sk-app-bar-item'}>

View File

@@ -2,7 +2,7 @@ import { FunctionalComponent } from 'preact';
interface IProps { interface IProps {
isReloading: boolean; isReloading: boolean;
reloadStatus: (doManualReload?: boolean) => void; reloadStatus: () => void;
} }
export const OfflineRestricted: FunctionalComponent<IProps> = ({ export const OfflineRestricted: FunctionalComponent<IProps> = ({

View File

@@ -5,7 +5,6 @@ import { toDirective } from '@/components/utils';
import { useCallback, useEffect, useRef, useState } from 'preact/hooks'; import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
import { observer } from 'mobx-react-lite'; import { observer } from 'mobx-react-lite';
import { isDesktopApplication } from '@/utils'; import { isDesktopApplication } from '@/utils';
import { RootScopeMessages } from '@/messages';
import { OfflineRestricted } from '@/components/ComponentView/OfflineRestricted'; import { OfflineRestricted } from '@/components/ComponentView/OfflineRestricted';
import { UrlMissing } from '@/components/ComponentView/UrlMissing'; import { UrlMissing } from '@/components/ComponentView/UrlMissing';
import { IsDeprecated } from '@/components/ComponentView/IsDeprecated'; import { IsDeprecated } from '@/components/ComponentView/IsDeprecated';
@@ -20,7 +19,6 @@ interface IProps {
componentUuid: string; componentUuid: string;
onLoad?: (component: SNComponent) => void; onLoad?: (component: SNComponent) => void;
templateComponent?: SNComponent; templateComponent?: SNComponent;
broadcast?: (...args: unknown[]) => unknown;
manualDealloc?: boolean; manualDealloc?: boolean;
} }
@@ -39,8 +37,7 @@ export const ComponentView: FunctionalComponent<IProps> = observer(
onLoad, onLoad,
componentUuid, componentUuid,
templateComponent, templateComponent,
broadcast, manualDealloc = false,
manualDealloc = false
}) => { }) => {
const liveComponentRef = useRef<LiveItem<SNComponent> | null>(null); const liveComponentRef = useRef<LiveItem<SNComponent> | null>(null);
const iframeRef = useRef<HTMLIFrameElement>(null); const iframeRef = useRef<HTMLIFrameElement>(null);
@@ -71,7 +68,7 @@ export const ComponentView: FunctionalComponent<IProps> = observer(
}); });
}; };
const reloadStatus = useCallback((doManualReload = true) => { const reloadStatus = useCallback(() => {
if (!component) { if (!component) {
return; return;
} }
@@ -105,12 +102,9 @@ export const ComponentView: FunctionalComponent<IProps> = observer(
} else { } else {
setError(undefined); setError(undefined);
} }
if (isExpired && doManualReload) {
broadcast?.(RootScopeMessages.ReloadExtendedData);
}
setIsDeprecated(component.isDeprecated); setIsDeprecated(component.isDeprecated);
setDeprecationMessage(component.package_info.deprecation_message); setDeprecationMessage(component.package_info.deprecation_message);
}, [application.componentManager, broadcast, component, isComponentValid, isExpired]); }, [application.componentManager, component, isComponentValid, isExpired]);
const dismissDeprecationMessage = () => { const dismissDeprecationMessage = () => {
setTimeout(() => { setTimeout(() => {
@@ -362,6 +356,5 @@ export const ComponentViewDirective = toDirective<IProps>(ComponentView, {
onLoad: '=', onLoad: '=',
componentUuid: '=', componentUuid: '=',
templateComponent: '=', templateComponent: '=',
broadcast: '=',
manualDealloc: '=' manualDealloc: '='
}); });

View File

@@ -1,4 +1,3 @@
export enum RootScopeMessages { export enum RootScopeMessages {
ReloadExtendedData = 'reload-ext-data',
NewUpdateAvailable = 'new-update-available' NewUpdateAvailable = 'new-update-available'
} }

View File

@@ -113,7 +113,6 @@
on-load='self.onEditorLoad', on-load='self.onEditorLoad',
application='self.application' application='self.application'
app-state='self.appState' app-state='self.appState'
broadcast='$broadcast'
) )
textarea#note-text-editor.editable.font-editor( textarea#note-text-editor.editable.font-editor(
dir='auto', dir='auto',
@@ -171,5 +170,4 @@
ng-show='!self.stackComponentHidden(component)', ng-show='!self.stackComponentHidden(component)',
application='self.application' application='self.application'
app-state='self.appState' app-state='self.appState'
broadcast='$broadcast'
) )

View File

@@ -4,7 +4,6 @@
component-uuid='self.component.uuid', component-uuid='self.component.uuid',
application='self.application' application='self.application'
app-state='self.appState' app-state='self.appState'
broadcast='$broadcast'
) )
#tags-content.content(ng-if='!(self.component && self.component.active)') #tags-content.content(ng-if='!(self.component && self.component.active)')
.tags-title-section.section-title-bar .tags-title-section.section-title-bar

View File

@@ -15,5 +15,4 @@
component-uuid="ctrl.component.uuid", component-uuid="ctrl.component.uuid",
application='ctrl.application' application='ctrl.application'
app-state='self.appState' app-state='self.appState'
broadcast='$broadcast'
) )

View File

@@ -34,5 +34,4 @@
template-component="ctrl.state.editor", template-component="ctrl.state.editor",
application='ctrl.application' application='ctrl.application'
app-state='self.appState' app-state='self.appState'
broadcast='$broadcast'
) )