Skip to content

Commit

Permalink
Update remember-the-date extension (#14151)
Browse files Browse the repository at this point in the history
* Update remember-the-date extension

- Add new command
- Initial commit

* Update CHANGELOG.md and optimise images

---------

Co-authored-by: raycastbot <bot@raycast.com>
  • Loading branch information
samuelkraft and raycastbot committed Aug 25, 2024
1 parent b9b1257 commit c08fd92
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 8 deletions.
5 changes: 5 additions & 0 deletions extensions/remember-the-date/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Remember the Date Changelog

## [Add Up Next command] - 2024-04-19

- Added "Up Next" Command perfect for pinning as a favorite
- Update command icon

## [Add Menu Bar Command] - 2024-04-19

- Added Menu Bar Command that shows the next upcoming event
Expand Down
Binary file added extensions/remember-the-date/assets/add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed extensions/remember-the-date/assets/countdown.png
Binary file not shown.
Binary file added extensions/remember-the-date/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions extensions/remember-the-date/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "remember-the-date",
"title": "Remember the Date",
"description": "Creates and shows the most important date which should be remembered.",
"icon": "countdown.png",
"icon": "icon.png",
"author": "pernielsentikaer",
"contributors": [
"samuelkraft"
Expand All @@ -21,7 +21,8 @@
"title": "Create Date",
"subtitle": "Remember the Date",
"description": "Create new date to remember",
"mode": "view"
"mode": "view",
"icon": "add.png"
},
{
"name": "list",
Expand All @@ -36,6 +37,13 @@
"description": "List of all dates to remember in the menu bar",
"mode": "menu-bar",
"interval": "1d"
},
{
"name": "up-next",
"title": "Up Next",
"description": "Show the next date to remember",
"mode": "no-view",
"interval": "1d"
}
],
"preferences": [
Expand Down
4 changes: 2 additions & 2 deletions extensions/remember-the-date/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Form, ActionPanel, Action, showToast, Icon, Color, popToRoot } from "@r
import { Item } from "./types";
import { getItems, saveItems } from "./storage";
import { nanoid } from "nanoid";
import { refreshMenuBar, validateItem } from "./utils";
import { refreshCommands, validateItem } from "./utils";
import { useCachedPromise } from "@raycast/utils";
import { getFormattedList } from "./list";

Expand All @@ -17,7 +17,7 @@ export default function Command() {
popToRoot();
await saveItems(existingItems);
await mutate(getFormattedList());
await refreshMenuBar();
await refreshCommands();
showToast({ title: "Success", message: "Successfully added item" });
}
}
Expand Down
6 changes: 3 additions & 3 deletions extensions/remember-the-date/src/list.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { List, ActionPanel, Action, Icon, getPreferenceValues, confirmAlert, Alert } from "@raycast/api";
import moment from "moment";
import { refreshMenuBar, pluralize } from "./utils";
import { refreshCommands, pluralize } from "./utils";
import { Item, ListItems, Preferences } from "./types";
import { EditForm } from "./editForm";
import { getItems, saveItems } from "./storage";
Expand All @@ -16,7 +16,7 @@ export default function Command() {

await saveItems(items);
await mutate(getFormattedList());
await refreshMenuBar();
await refreshCommands();
}

async function removeItem(item: Item) {
Expand All @@ -25,7 +25,7 @@ export default function Command() {

await saveItems(items);
await mutate(getFormattedList());
await refreshMenuBar();
await refreshCommands();
}

return (
Expand Down
21 changes: 21 additions & 0 deletions extensions/remember-the-date/src/up-next.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { updateCommandMetadata } from "@raycast/api";
import { getFormattedList } from "./list";
import moment from "moment";

export default async function UpNext() {
const datesList = await getFormattedList();
const nextDate = datesList[0]?.items?.[0];

let subtitle = "No upcoming dates";

if (nextDate) {
const untilNextDate = `${
nextDate.name.length > 15 ? nextDate.name.substring(0, 15) + "..." : nextDate.name
} ${moment(nextDate.date).fromNow()}`;
subtitle = untilNextDate;
}

updateCommandMetadata({
subtitle,
});
}
9 changes: 8 additions & 1 deletion extensions/remember-the-date/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ export function validateItem(item: Item) {
return true;
}

export async function refreshMenuBar() {
export async function refreshCommands() {
try {
await launchCommand({ name: "menu-bar", type: LaunchType.Background });
} catch (e) {
() => {
console.error("An error occurred while updating the menu bar", e);
};
}
try {
await launchCommand({ name: "up-next", type: LaunchType.Background });
} catch (e) {
() => {
console.error("An error occurred while updating the up-next command", e);
};
}
}

0 comments on commit c08fd92

Please sign in to comment.