Skip to content

Commit

Permalink
Update LaunchAgents extension (raycast#14157)
Browse files Browse the repository at this point in the history
* Update LaunchAgents extension

Scenario: empty list
Action: Create launch agent
Result: LaunchAgent created but list not refreshed
Expected: Launch agente created and list updated to see the newly created

* Update CHANGELOG.md and optimise images

---------

Co-authored-by: raycastbot <[email protected]>
  • Loading branch information
stevensd2m and raycastbot authored Aug 25, 2024
1 parent 75a41f1 commit cc1bffe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions extensions/launch-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Launch Agents Extension Changelog

## [LaunchAgent creation on empty list refreshes the list] - 2024-08-25

## [Guarantee that the user launch agents folder exists] - 2024-08-22

## [Initial Version] - 2024-08-16
14 changes: 8 additions & 6 deletions extensions/launch-agents/components/LaunchAgentList.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Action, ActionPanel, Color, Icon, List } from "@raycast/api";
import { execSync } from "child_process";
import { useEffect, useState } from "react";
import { createLaunchAgent } from "../lib/plist";
import { createLaunchAgent as createLaunchAgentCommand } from "../lib/plist";
import { getFileName } from "../lib/utils";
import LaunchAgentDetails from "./LaunchAgentDetails";

const EmptyView = () => (
const EmptyView = ({ loadLaunchAgentsFiles }: { loadLaunchAgentsFiles: () => void }) => (
<List.EmptyView
icon={Icon.Multiply}
title="No Launch Agents found"
Expand All @@ -14,7 +14,10 @@ const EmptyView = () => (
<Action
icon={{ source: Icon.NewDocument, tintColor: Color.Green }}
title="Create Launch Agent"
onAction={createLaunchAgent}
onAction={() => {
createLaunchAgentCommand();
loadLaunchAgentsFiles();
}}
/>
</ActionPanel>
}
Expand All @@ -40,8 +43,7 @@ export default function LaunchAgentList() {
};

const createLaunchAgent = () => {
const fileName = `com.raycast.${Math.random()}`;
execSync(`touch ~/Library/LaunchAgents/${fileName}.plist`);
createLaunchAgentCommand();
loadLaunchAgentsFiles();
};

Expand All @@ -52,7 +54,7 @@ export default function LaunchAgentList() {

return (
<List navigationTitle="Search Launch Agents" searchBarPlaceholder="Search your Launch Agent" isLoading={isLoading}>
<EmptyView />
<EmptyView loadLaunchAgentsFiles={loadLaunchAgentsFiles} />
{launchAgentsFiles.map((file, index) => (
<List.Item
key={index}
Expand Down

0 comments on commit cc1bffe

Please sign in to comment.