Skip to content

Commit

Permalink
Release CollapseEmbeds v1.1.0
Browse files Browse the repository at this point in the history
- Update to work with new attachments (#180)
  • Loading branch information
Zerthox committed May 4, 2024
1 parent ff3e85a commit 8092d08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 16 additions & 6 deletions dist/bd/CollapseEmbeds.plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @name CollapseEmbeds
* @version 1.0.6
* @version 1.1.0
* @author Zerthox
* @authorLink https://github.com/Zerthox
* @description Adds a button to collapse embeds & attachments.
Expand Down Expand Up @@ -357,13 +357,14 @@ const Settings = createSettings({
hideByDefault: false
});

const css = ".container-CollapseEmbeds.embed-CollapseEmbeds {\n justify-self: stretch;\n}\n.container-CollapseEmbeds.embed-CollapseEmbeds > article {\n flex-grow: 1;\n flex-shrink: 0;\n}\n\n.placeholder-CollapseEmbeds + .placeholder-CollapseEmbeds {\n margin-left: 4px;\n}\n\n.hideButton-CollapseEmbeds {\n margin-bottom: -4px;\n align-self: flex-end;\n color: var(--interactive-normal);\n cursor: pointer;\n visibility: hidden;\n}\n.hideButton-CollapseEmbeds:hover {\n color: var(--interactive-hover);\n}\n.expanded-CollapseEmbeds > .hideButton-CollapseEmbeds {\n margin-bottom: -6px;\n}\n.hideButton-CollapseEmbeds:hover, :hover + .hideButton-CollapseEmbeds, .collapsed-CollapseEmbeds > .hideButton-CollapseEmbeds {\n visibility: visible;\n}\n\n.icon-CollapseEmbeds {\n margin: -2px;\n transition: transform 0.2s ease-out;\n}\n.icon-CollapseEmbeds.open-CollapseEmbeds {\n transform: rotate(180deg);\n}";
const css = ".container-CollapseEmbeds.embed-CollapseEmbeds {\n justify-self: stretch;\n}\n.container-CollapseEmbeds.embed-CollapseEmbeds > article {\n flex-grow: 1;\n flex-shrink: 0;\n}\n.container-CollapseEmbeds.mediaItem-CollapseEmbeds.expanded-CollapseEmbeds {\n position: relative;\n}\n.container-CollapseEmbeds.mediaItem-CollapseEmbeds.expanded-CollapseEmbeds > .hideButton-CollapseEmbeds {\n position: absolute;\n right: 2px;\n bottom: 2px;\n z-index: 1;\n}\n\n.placeholder-CollapseEmbeds + .placeholder-CollapseEmbeds {\n margin-left: 4px;\n}\n\n.hideButton-CollapseEmbeds {\n margin-bottom: -4px;\n align-self: flex-end;\n color: var(--interactive-normal);\n cursor: pointer;\n visibility: hidden;\n}\n.hideButton-CollapseEmbeds:hover {\n color: var(--interactive-hover);\n}\n.expanded-CollapseEmbeds > .hideButton-CollapseEmbeds {\n margin-bottom: -6px;\n}\n.hideButton-CollapseEmbeds:hover, :hover + .hideButton-CollapseEmbeds, .collapsed-CollapseEmbeds > .hideButton-CollapseEmbeds {\n visibility: visible;\n}\n\n.icon-CollapseEmbeds {\n margin: -2px;\n transition: transform 0.2s ease-out;\n}\n.icon-CollapseEmbeds.open-CollapseEmbeds {\n transform: rotate(180deg);\n}";
const styles = {
container: "container-CollapseEmbeds",
embed: "embed-CollapseEmbeds",
placeholder: "placeholder-CollapseEmbeds",
hideButton: "hideButton-CollapseEmbeds",
mediaItem: "mediaItem-CollapseEmbeds",
expanded: "expanded-CollapseEmbeds",
hideButton: "hideButton-CollapseEmbeds",
placeholder: "placeholder-CollapseEmbeds",
collapsed: "collapsed-CollapseEmbeds",
icon: "icon-CollapseEmbeds",
open: "open-CollapseEmbeds",
Expand All @@ -376,20 +377,29 @@ const Hider = ({ placeholders, type, children }) => {
return (React.createElement(Flex, { align: Flex.Align.CENTER, className: classNames(styles.container, styles[type], shown ? styles.expanded : styles.collapsed) },
shown ? children : placeholders.filter(Boolean).map((placeholder, i) => (React.createElement(Text, { key: i, variant: "text-xs/normal", className: styles.placeholder }, placeholder))),
React.createElement(Clickable, { className: styles.hideButton, onClick: () => setShown(!shown) },
React.createElement(IconArrow, { className: classNames(styles.icon, shown ? styles.open : null) }))));
React.createElement(IconArrow, { color: "currentColor", className: classNames(styles.icon, shown ? styles.open : null) }))));
};

const MediaModule = demangle({
MediaItem: bySource$1("getObscureReason", "useFullWidth")
}, null, true);
const index = createPlugin({
start() {
after(Embed.prototype, "render", ({ result, context }) => {
const { embed } = context.props;
const placeholder = embed.provider?.name ?? embed.author?.name ?? embed.rawTitle ?? new URL(embed.url).hostname;
return (React.createElement(Hider, { type: "embed" , placeholders: [placeholder] }, result));
}, { name: "Embed render" });
after(MediaModule, "MediaItem", ({ args: [props], result }) => {
const attachment = props.item.originalItem;
const placeholder = attachment.filename ?? new URL(attachment.url).hostname;
return (React.createElement(Hider, { type: "mediaItem" , placeholders: [placeholder] }, result));
}, { name: "MediaItem render" });
after(MessageFooter.prototype, "renderAttachments", ({ result }) => {
for (const element of queryTreeAll(result, (node) => node?.props?.attachments)) {
hookFunctionComponent(element, (result, { attachments }) => {
return (React.createElement(Hider, { type: "attachment" , placeholders: attachments.map(({ attachment }) => attachment.filename ?? new URL(attachment.url).hostname) }, result));
const placeholders = attachments.map(({ attachment }) => attachment.filename ?? new URL(attachment.url).hostname);
return (React.createElement(Hider, { type: "attachment" , placeholders: placeholders }, result));
});
}
}, { name: "MessageFooter renderAttachments" });
Expand Down
2 changes: 1 addition & 1 deletion dist/bd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Adds new functionality to server folders. Custom Folder Icons. Close other folde
## [BetterVolume](https://betterdiscord.app/plugin/BetterVolume) <sub><sup>`v2.5.0` *(Updated: 25/09/2023)*</sup></sub>
Set user volume values manually instead of using a slider. Allows setting volumes higher than 200%.

## [CollapseEmbeds](https://betterdiscord.app/plugin/CollapseEmbeds) <sub><sup>`v1.0.6` *(Updated: 06/12/2023)*</sup></sub>
## [CollapseEmbeds](https://betterdiscord.app/plugin/CollapseEmbeds) <sub><sup>`v1.1.0` *(Updated: 04/05/2024)*</sup></sub>
Adds a button to collapse embeds & attachments.

## [OnlineFriendCount](https://betterdiscord.app/plugin/OnlineFriendCount) <sub><sup>`v3.1.4` *(Updated: 02/11/2023)*</sup></sub>
Expand Down

0 comments on commit 8092d08

Please sign in to comment.