import { FunctionComponent } from "preact"; import { SNComponent } from "@standardnotes/snjs"; import { PreferencesSegment, SubtitleLight, Title } from "@/preferences/components"; import { Switch } from "@/components/Switch"; import { WebApplication } from "@/ui_models/application"; import { useState } from "preact/hooks"; import { Button } from "@/components/Button"; import { RenameExtension } from "./RenameExtension"; const UseHosted: FunctionComponent<{ offlineOnly: boolean, toggleOfllineOnly: () => void }> = ({ offlineOnly, toggleOfllineOnly }) => (
Use hosted when local is unavailable
); export interface ExtensionItemProps { application: WebApplication, extension: SNComponent, first: boolean, latestVersion: string | undefined, uninstall: (extension: SNComponent) => void, toggleActivate?: (extension: SNComponent) => void, } export const ExtensionItem: FunctionComponent = ({ application, extension, first, uninstall}) => { const [offlineOnly, setOfflineOnly] = useState(extension.offlineOnly ?? false); const [extensionName, setExtensionName] = useState(extension.name); const toggleOffllineOnly = () => { const newOfflineOnly = !offlineOnly; setOfflineOnly(newOfflineOnly); application .changeAndSaveItem(extension.uuid, (m: any) => { if (m.content == undefined) m.content = {}; m.content.offlineOnly = newOfflineOnly; }) .then((item) => { const component = (item as SNComponent); setOfflineOnly(component.offlineOnly); }) .catch(e => { console.error(e); }); }; const changeExtensionName = (newName: string) => { setExtensionName(newName); application .changeAndSaveItem(extension.uuid, (m: any) => { if (m.content == undefined) m.content = {}; m.content.name = newName; }) .then((item) => { const component = (item as SNComponent); setExtensionName(component.name); }); }; const localInstallable = extension.package_info.download_url; const isThirParty = application.isThirdPartyFeature(extension.identifier); return ( {first && <> Extensions
}
{isThirParty && localInstallable && } <>
); };