Skip to content

Commit

Permalink
fix(frontend-embed): URLエンコードされた文字列が正常に読み込めない問題を修正 (misskey-dev#14630)
Browse files Browse the repository at this point in the history
* fix(frontend-embed): URLエンコードされた文字列が正常に読み込めない問題を修正

* fix(frontend-embed): bring back missing bits
  • Loading branch information
kakkokari-gtyih authored and HotoRas committed Sep 27, 2024
1 parent 30faf68 commit 6c90af2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion packages/frontend-embed/src/pages/user-timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<a :href="`/@${user.username}`" target="_blank" rel="noopener noreferrer" :class="$style.avatarLink">
<EmAvatar :class="$style.avatar" :user="user"/>
</a>
<div :class="$style.headerTitle">
<div :class="$style.headerTitle" @click="top">
<I18n :src="i18n.ts.noteOf" tag="div" class="_nowrap">
<template #user>
<a v-if="user != null" :href="`/@${user.username}`" target="_blank" rel="noopener noreferrer">
Expand Down Expand Up @@ -56,6 +56,8 @@ import EmUserName from '@/components/EmUserName.vue';
import I18n from '@/components/I18n.vue';
import XNotFound from '@/pages/not-found.vue';
import EmTimelineContainer from '@/components/EmTimelineContainer.vue';
import { scrollToTop } from '@@/js/scroll.js';
import { isLink } from '@@/js/is-link.js';
import { misskeyApi } from '@/misskey-api.js';
import { i18n } from '@/i18n.js';
import { assertServerContext } from '@/server-context.js';
Expand Down Expand Up @@ -98,6 +100,15 @@ const pagination = computed(() => ({
} as Paging));

const notesEl = useTemplateRef('notesEl');

function top(ev: MouseEvent) {
const target = ev.target as HTMLElement | null;
if (target && isLink(target)) return;

if (notesEl.value) {
scrollToTop(notesEl.value.$el as HTMLElement, { behavior: 'smooth' });
}
}
</script>

<style lang="scss" module>
Expand Down
10 changes: 9 additions & 1 deletion packages/frontend-embed/src/ui.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@ import EmTagPage from '@/pages/tag.vue';
import XNotFound from '@/pages/not-found.vue';
import EmLoading from '@/components/EmLoading.vue';

function safeURIDecode(str: string): string {
try {
return decodeURIComponent(str);
} catch {
return str;
}
}

const page = location.pathname.split('/')[2];
const contentId = location.pathname.split('/')[3];
const contentId = safeURIDecode(location.pathname.split('/')[3]);
if (_DEV_) console.log(page, contentId);

const embedParams = inject(DI.embedParams, defaultEmbedParams);
Expand Down

0 comments on commit 6c90af2

Please sign in to comment.