Skip to content

Commit

Permalink
add @ + acct
Browse files Browse the repository at this point in the history
  • Loading branch information
noridev committed Sep 23, 2023
1 parent 10f47b2 commit 686f1f8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
9 changes: 3 additions & 6 deletions packages/frontend/src/components/MkChatPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only
v-anim="i"
class="_panel"
:class="[$style.message, { [$style.isRead]: (isMe(message) || (message.groupId ? message.reads.includes($i.id) : message.isRead)) }]"
:to="message.groupId ? `/my/messaging/group/${message.groupId}` : `/my/messaging/${getAcct(isMe(message) ? message.recipient : message.user)}`"
:to="message.groupId ? `/my/messaging/group/${ message.groupId }` : `/my/messaging/@${Misskey.acct.toString(isMe(message) ? message.recipient : message.user)}`"
:data-index="i"
>
<div>
Expand All @@ -20,7 +20,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</header>
<header v-else>
<span :class="$style.name"><MkUserName :user="isMe(message) ? message.recipient : message.user"/></span>
<span :class="$style.username">@{{ acct(isMe(message) ? message.recipient : message.user) }}</span>
<span :class="$style.username">@{{ Misskey.acct.toString(isMe(message) ? message.recipient : message.user) }}</span>
<MkTime :time="message.createdAt" :class="$style.time"/>
</header>
<div>
Expand All @@ -31,13 +31,10 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
import * as Acct from 'cherrypick-js/built/acct';
import { acct } from '@/filters/user.js';
import * as Misskey from 'cherrypick-js';
import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';

const getAcct = Acct.toString;

const props = defineProps<{
message: Record<string, any>;
}>();
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/messaging/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts" setup>
import { markRaw, onMounted, onUnmounted } from 'vue';
import * as Acct from 'cherrypick-js/built/acct';
import * as Misskey from 'cherrypick-js';
import * as os from '@/os.js';
import { useStream } from '@/stream.js';
import { useRouter } from '@/router.js';
Expand Down Expand Up @@ -104,7 +104,7 @@ function start(ev) {

async function startUser() {
os.selectUser().then(user => {
router.push(`/my/messaging/${Acct.toString(user)}`);
router.push(`/my/messaging/@${Misskey.acct.toString(user)}`);
});
}

Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/pages/messaging/messaging-room.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { computed, onMounted, nextTick, onBeforeUnmount, watch, shallowRef } from 'vue';
import * as Misskey from 'cherrypick-js';
import * as Acct from 'cherrypick-js/built/acct';
import XMessage from './messaging-room.message.vue';
import XForm from './messaging-room.form.vue';
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
Expand Down Expand Up @@ -109,7 +108,7 @@ async function fetch() {
fetching = true;

if (props.userAcct) {
const acct = Acct.parse(props.userAcct);
const acct = Misskey.acct.parse(props.userAcct);
user = await os.api('users/show', { username: acct.username, host: acct.host || undefined });
group = null;

Expand Down Expand Up @@ -310,6 +309,8 @@ onBeforeUnmount(() => {
});

definePageMetadata(computed(() => !fetching ? user ? {
title: '',
icon: null,
userName: user,
avatar: user,
} : {
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export const routes = [{
loginRequired: true,
}, {
name: 'messaging-room',
path: '/my/messaging/:userAcct',
path: '/my/messaging/@:userAcct',
component: page(() => import('./pages/messaging/messaging-room.vue')),
loginRequired: true,
}, {
Expand Down
2 changes: 1 addition & 1 deletion packages/sw/src/scripts/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function openAntenna(antennaId: string, loginId: string): ReturnType<type

export async function openChat(body: any, loginId: string) {
if (body.groupId === null) {
return openClient('push', `/my/messaging/${getAcct(body.user)}`, loginId, { body });
return openClient('push', `/my/messaging/@${Misskey.acct.toString(body.user)}`, loginId, { body });
} else {
return openClient('push', `/my/messaging/group/${body.groupId}`, loginId, { body });
}
Expand Down

0 comments on commit 686f1f8

Please sign in to comment.