mirror of
https://github.com/Sevichecc/raycast-akkoma-extension.git
synced 2025-04-30 22:49:30 +08:00
feat: add view my status command
This commit is contained in:
parent
54a6188bc5
commit
0a9f549bda
5 changed files with 19 additions and 10 deletions
|
@ -36,9 +36,9 @@ export default function BookmarkCommand() {
|
||||||
<List isShowingDetail isLoading={isLoading} searchBarPlaceholder="Search bookmarks">
|
<List isShowingDetail isLoading={isLoading} searchBarPlaceholder="Search bookmarks">
|
||||||
{bookmarks?.map((bookmark) => (
|
{bookmarks?.map((bookmark) => (
|
||||||
<List.Item
|
<List.Item
|
||||||
title={bookmark.pleroma.content["text/plain"]}
|
title={bookmark.pleroma.content["text/plain"] || bookmark.akkoma.source.content}
|
||||||
key={bookmark.id}
|
key={bookmark.id}
|
||||||
detail={<List.Item.Detail markdown={statusParser(bookmark)} />}
|
detail={<List.Item.Detail markdown={statusParser(bookmark, "idAndDate")} />}
|
||||||
actions={
|
actions={
|
||||||
<ActionPanel>
|
<ActionPanel>
|
||||||
<Action.OpenInBrowser title="Open Original Status" url={bookmark.url} />
|
<Action.OpenInBrowser title="Open Original Status" url={bookmark.url} />
|
||||||
|
|
|
@ -36,9 +36,9 @@ export default function ViewStatusCommand() {
|
||||||
<List isShowingDetail isLoading={isLoading} searchBarPlaceholder="Search bookmarks">
|
<List isShowingDetail isLoading={isLoading} searchBarPlaceholder="Search bookmarks">
|
||||||
{status?.map((statu) => (
|
{status?.map((statu) => (
|
||||||
<List.Item
|
<List.Item
|
||||||
title={statu.pleroma.content["text/plain"]}
|
title={statu.akkoma.source.content}
|
||||||
key={statu.id}
|
key={statu.id}
|
||||||
detail={<List.Item.Detail markdown={statusParser(statu)} />}
|
detail={<List.Item.Detail markdown={statusParser(statu, "date")} />}
|
||||||
actions={
|
actions={
|
||||||
<ActionPanel>
|
<ActionPanel>
|
||||||
<Action.OpenInBrowser title="Open Original Status" url={statu.url} />
|
<Action.OpenInBrowser title="Open Original Status" url={statu.url} />
|
||||||
|
|
|
@ -21,7 +21,7 @@ const CONFIG = {
|
||||||
tokenUrl: "/oauth/token",
|
tokenUrl: "/oauth/token",
|
||||||
appUrl: "/api/v1/apps",
|
appUrl: "/api/v1/apps",
|
||||||
statusesUrl: "/api/v1/statuses",
|
statusesUrl: "/api/v1/statuses",
|
||||||
accountsUrl: "/api/v1/accounts",
|
accountsUrl: "/api/v1/accounts/",
|
||||||
verifyCredentialsUrl: "/api/v1/accounts/verify_credentials",
|
verifyCredentialsUrl: "/api/v1/accounts/verify_credentials",
|
||||||
mediaUrl: "/api/v1/media/",
|
mediaUrl: "/api/v1/media/",
|
||||||
bookmarkUrl: "/api/v1/bookmarks",
|
bookmarkUrl: "/api/v1/bookmarks",
|
||||||
|
|
|
@ -64,6 +64,12 @@ export interface StatusRequest {
|
||||||
export interface Status {
|
export interface Status {
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
media_attachments: UploadAttachResponse[];
|
media_attachments: UploadAttachResponse[];
|
||||||
|
akkoma: {
|
||||||
|
source: {
|
||||||
|
content: string;
|
||||||
|
mediaType: "text/markdown" | "text/plain" | "text/bbcode" | "text/html" | "x.misskeymarkdown";
|
||||||
|
};
|
||||||
|
};
|
||||||
account: {
|
account: {
|
||||||
acct: string;
|
acct: string;
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,14 +21,17 @@ export const dateTimeFormatter = (time: Date, type: "short" | "long") => {
|
||||||
}).format(time);
|
}).format(time);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const statusParser = ({ content, media_attachments, account, created_at }: Status) => {
|
export const statusParser = (
|
||||||
|
{ content, media_attachments, account, created_at }: Status,
|
||||||
|
type: "idAndDate" | "date"
|
||||||
|
) => {
|
||||||
const images = media_attachments.filter((attachment) => attachment.type === "image");
|
const images = media_attachments.filter((attachment) => attachment.type === "image");
|
||||||
const parsedImages = images.reduce((link, image) => link + ``, "");
|
const parsedImages = images.reduce((link, image) => link + ``, "");
|
||||||
|
|
||||||
const date = new Date(created_at);
|
const date = new Date(created_at);
|
||||||
const parsedTime = dateTimeFormatter(date, "short");
|
const parsedTime = dateTimeFormatter(date, "short");
|
||||||
|
|
||||||
if (account) return ` _@${account.acct} (${parsedTime})_ ` + nhm.translate("<br>" + content) + parsedImages;
|
return type === "idAndDate"
|
||||||
|
? ` _@${account.acct} (${parsedTime})_ ` + nhm.translate("<br>" + content) + parsedImages
|
||||||
return parsedTime + nhm.translate("<br>" + content) + parsedImages;
|
: `_${parsedTime}_` + nhm.translate("<br>" + content) + parsedImages;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue