Skip to content

Commit

Permalink
fix: display offline hosted only for third party features
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Jan 7, 2022
1 parent 713be82 commit 4c8d593
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FunctionComponent } from "preact";
import { SNComponent } from "@standardnotes/snjs";
import { ComponentArea } from "@standardnotes/features";
import { PreferencesSegment, SubtitleLight, Title } from "@/preferences/components";
import { Switch } from "@/components/Switch";
import { WebApplication } from "@/ui_models/application";
Expand All @@ -27,28 +26,10 @@ export interface ExtensionItemProps {
}

export const ExtensionItem: FunctionComponent<ExtensionItemProps> =
({ application, extension, first, uninstall, toggleActivate, latestVersion }) => {
const [autoupdateDisabled, setAutoupdateDisabled] = useState(extension.autoupdateDisabled ?? false);
({ application, extension, first, uninstall}) => {
const [offlineOnly, setOfflineOnly] = useState(extension.offlineOnly ?? false);
const [extensionName, setExtensionName] = useState(extension.name);

const toggleAutoupdate = () => {
const newAutoupdateValue = !autoupdateDisabled;
setAutoupdateDisabled(newAutoupdateValue);
application
.changeAndSaveItem(extension.uuid, (m: any) => {
if (m.content == undefined) m.content = {};
m.content.autoupdateDisabled = newAutoupdateValue;
})
.then((item) => {
const component = (item as SNComponent);
setAutoupdateDisabled(component.autoupdateDisabled);
})
.catch(e => {
console.error(e);
});
};

const toggleOffllineOnly = () => {
const newOfflineOnly = !offlineOnly;
setOfflineOnly(newOfflineOnly);
Expand Down Expand Up @@ -80,6 +61,7 @@ export const ExtensionItem: FunctionComponent<ExtensionItemProps> =
};

const localInstallable = extension.package_info.download_url;
const isThirParty = application.isThirdPartyFeature(extension.identifier);

return (
<PreferencesSegment classes={'mb-5'}>
Expand All @@ -91,7 +73,7 @@ export const ExtensionItem: FunctionComponent<ExtensionItemProps> =
<RenameExtension extensionName={extensionName} changeName={changeExtensionName} />
<div className="min-h-2" />

{localInstallable && <UseHosted offlineOnly={offlineOnly} toggleOfllineOnly={toggleOffllineOnly} />}
{isThirParty && localInstallable && <UseHosted offlineOnly={offlineOnly} toggleOfllineOnly={toggleOffllineOnly} />}

<>
<div className="min-h-2" />
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@reach/tooltip": "^0.16.2",
"@standardnotes/features": "1.20.5",
"@standardnotes/sncrypto-web": "1.5.3",
"@standardnotes/snjs": "2.34.1",
"@standardnotes/snjs": "2.34.2",
"mobx": "^6.3.5",
"mobx-react-lite": "^3.2.2",
"preact": "^10.5.15",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2655,10 +2655,10 @@
buffer "^6.0.3"
libsodium-wrappers "^0.7.9"

"@standardnotes/[email protected].1":
version "2.34.1"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.34.1.tgz#d65ccc52ef316019f3461205d472ba0a1ba4164c"
integrity sha512-4IZ0b7G4Pp8zzrcacePQttm7LCF9vROL42BBALUrOIRDB6L22s978jM9bGYGIveI0FJI3mRnW4i1pXnoJzrqLA==
"@standardnotes/[email protected].2":
version "2.34.2"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.34.2.tgz#540f32252083f99ee635b900cc70aa19ed68e1f2"
integrity sha512-JhhjAQ66sSHTnGSgTY5VSJU7Lv9fnX0X+SR/pPPi0Kv3gk+aqVi2Zmgf8htmigJSFtrmn2pXGSaJk1v92LFckw==
dependencies:
"@standardnotes/auth" "3.8.1"
"@standardnotes/common" "1.2.1"
Expand Down

0 comments on commit 4c8d593

Please sign in to comment.