Skip to content

Commit

Permalink
feat(vmimi-relay/frontend): virtual kemomimi relay social timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Apr 16, 2024
1 parent d41e286 commit 5afbe0e
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 13 deletions.
4 changes: 4 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8573,6 +8573,10 @@ export interface Locale extends ILocale {
* ぶいみみリレー
*/
"vmimiRelay": string;
/**
* ぶいみみリレーソーシャル
*/
"vmimiRelaySocial": string;
};
"_play": {
/**
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,7 @@ _timelines:
social: "ソーシャル"
global: "グローバル"
vmimiRelay: "ぶいみみリレー"
vmimiRelaySocial: "ぶいみみリレーソーシャル"

_play:
new: "Playの作成"
Expand Down
15 changes: 14 additions & 1 deletion packages/frontend/src/components/MkTimeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { defaultStore } from '@/store.js';
import { Paging } from '@/components/MkPagination.vue';

const props = withDefaults(defineProps<{
src: 'home' | 'local' | 'social' | 'global' | 'vmimi-relay' | 'mentions' | 'directs' | 'list' | 'antenna' | 'channel' | 'role';
src: 'home' | 'local' | 'social' | 'global' | 'vmimi-relay' | 'vmimi-relay-social' | 'mentions' | 'directs' | 'list' | 'antenna' | 'channel' | 'role';
list?: string;
antenna?: string;
channel?: string;
Expand Down Expand Up @@ -127,6 +127,12 @@ function connectChannel() {
withFiles: props.onlyFiles ? true : undefined,
withReplies: props.withReplies,
});
} else if (props.src === 'vmimi-relay-social') {
connection = stream.useChannel('vmimiRelayHybridTimeline', {
withRenotes: props.withRenotes,
withFiles: props.onlyFiles ? true : undefined,
withReplies: props.withReplies,
});
} else if (props.src === 'mentions') {
connection = stream.useChannel('main');
connection.on('mention', prepend);
Expand Down Expand Up @@ -206,6 +212,13 @@ function updatePaginationQuery() {
withFiles: props.onlyFiles ? true : undefined,
withReplies: props.withReplies,
};
} else if (props.src === 'vmimi-relay-social') {
endpoint = 'notes/vmimi-relay-hybrid-timeline';
query = {
withRenotes: props.withRenotes,
withFiles: props.onlyFiles ? true : undefined,
withReplies: props.withReplies,
};
} else if (props.src === 'mentions') {
endpoint = 'notes/mentions';
query = null;
Expand Down
22 changes: 14 additions & 8 deletions packages/frontend/src/pages/timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { miLocalStorage } from '@/local-storage.js';
provide('shouldOmitHeaderTitle', true);

const isLocalTimelineAvailable = ($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable);
const isVmimiRelayTimelineAvailable = ($i == null && instance.policies.vrtlAvailable) || ($i != null && $i.policies.vrtlAvailable);
const isGlobalTimelineAvailable = ($i == null && instance.policies.gtlAvailable) || ($i != null && $i.policies.gtlAvailable);
const keymap = {
't': focus,
Expand All @@ -67,7 +68,7 @@ const rootEl = shallowRef<HTMLElement>();

const queue = ref(0);
const srcWhenNotSignin = ref<'local' | 'global'>(isLocalTimelineAvailable ? 'local' : 'global');
const src = computed<'home' | 'local' | 'social' | 'global' | 'vmimi-relay' | `list:${string}`>({
const src = computed<'home' | 'local' | 'social' | 'global' | 'vmimi-relay' | 'vmimi-relay-social' | `list:${string}`>({
get: () => ($i ? defaultStore.reactiveState.tl.value.src : srcWhenNotSignin.value),
set: (x) => saveSrc(x),
});
Expand All @@ -82,7 +83,7 @@ const localSocialTLFilterSwitchStore = ref<'withReplies' | 'onlyFiles' | false>(
const withReplies = computed<boolean>({
get: () => {
if (!$i) return false;
if (['local', 'social', 'vmimi-relay'].includes(src.value) && localSocialTLFilterSwitchStore.value === 'onlyFiles') {
if (['local', 'social', 'vmimi-relay', 'vmimi-relay-social'].includes(src.value) && localSocialTLFilterSwitchStore.value === 'onlyFiles') {
return false;
} else {
return defaultStore.reactiveState.tl.value.filter.withReplies;
Expand All @@ -92,7 +93,7 @@ const withReplies = computed<boolean>({
});
const onlyFiles = computed<boolean>({
get: () => {
if (['local', 'social', 'vmimi-relay'].includes(src.value) && localSocialTLFilterSwitchStore.value === 'withReplies') {
if (['local', 'social', 'vmimi-relay', 'vmimi-relay-social'].includes(src.value) && localSocialTLFilterSwitchStore.value === 'withReplies') {
return false;
} else {
return defaultStore.reactiveState.tl.value.filter.onlyFiles;
Expand Down Expand Up @@ -199,7 +200,7 @@ async function chooseChannel(ev: MouseEvent): Promise<void> {
os.popupMenu(items, ev.currentTarget ?? ev.target);
}

function saveSrc(newSrc: 'home' | 'local' | 'social' | 'global' | 'vmimi-relay' | `list:${string}`): void {
function saveSrc(newSrc: 'home' | 'local' | 'social' | 'global' | 'vmimi-relay' | 'vmimi-relay-social' | `list:${string}`): void {
const out = deepMerge({ src: newSrc }, defaultStore.state.tl);

if (newSrc.startsWith('userList:')) {
Expand Down Expand Up @@ -250,7 +251,7 @@ const headerActions = computed(() => {
type: 'switch',
text: i18n.ts.showRenotes,
ref: withRenotes,
}, src.value === 'local' || src.value === 'social' || src.value === 'vmimi-relay' ? {
}, src.value === 'local' || src.value === 'social' || src.value === 'vmimi-relay' || src.value === 'vmimi-relay-social' ? {
type: 'switch',
text: i18n.ts.showRepliesToOthersInTimeline,
ref: withReplies,
Expand All @@ -263,7 +264,7 @@ const headerActions = computed(() => {
type: 'switch',
text: i18n.ts.fileAttachedOnly,
ref: onlyFiles,
disabled: src.value === 'local' || src.value === 'social' || src.value === 'vmimi-relay' ? withReplies : false,
disabled: src.value === 'local' || src.value === 'social' || src.value === 'vmimi-relay' || src.value === 'vmimi-relay-social' ? withReplies : false,
}], ev.currentTarget ?? ev.target);
},
},
Expand Down Expand Up @@ -305,11 +306,16 @@ const headerTabs = computed(() => [...(defaultStore.reactiveState.pinnedUserList
title: i18n.ts._timelines.global,
icon: 'ti ti-whirl',
iconOnly: true,
}, {
}] : []), ...(isVmimiRelayTimelineAvailable ? [{
key: 'vmimi-relay',
title: i18n.ts._timelines.vmimiRelay,
icon: 'ti ti-circles-relation',
iconOnly: true,
}, {
key: 'vmimi-relay-social',
title: i18n.ts._timelines.vmimiRelaySocial,
icon: 'ti ti-topology-full',
iconOnly: true,
}] : []), {
icon: 'ti ti-list',
title: i18n.ts.lists,
Expand Down Expand Up @@ -344,7 +350,7 @@ const headerTabsWhenNotLogin = computed(() => [

definePageMetadata(() => ({
title: i18n.ts.timeline,
icon: src.value === 'local' ? 'ti ti-planet' : src.value === 'social' ? 'ti ti-universe' : src.value === 'global' ? 'ti ti-whirl' : src.value === 'vmimi-relay' ? 'ti ti-circles-relation' : 'ti ti-home',
icon: src.value === 'local' ? 'ti ti-planet' : src.value === 'social' ? 'ti ti-universe' : src.value === 'global' ? 'ti ti-whirl' : src.value === 'vmimi-relay' ? 'ti ti-circles-relation': src.value === 'vmimi-relay-social' ? 'ti ti-topology-full' : 'ti ti-home',
}));
</script>

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const defaultStore = markRaw(new Storage('base', {
tl: {
where: 'deviceAccount',
default: {
src: 'home' as 'home' | 'local' | 'social' | 'global' | 'vmimi-relay' | `list:${string}`,
src: 'home' as 'home' | 'local' | 'social' | 'global' | 'vmimi-relay' | 'vmimi-relay-social' | `list:${string}`,
userList: null as Misskey.entities.UserList | null,
filter: {
withReplies: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/ui/deck/deck-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type Column = {
channelId?: string;
roleId?: string;
excludeTypes?: typeof notificationTypes[number][];
tl?: 'home' | 'local' | 'social' | 'global' | 'vmimi-relay';
tl?: 'home' | 'local' | 'social' | 'global' | 'vmimi-relay' | 'vmimi-relay-social';
withRenotes?: boolean;
withReplies?: boolean;
onlyFiles?: boolean;
Expand Down
7 changes: 5 additions & 2 deletions packages/frontend/src/ui/deck/tl-column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<i v-else-if="column.tl === 'social'" class="ti ti-universe"></i>
<i v-else-if="column.tl === 'global'" class="ti ti-whirl"></i>
<i v-else-if="column.tl === 'vmimi-relay'" class="ti ti-circles-relation"></i>
<i v-else-if="column.tl === 'vmimi-relay-social'" class="ti ti-topology-full"></i>
<span style="margin-left: 8px;">{{ column.name }}</span>
</template>

Expand Down Expand Up @@ -98,6 +99,8 @@ async function setType() {
value: 'global' as const, text: i18n.ts._timelines.global,
}, {
value: 'vmimi-relay' as const, text: i18n.ts._timelines.vmimiRelay,
}, {
value: 'vmimi-relay-social' as const, text: i18n.ts._timelines.vmimiRelaySocial,
}],
});
if (canceled) {
Expand All @@ -119,7 +122,7 @@ const menu = [{
type: 'switch',
text: i18n.ts.showRenotes,
ref: withRenotes,
}, props.column.tl === 'local' || props.column.tl === 'social' || props.column.tl === 'vmimi-relay' ? {
}, props.column.tl === 'local' || props.column.tl === 'social' || props.column.tl === 'vmimi-relay-social' || props.column.tl === 'vmimi-relay' ? {
type: 'switch',
text: i18n.ts.showRepliesToOthersInTimeline,
ref: withReplies,
Expand All @@ -128,7 +131,7 @@ const menu = [{
type: 'switch',
text: i18n.ts.fileAttachedOnly,
ref: onlyFiles,
disabled: props.column.tl === 'local' || props.column.tl === 'social' ? withReplies : false,
disabled: props.column.tl === 'local' || props.column.tl === 'social' || props.column.tl === 'vmimi-relay-social' || props.column.tl === 'vmimi-relay' ? withReplies : false,
}];
</script>

Expand Down

0 comments on commit 5afbe0e

Please sign in to comment.