Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update macrumors extension #16707

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hughmcmillanv
Copy link
Contributor

@hughmcmillanv hughmcmillanv commented Jan 30, 2025

Description

Screencast

Checklist

- Merge branch \'contributions/merge-1738208931245\'
- Pull contributions
- Edit Markdown and JSON
- Revise export default function and clean up
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: macrumors Issues related to the macrumors extension OP is author The OP of the PR is the author of the extension labels Jan 30, 2025
@raycastbot
Copy link
Collaborator

Thank you for the update! 🎉

You can expect an initial review within five business days.

Copy link
Collaborator

@pernielsentikaer pernielsentikaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update 🔥

I tweaked the script a bit, I think it will work much better and faster this way 😊

import { Action, ActionPanel, List } from "@raycast/api";
import { useCachedPromise } from "@raycast/utils";
import { getIcon, getPubDate } from "./utils";
import Parser from "rss-parser";

export default function Command() {
  const { data, isLoading } = useCachedPromise(async () => {
    const parser = new Parser();
    const feed = await parser.parseURL("https://feeds.macrumors.com/MacRumors-All");
    return { items: feed.items };
  });

  return (
    <List isLoading={isLoading}>
      {data?.items?.map((item, index) => <StoryListItem key={item.guid} item={item} index={index} />)}
    </List>
  );
}

function StoryListItem(props: { item: Parser.Item; index: number }) {
  const icon = getIcon(props.index + 1);
  const pubDate = new Date(getPubDate(props.item) ?? "");

  return (
    <List.Item
      icon={icon}
      title={props.item.title ?? "No title"}
      subtitle={props.item.creator ?? "No author"}
      accessories={[{ date: pubDate }]}
      actions={<Actions item={props.item} />}
    />
  );
}

function Actions(props: { item: Parser.Item }) {
  return (
    <ActionPanel title={props.item.title}>
      <ActionPanel.Section>{props.item.link && <Action.OpenInBrowser url={props.item.link} />}</ActionPanel.Section>
      <ActionPanel.Section>
        {props.item.link && (
          <Action.CopyToClipboard
            content={props.item.link}
            title="Copy Article Link"
            shortcut={{ modifiers: ["cmd"], key: "." }}
          />
        )}
      </ActionPanel.Section>
    </ActionPanel>
  );
}

@pernielsentikaer pernielsentikaer self-assigned this Jan 30, 2025
@hughmcmillanv
Copy link
Contributor Author

Your requested changes to the "macrumors.tsx" file have been incorporated. Thank you very much for your tweaks. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension fix / improvement Label for PRs with extension's fix improvements extension: macrumors Issues related to the macrumors extension OP is author The OP of the PR is the author of the extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants