forked from Hoishin/social-media-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Confirmation dialog * feat: Disable submit on empty content * feat: Quotes * feat: Limit file number * feat: Template
- Loading branch information
Showing
11 changed files
with
543 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { env } from "../env.server"; | ||
|
||
export interface Run { | ||
id: number; | ||
gamename: string; | ||
category: string; | ||
runner: { | ||
username: string; | ||
twitterid: string; | ||
}[]; | ||
commentary: { | ||
username: string; | ||
twitterid: string; | ||
}[]; | ||
} | ||
|
||
export const getRuns = async (): Promise<Run[]> => { | ||
const apiUrl = env.RUNDATA_API_URL; | ||
if (!apiUrl) { | ||
return []; | ||
} | ||
|
||
try { | ||
const response = await fetch(apiUrl); | ||
|
||
if (!response.ok) { | ||
console.error("Failed to load runs"); | ||
return []; | ||
} | ||
const json = (await response.json()) as { data: Run[] }; | ||
return json.data; | ||
} catch (e) { | ||
console.error(e); | ||
return []; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { create } from "zustand"; | ||
|
||
export const useQuoteStore = create<{ | ||
twitterId?: string; | ||
blueskyId?: string; | ||
setQuote: (args: { twitterId?: string; blueskyId?: string }) => void; | ||
clearQuote: () => void; | ||
}>((set) => ({ | ||
setQuote: ({ twitterId, blueskyId }) => { | ||
set({ twitterId, blueskyId }); | ||
}, | ||
clearQuote: () => { | ||
set({ twitterId: undefined, blueskyId: undefined }); | ||
}, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import type { Run } from "../../api/runs.server"; | ||
|
||
interface Template { | ||
label: | ||
| "setup" | ||
| "finishWithTime" | ||
| "finishWithoutTime" | ||
| "finishOnlyTime" | ||
| "running" | ||
| "backup"; | ||
apply: (run: Run) => string; | ||
} | ||
|
||
const presentRunners = (runners: Run["runner"]) => { | ||
return runners | ||
.map((runner) => { | ||
const name = runner.username.replaceAll("@", "@ "); | ||
return `${name}さん(@${runner.twitterid})`; | ||
}) | ||
.join("、"); | ||
}; | ||
|
||
export const templates: Template[] = [ | ||
{ | ||
label: "setup", | ||
apply: (run) => | ||
`次のタイムアタックは『${run.gamename}』\nカテゴリーは「${ | ||
run.category | ||
}」\n走者は${presentRunners( | ||
run.runner | ||
)}です。\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`, | ||
}, | ||
{ | ||
label: "finishWithTime", | ||
apply: (run) => | ||
`『${run.gamename}』のカテゴリー「${ | ||
run.category | ||
}」RTA\n走者の${presentRunners( | ||
run.runner | ||
)}お疲れさまでした。\nクリアタイムはxx:xx:xxでした。\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`, | ||
}, | ||
{ | ||
label: "finishWithoutTime", | ||
apply: (run) => | ||
`『${run.gamename}』のカテゴリー「${ | ||
run.category | ||
}」RTA\n走者の${presentRunners( | ||
run.runner | ||
)}お疲れさまでした。\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`, | ||
}, | ||
{ | ||
label: "finishOnlyTime", | ||
apply: (run) => | ||
`『${run.gamename}』\nクリアタイムは次の通りです\n\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`, | ||
}, | ||
{ | ||
label: "running", | ||
apply: (run) => | ||
`現在のタイムアタックは『${run.gamename}』\n\n\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`, | ||
}, | ||
{ | ||
label: "backup", | ||
apply: (run) => | ||
`【バックアップ追加のお知らせ】\n「xxx」の終了後、バックアップとして『${run.gamename}』を追加いたします。\n\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`, | ||
}, | ||
] as const; |
Oops, something went wrong.