generated from moonlight-mod/sample-extension
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1f0be2
commit dac0edb
Showing
7 changed files
with
58 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ExtensionWebpackModule } from "@moonlight-mod/types"; | ||
|
||
export const webpackModules: Record<string, ExtensionWebpackModule> = { | ||
dmDates: { | ||
entrypoint: true, | ||
dependencies: [ | ||
{ id: "react" }, | ||
{ id: "discord/components/common/index" }, | ||
{ ext: "spacepack", id: "spacepack" }, | ||
{ ext: "componentEditor", id: "dmList" }, | ||
moonlight.enabledExtensions.has("dmFavorites") && { ext: "dmFavorites", id: "icon" } | ||
].filter((d) => !!d) | ||
} | ||
}; |
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,14 @@ | ||
{ | ||
"$schema": "https://moonlight-mod.github.io/manifest.schema.json", | ||
"id": "dmDates", | ||
"version": "1.0.0", | ||
"meta": { | ||
"name": "DM Dates", | ||
"tagline": "Implements dates next to direct messages like mobile", | ||
"authors": ["Cynosphere"], | ||
"tags": ["chat", "qol"], | ||
"source": "https://github.com/Cynosphere/moonlight-extensions" | ||
}, | ||
"dependencies": ["spacepack", "componentEditor"], | ||
"apiLevel": 2 | ||
} |
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,3 @@ | ||
.dmDate-date { | ||
margin-right: 4px; | ||
} |
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,21 @@ | ||
import React from "@moonlight-mod/wp/react"; | ||
import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; | ||
import DMList from "@moonlight-mod/wp/componentEditor_dmList"; | ||
import { Text } from "@moonlight-mod/wp/discord/components/common/index"; | ||
|
||
const getTimestampString = spacepack.findByCode('["XIGt+f"]')[0].exports; | ||
const getAbbreviatedFormatter = spacepack.findFunctionByStrings(getTimestampString, '["XIGt+f"]'); | ||
const SnowflakeUtils = spacepack.require("discord/utils/SnowflakeUtils").default; | ||
|
||
function DMDate({ channel }: { channel: any }) { | ||
const lastMessage = SnowflakeUtils.extractTimestamp(channel.lastMessageId ?? channel.id); | ||
const formattedTime = getTimestampString.ZP({ since: lastMessage, getFormatter: getAbbreviatedFormatter }); | ||
|
||
return ( | ||
<Text variant="text-xxs/normal" color="currentColor" className="dmDates-date"> | ||
{formattedTime} | ||
</Text> | ||
); | ||
} | ||
|
||
DMList.addItem("dmDates", DMDate, "close-button", true); |
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,3 @@ | ||
.dmFavorites-icon { | ||
margin-right: 4px; | ||
} |
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import React from "@moonlight-mod/wp/react"; | ||
import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; | ||
import { UserGuildSettingsStore } from "@moonlight-mod/wp/common_stores"; | ||
import DMList from "@moonlight-mod/wp/componentEditor_dmList"; | ||
|
||
const DMList = spacepack.require("componentEditor_dmList").default; | ||
const { StarIcon } = spacepack.require("discord/components/common/index"); | ||
|
||
function FavoritedIcon(props: any) { | ||
const id = props.channel.id; | ||
const override = UserGuildSettingsStore.getChannelOverrides("null")[id] ?? {}; | ||
const isFavorite = (override.flags & 2048) !== 0; | ||
|
||
return isFavorite ? <StarIcon color="currentColor" size="xxs" style={{ marginRight: "8px" }} /> : null; | ||
return isFavorite ? <StarIcon color="currentColor" size="xxs" className="dmFavorites-icon" /> : null; | ||
} | ||
|
||
DMList.addItem("dmFavorites", FavoritedIcon, "close-button", true); |