mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 19:31:46 +00:00
fix: openToast to toastService
This commit is contained in:
@ -166,13 +166,13 @@ export default createPlugin<
|
|||||||
this.profiles = {};
|
this.profiles = {};
|
||||||
this.connection.onConnections((connection) => {
|
this.connection.onConnections((connection) => {
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
this.api?.openToast(t('plugins.music-together.toast.disconnected'));
|
this.api?.toastService.show(t('plugins.music-together.toast.disconnected'));
|
||||||
this.onStop();
|
this.onStop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connection.open) {
|
if (!connection.open) {
|
||||||
this.api?.openToast(t('plugins.music-together.toast.user-disconnected', {
|
this.api?.toastService.show(t('plugins.music-together.toast.user-disconnected', {
|
||||||
name: this.profiles[connection.peer]?.name
|
name: this.profiles[connection.peer]?.name
|
||||||
}));
|
}));
|
||||||
this.putProfile(connection.peer, undefined);
|
this.putProfile(connection.peer, undefined);
|
||||||
@ -219,7 +219,7 @@ export default createPlugin<
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.api?.openToast(t('plugins.music-together.toast.user-connected', { name: event.payload.profile.name }));
|
this.api?.toastService.show(t('plugins.music-together.toast.user-connected', { name: event.payload.profile.name }));
|
||||||
this.putProfile(conn.peer, event.payload.profile);
|
this.putProfile(conn.peer, event.payload.profile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -307,7 +307,7 @@ export default createPlugin<
|
|||||||
if (!connection) return false;
|
if (!connection) return false;
|
||||||
this.connection.onConnections((connection) => {
|
this.connection.onConnections((connection) => {
|
||||||
if (!connection?.open) {
|
if (!connection?.open) {
|
||||||
this.api?.openToast(t('plugins.music-together.toast.disconnected'));
|
this.api?.toastService.show(t('plugins.music-together.toast.disconnected'));
|
||||||
this.onStop();
|
this.onStop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -381,7 +381,7 @@ export default createPlugin<
|
|||||||
|
|
||||||
const permissionLabel = t(`plugins.music-together.menu.permission.${this.permission}`);
|
const permissionLabel = t(`plugins.music-together.menu.permission.${this.permission}`);
|
||||||
|
|
||||||
this.api?.openToast(t('plugins.music-together.toast.permission-changed', { permission: permissionLabel }));
|
this.api?.toastService.show(t('plugins.music-together.toast.permission-changed', { permission: permissionLabel }));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -593,18 +593,18 @@ export default createPlugin<
|
|||||||
onItemClick: (id) => {
|
onItemClick: (id) => {
|
||||||
if (id === 'music-together-close') {
|
if (id === 'music-together-close') {
|
||||||
this.onStop();
|
this.onStop();
|
||||||
this.api?.openToast(t('plugins.music-together.toast.closed'));
|
this.api?.toastService.show(t('plugins.music-together.toast.closed'));
|
||||||
hostPopup.dismiss();
|
hostPopup.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id === 'music-together-copy-id') {
|
if (id === 'music-together-copy-id') {
|
||||||
navigator.clipboard.writeText(this.connection?.id ?? '')
|
navigator.clipboard.writeText(this.connection?.id ?? '')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.api?.openToast(t('plugins.music-together.toast.id-copied'));
|
this.api?.toastService.show(t('plugins.music-together.toast.id-copied'));
|
||||||
hostPopup.dismiss();
|
hostPopup.dismiss();
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.api?.openToast(t('plugins.music-together.toast.id-copy-failed'));
|
this.api?.toastService.show(t('plugins.music-together.toast.id-copy-failed'));
|
||||||
hostPopup.dismiss();
|
hostPopup.dismiss();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -620,7 +620,7 @@ export default createPlugin<
|
|||||||
settingPopup.setPermission(this.permission);
|
settingPopup.setPermission(this.permission);
|
||||||
|
|
||||||
const permissionLabel = t(`plugins.music-together.menu.permission.${this.permission}`);
|
const permissionLabel = t(`plugins.music-together.menu.permission.${this.permission}`);
|
||||||
this.api?.openToast(t('plugins.music-together.toast.permission-changed', { permission: permissionLabel }));
|
this.api?.toastService.show(t('plugins.music-together.toast.permission-changed', { permission: permissionLabel }));
|
||||||
const item = hostPopup.items.find((it) => it?.element.id === id);
|
const item = hostPopup.items.find((it) => it?.element.id === id);
|
||||||
if (item?.type === 'item') {
|
if (item?.type === 'item') {
|
||||||
item.setText(t('plugins.music-together.menu.set-permission'));
|
item.setText(t('plugins.music-together.menu.set-permission'));
|
||||||
@ -632,7 +632,7 @@ export default createPlugin<
|
|||||||
onItemClick: (id) => {
|
onItemClick: (id) => {
|
||||||
if (id === 'music-together-disconnect') {
|
if (id === 'music-together-disconnect') {
|
||||||
this.onStop();
|
this.onStop();
|
||||||
this.api?.openToast(t('plugins.music-together.toast.disconnected'));
|
this.api?.toastService.show(t('plugins.music-together.toast.disconnected'));
|
||||||
guestPopup.dismiss();
|
guestPopup.dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -648,14 +648,14 @@ export default createPlugin<
|
|||||||
if (result) {
|
if (result) {
|
||||||
navigator.clipboard.writeText(this.connection?.id ?? '')
|
navigator.clipboard.writeText(this.connection?.id ?? '')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.api?.openToast(t('plugins.music-together.toast.id-copied'));
|
this.api?.toastService.show(t('plugins.music-together.toast.id-copied'));
|
||||||
hostPopup.showAtAnchor(setting);
|
hostPopup.showAtAnchor(setting);
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.api?.openToast(t('plugins.music-together.toast.id-copy-failed'));
|
this.api?.toastService.show(t('plugins.music-together.toast.id-copy-failed'));
|
||||||
hostPopup.showAtAnchor(setting);
|
hostPopup.showAtAnchor(setting);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.api?.openToast(t('plugins.music-together.toast.host-failed'));
|
this.api?.toastService.show(t('plugins.music-together.toast.host-failed'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,10 +666,10 @@ export default createPlugin<
|
|||||||
this.hideSpinner();
|
this.hideSpinner();
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
this.api?.openToast(t('plugins.music-together.toast.joined'));
|
this.api?.toastService.show(t('plugins.music-together.toast.joined'));
|
||||||
guestPopup.showAtAnchor(setting);
|
guestPopup.showAtAnchor(setting);
|
||||||
} else {
|
} else {
|
||||||
this.api?.openToast(t('plugins.music-together.toast.join-failed'));
|
this.api?.toastService.show(t('plugins.music-together.toast.join-failed'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,11 +30,39 @@ export type QueueAPI = {
|
|||||||
continuation?: string;
|
continuation?: string;
|
||||||
autoPlaying?: boolean;
|
autoPlaying?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ToastElement = HTMLElement & {
|
||||||
|
autoFitOnAttach: boolean;
|
||||||
|
duration: number;
|
||||||
|
expandSizingTargetForScrollbars: boolean;
|
||||||
|
horizontalAlign: 'left' | 'right' | 'center';
|
||||||
|
importPath?: unknown;
|
||||||
|
label: string;
|
||||||
|
noAutoFocus: boolean;
|
||||||
|
noCancelOnEscKey: boolean;
|
||||||
|
noCancelOnOutsideClick: boolean;
|
||||||
|
noIronAnnounce: boolean;
|
||||||
|
restoreFocusOnClose: boolean;
|
||||||
|
root: ToastElement;
|
||||||
|
rootPath: string;
|
||||||
|
sizingTarget: ToastElement;
|
||||||
|
verticalAlign: 'bottom' | 'top' | 'center';
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface ToastService {
|
||||||
|
attached: boolean;
|
||||||
|
displaying: boolean;
|
||||||
|
messageQueue: string[];
|
||||||
|
toastElement: ToastElement;
|
||||||
|
show: (message: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
export type AppElement = HTMLElement & AppAPI;
|
export type AppElement = HTMLElement & AppAPI;
|
||||||
export type AppAPI = {
|
export type AppAPI = {
|
||||||
queue_: QueueAPI;
|
queue: QueueAPI;
|
||||||
playerApi_: YoutubePlayer;
|
playerApi: YoutubePlayer;
|
||||||
openToast: (message: string) => void;
|
|
||||||
|
toastService: ToastService;
|
||||||
|
|
||||||
// TODO: Add more
|
// TODO: Add more
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user