New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@navikt/appstatus-react

Package Overview
Dependencies
Maintainers
25
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@navikt/appstatus-react - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

31

lib/hooks/useGetApplicationStatus.js

@@ -23,2 +23,3 @@ "use strict";

message,
liveUpdate,
name,

@@ -36,2 +37,3 @@ team->{key}

const [applicationTeam, setApplicationTeam] = react_1.useState();
const [liveUpdate, setLiveUpdate] = react_1.useState();
const [isLoading, setIsLoading] = react_1.useState(true);

@@ -50,2 +52,3 @@ const [error, setError] = react_1.useState();

setApplicationTeam((_a = appResult.team) === null || _a === void 0 ? void 0 : _a.key);
setLiveUpdate(appResult.liveUpdate === true);
}

@@ -57,2 +60,3 @@ }

setApplicationTeam(undefined);
setLiveUpdate(false);
}

@@ -73,2 +77,3 @@ finally {

const prevApplicationKey = usePrevious_1.usePrevious(applicationKey);
const prevLiveUpdate = usePrevious_1.usePrevious(liveUpdate);
const stopSubscription = () => {

@@ -85,3 +90,3 @@ if (subscription.current && subscription.current.unsubscribe) {

if (error) {
stopSubscription();
setLiveUpdate(false);
return;

@@ -91,14 +96,24 @@ }

fetch(applicationKey, sanityConfig);
if (!subscription.current) {
startSubscription(applicationKey, sanityConfig);
}
if (applicationKey === undefined) {
setLiveUpdate(false);
}
}, [applicationKey, prevApplicationKey, error, sanityConfig]);
react_1.useEffect(() => {
if (applicationKey &&
(prevLiveUpdate !== liveUpdate || (applicationKey && applicationKey !== prevApplicationKey))) {
if (liveUpdate === true) {
if (!subscription.current) {
startSubscription(applicationKey, sanityConfig);
}
else {
stopSubscription();
startSubscription(applicationKey, sanityConfig);
}
}
else {
stopSubscription();
startSubscription(applicationKey, sanityConfig);
}
}
if (applicationKey === undefined) {
stopSubscription();
}
}, [applicationKey, prevApplicationKey, error, sanityConfig]);
}, [liveUpdate, prevLiveUpdate, applicationKey, prevApplicationKey, sanityConfig]);
react_1.useEffect(() => {

@@ -105,0 +120,0 @@ if (application) {

@@ -21,2 +21,3 @@ "use strict";

teamApplicationStatus,
liveUpdate,
message,

@@ -29,2 +30,3 @@ }`;

const [isLoading, setIsLoading] = react_1.useState(false);
const [liveUpdate, setLiveUpdate] = react_1.useState();
const [error, setError] = react_1.useState();

@@ -42,2 +44,3 @@ const subscription = react_1.useRef();

setMessage(utils_1.getMessage(team.message));
setLiveUpdate(team.liveUpdate === true);
}

@@ -49,2 +52,3 @@ }

setMessage(undefined);
setLiveUpdate(false);
}

@@ -66,3 +70,3 @@ finally {

};
const stopSubscription = () => {
const stopSubscription = (key) => {
if (subscription.current && subscription.current.unsubscribe) {

@@ -73,2 +77,3 @@ subscription.current.unsubscribe();

const prevTeamKey = usePrevious_1.usePrevious(teamKey);
const prevLiveUpdate = usePrevious_1.usePrevious(liveUpdate);
react_1.useEffect(() => {

@@ -80,3 +85,3 @@ if (!utils_1.sanityConfigIsValid(sanityConfig)) {

if (error) {
stopSubscription();
setLiveUpdate(false);
return;

@@ -86,16 +91,25 @@ }

fetch(teamKey, sanityConfig);
if (!subscription.current) {
startSubscription(teamKey, sanityConfig);
}
if (prevTeamKey !== teamKey) {
stopSubscription();
startSubscription(teamKey, sanityConfig);
}
}
if (teamKey === undefined && subscription.current !== undefined) {
stopSubscription();
setLiveUpdate(false);
}
}, [teamKey, prevTeamKey, error, sanityConfig]);
react_1.useEffect(() => {
if (teamKey) {
if (liveUpdate === true) {
if (!subscription.current) {
startSubscription(teamKey, sanityConfig);
}
else {
stopSubscription(teamKey);
startSubscription(teamKey, sanityConfig);
}
}
else {
stopSubscription(teamKey);
}
}
}, [liveUpdate, prevLiveUpdate, teamKey, prevTeamKey, sanityConfig]);
return { status, message, isLoading, error };
}
exports.default = useGetTeamStatus;
{
"name": "@navikt/appstatus-react",
"version": "0.1.1",
"version": "0.1.2",
"private": false,

@@ -5,0 +5,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc