Skip to content

Commit

Permalink
fix: avoid getting the ip each time
Browse files Browse the repository at this point in the history
  • Loading branch information
dubisdev committed Mar 11, 2024
1 parent 6f24b10 commit 6d19960
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions extensions/ip/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ const noInternetItem = new InfoItem({
subtitle: 'You are offline'
});

let ip = '';

const run: ExtensionModule['run'] = async ({ display, actions }) => {
if (navigator.onLine === false) {
return display([noInternetItem]);
}

const ip = await getIp();

const ipItem = new ScriptItem({
title: 'Your IP',
title: 'IP:',
subtitle: ip,
run: async () => {
actions.copyToClipboard(ip);
Expand All @@ -26,6 +26,13 @@ const run: ExtensionModule['run'] = async ({ display, actions }) => {

const IpExtension: ExtensionModule = {
name: 'Ip',
initializeAsync: async (send) => {
const ip = await getIp();
send(ip);
},
onMessage (dataIp) {
ip = dataIp as string;
},
run,
icon: ''
};
Expand Down

0 comments on commit 6d19960

Please sign in to comment.