mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 15:35:11 +00:00
make copyWithToast use error style on error
This commit is contained in:
parent
28efdef3a0
commit
1693273f8b
1 changed files with 8 additions and 4 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Clipboard, Toasts } from "@webpack/common";
|
import { Clipboard, ToastData, Toasts } from "@webpack/common";
|
||||||
|
|
||||||
import { DevsById } from "./constants";
|
import { DevsById } from "./constants";
|
||||||
|
|
||||||
|
@ -36,15 +36,19 @@ export function sleep(ms: number): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function copyWithToast(text: string, toastMessage = "Copied to clipboard!") {
|
export function copyWithToast(text: string, toastMessage = "Copied to clipboard!") {
|
||||||
|
const opts: Pick<ToastData, "type" | "message"> = {
|
||||||
|
message: toastMessage,
|
||||||
|
type: Toasts.Type.SUCCESS
|
||||||
|
};
|
||||||
if (Clipboard.SUPPORTS_COPY) {
|
if (Clipboard.SUPPORTS_COPY) {
|
||||||
Clipboard.copy(text);
|
Clipboard.copy(text);
|
||||||
} else {
|
} else {
|
||||||
toastMessage = "Your browser does not support copying to clipboard";
|
opts.message = "Your browser does not support copying to clipboard";
|
||||||
|
opts.type = Toasts.Type.FAILURE;
|
||||||
}
|
}
|
||||||
Toasts.show({
|
Toasts.show({
|
||||||
message: toastMessage,
|
|
||||||
id: Toasts.genId(),
|
id: Toasts.genId(),
|
||||||
type: Toasts.Type.SUCCESS
|
...opts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue