Skip to content

Commit

Permalink
fix(InstanceTicker): リモートサーバーのアイコンが初期画像になる問題 (misskey-dev#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyme authored May 2, 2024
1 parent b173f77 commit 7c9c175
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/frontend/src/components/TmsInstanceTicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import { type tmsStore } from '@/tms/store.js';
export type TickerProps = {
readonly instance?: {
readonly name?: string | null;
readonly iconUrl?: string | null;
// NOTE: リモートサーバーにおいてiconUrlを参照すると意図した画像にならない https://github.com/taiyme/misskey/issues/210
// readonly iconUrl?: string | null;
readonly faviconUrl?: string | null;
readonly themeColor?: string | null;
} | null;
Expand Down
11 changes: 4 additions & 7 deletions packages/frontend/src/scripts/tms/instance-ticker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,24 @@ export const getTickerInfo = (props: TickerProps): TickerInfo => {
if (props.channel != null) {
return {
name: props.channel.name,
iconUrl: getProxiedIconUrl(localInstance) ?? '/favicon.ico',
iconUrl: getProxiedImageUrlNullable(localInstance.iconUrl, 'preview') ?? '/favicon.ico',
themeColor: props.channel.color,
} as const satisfies TickerInfo;
}
if (props.instance != null) {
return {
name: props.instance.name ?? '',
iconUrl: getProxiedIconUrl(props.instance) ?? '/client-assets/dummy.png',
// NOTE: リモートサーバーにおいてiconUrlを参照すると意図した画像にならない https://github.com/taiyme/misskey/issues/210
iconUrl: getProxiedImageUrlNullable(props.instance.faviconUrl, 'preview') ?? '/client-assets/dummy.png',
themeColor: props.instance.themeColor ?? TICKER_BG_COLOR_DEFAULT,
} as const satisfies TickerInfo;
}
return {
name: localInstance.name ?? host,
iconUrl: getProxiedIconUrl(localInstance) ?? '/favicon.ico',
iconUrl: getProxiedImageUrlNullable(localInstance.iconUrl, 'preview') ?? '/favicon.ico',
themeColor: localInstance.themeColor ?? document.querySelector<HTMLMetaElement>('meta[name="theme-color-orig"]')?.content ?? TICKER_BG_COLOR_DEFAULT,
} as const satisfies TickerInfo;
};

const getProxiedIconUrl = (instance: NonNullable<TickerProps['instance']>): string | null => {
return getProxiedImageUrlNullable(instance.iconUrl, 'preview') ?? getProxiedImageUrlNullable(instance.faviconUrl, 'preview') ?? null;
};
//#endregion ticker info

//#region ticker colors
Expand Down

0 comments on commit 7c9c175

Please sign in to comment.