2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
2024-02-13 15:59:27 +00:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 05:31:52 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2023-05-19 07:20:53 +00:00
|
|
|
<MkContainer :showHeader="widgetProps.showHeader" :style="`height: ${widgetProps.height}px;`" :scrollable="true" data-cy-mkw-timeline class="mkw-timeline">
|
2023-01-14 23:30:29 +00:00
|
|
|
<template #icon>
|
2023-09-30 19:53:52 +00:00
|
|
|
<i v-if="widgetProps.src === 'home'" class="ph-house ph-bold ph-lg"></i>
|
2023-11-03 22:20:53 +00:00
|
|
|
<i v-else-if="widgetProps.src === 'local'" class="ph-planet ph-bold ph-lg"></i>
|
|
|
|
<i v-else-if="widgetProps.src === 'social'" class="ph-rocket-launch ph-bold ph-lg"></i>
|
2023-12-04 01:10:51 +00:00
|
|
|
<i v-else-if="widgetProps.src === 'bubble'" class="ph-drop ph-bold ph-lg"></i>
|
2023-09-30 19:53:52 +00:00
|
|
|
<i v-else-if="widgetProps.src === 'global'" class="ph-globe-hemisphere-west ph-bold ph-lg"></i>
|
2023-11-03 22:20:53 +00:00
|
|
|
<i v-else-if="widgetProps.src === 'list'" class="ph-list ph-bold ph-lg"></i>
|
|
|
|
<i v-else-if="widgetProps.src === 'antenna'" class="ph-flying-saucer ph-bold ph-lg"></i>
|
2023-01-14 23:30:29 +00:00
|
|
|
</template>
|
2020-07-11 01:13:11 +00:00
|
|
|
<template #header>
|
2021-11-19 10:36:12 +00:00
|
|
|
<button class="_button" @click="choose">
|
2024-01-19 23:11:59 +00:00
|
|
|
<span>{{ widgetProps.src === 'list' ? widgetProps.list.name : widgetProps.src === 'antenna' ? widgetProps.antenna.name : i18n.ts._timelines[widgetProps.src] }}</span>
|
2023-09-30 19:53:52 +00:00
|
|
|
<i :class="menuOpened ? 'ph-caret-up ph-bold ph-lg' : 'ph-caret-down ph-bold ph-lg'" style="margin-left: 8px;"></i>
|
2020-07-11 01:13:11 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-12-04 01:10:51 +00:00
|
|
|
<div v-if="(((widgetProps.src === 'local' || widgetProps.src === 'social') && !isLocalTimelineAvailable) || (widgetProps.src === 'bubble' && !isBubbleTimelineAvailable) || (widgetProps.src === 'global' && !isGlobalTimelineAvailable))" :class="$style.disabled">
|
2023-03-12 01:20:33 +00:00
|
|
|
<p :class="$style.disabledTitle">
|
2023-09-30 19:53:52 +00:00
|
|
|
<i class="ph-minus ph-bold ph-lg"></i>
|
2023-03-12 01:20:33 +00:00
|
|
|
{{ i18n.ts._disabledTimeline.title }}
|
|
|
|
</p>
|
|
|
|
<p :class="$style.disabledDescription">{{ i18n.ts._disabledTimeline.description }}</p>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
2023-02-22 02:00:34 +00:00
|
|
|
<MkTimeline :key="widgetProps.src === 'list' ? `list:${widgetProps.list.id}` : widgetProps.src === 'antenna' ? `antenna:${widgetProps.antenna.id}` : widgetProps.src" :src="widgetProps.src" :list="widgetProps.list ? widgetProps.list.id : null" :antenna="widgetProps.antenna ? widgetProps.antenna.id : null"/>
|
2020-07-11 01:13:11 +00:00
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkContainer>
|
2020-01-29 19:37:25 +00:00
|
|
|
</template>
|
|
|
|
|
2022-01-08 11:30:01 +00:00
|
|
|
<script lang="ts" setup>
|
2023-02-16 14:09:41 +00:00
|
|
|
import { ref } from 'vue';
|
2023-12-21 02:36:45 +00:00
|
|
|
import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { GetFormResultType } from '@/scripts/form.js';
|
|
|
|
import * as os from '@/os.js';
|
2024-01-04 09:32:46 +00:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2022-09-06 09:21:49 +00:00
|
|
|
import MkContainer from '@/components/MkContainer.vue';
|
2023-02-22 02:00:34 +00:00
|
|
|
import MkTimeline from '@/components/MkTimeline.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { $i } from '@/account.js';
|
|
|
|
import { instance } from '@/instance.js';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-01-08 11:30:01 +00:00
|
|
|
const name = 'timeline';
|
2023-03-12 01:20:33 +00:00
|
|
|
const isLocalTimelineAvailable = (($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable));
|
|
|
|
const isGlobalTimelineAvailable = (($i == null && instance.policies.gtlAvailable) || ($i != null && $i.policies.gtlAvailable));
|
2023-12-04 01:10:51 +00:00
|
|
|
const isBubbleTimelineAvailable = (($i == null && instance.policies.btlAvailable) || ($i != null && $i.policies.btlAvailable));
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-01-08 11:30:01 +00:00
|
|
|
const widgetPropsDef = {
|
|
|
|
showHeader: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
default: true,
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
2022-01-08 11:30:01 +00:00
|
|
|
height: {
|
|
|
|
type: 'number' as const,
|
|
|
|
default: 300,
|
|
|
|
},
|
|
|
|
src: {
|
|
|
|
type: 'string' as const,
|
|
|
|
default: 'home',
|
|
|
|
hidden: true,
|
|
|
|
},
|
|
|
|
antenna: {
|
|
|
|
type: 'object' as const,
|
|
|
|
default: null,
|
|
|
|
hidden: true,
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
2022-01-08 11:30:01 +00:00
|
|
|
list: {
|
|
|
|
type: 'object' as const,
|
|
|
|
default: null,
|
|
|
|
hidden: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
type WidgetProps = GetFormResultType<typeof widgetPropsDef>;
|
|
|
|
|
2023-05-19 07:20:53 +00:00
|
|
|
const props = defineProps<WidgetComponentProps<WidgetProps>>();
|
|
|
|
const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
|
2022-01-08 11:30:01 +00:00
|
|
|
|
|
|
|
const { widgetProps, configure, save } = useWidgetPropsManager(name,
|
|
|
|
widgetPropsDef,
|
|
|
|
props,
|
|
|
|
emit,
|
|
|
|
);
|
|
|
|
|
|
|
|
const menuOpened = ref(false);
|
|
|
|
|
|
|
|
const setSrc = (src) => {
|
|
|
|
widgetProps.src = src;
|
|
|
|
save();
|
|
|
|
};
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-01-08 11:30:01 +00:00
|
|
|
const choose = async (ev) => {
|
|
|
|
menuOpened.value = true;
|
|
|
|
const [antennas, lists] = await Promise.all([
|
2024-01-04 09:32:46 +00:00
|
|
|
misskeyApi('antennas/list'),
|
|
|
|
misskeyApi('users/lists/list'),
|
2022-01-08 11:30:01 +00:00
|
|
|
]);
|
|
|
|
const antennaItems = antennas.map(antenna => ({
|
|
|
|
text: antenna.name,
|
2023-11-03 22:20:53 +00:00
|
|
|
icon: 'ph-flying-saucer ph-bold ph-lg',
|
2022-01-08 11:30:01 +00:00
|
|
|
action: () => {
|
|
|
|
widgetProps.antenna = antenna;
|
|
|
|
setSrc('antenna');
|
2022-12-22 07:01:59 +00:00
|
|
|
},
|
2022-01-08 11:30:01 +00:00
|
|
|
}));
|
|
|
|
const listItems = lists.map(list => ({
|
|
|
|
text: list.name,
|
2023-11-03 22:20:53 +00:00
|
|
|
icon: 'ph-list ph-bold ph-lg',
|
2022-01-08 11:30:01 +00:00
|
|
|
action: () => {
|
|
|
|
widgetProps.list = list;
|
|
|
|
setSrc('list');
|
2022-12-22 07:01:59 +00:00
|
|
|
},
|
2022-01-08 11:30:01 +00:00
|
|
|
}));
|
|
|
|
os.popupMenu([{
|
2022-01-28 02:39:49 +00:00
|
|
|
text: i18n.ts._timelines.home,
|
2023-09-30 19:53:52 +00:00
|
|
|
icon: 'ph-house ph-bold ph-lg',
|
2022-12-22 07:01:59 +00:00
|
|
|
action: () => { setSrc('home'); },
|
2022-01-08 11:30:01 +00:00
|
|
|
}, {
|
2022-01-28 02:39:49 +00:00
|
|
|
text: i18n.ts._timelines.local,
|
2023-11-03 22:20:53 +00:00
|
|
|
icon: 'ph-planet ph-bold ph-lg',
|
2022-12-22 07:01:59 +00:00
|
|
|
action: () => { setSrc('local'); },
|
2022-01-08 11:30:01 +00:00
|
|
|
}, {
|
2022-01-28 02:39:49 +00:00
|
|
|
text: i18n.ts._timelines.social,
|
2023-11-03 22:20:53 +00:00
|
|
|
icon: 'ph-rocket-launch ph-bold ph-lg',
|
2022-12-22 07:01:59 +00:00
|
|
|
action: () => { setSrc('social'); },
|
2023-12-04 01:10:51 +00:00
|
|
|
}, {
|
|
|
|
text: 'Bubble',
|
|
|
|
icon: 'ph-drop ph-bold ph-lg',
|
|
|
|
action: () => { setSrc('bubble'); },
|
2022-01-08 11:30:01 +00:00
|
|
|
}, {
|
2022-01-28 02:39:49 +00:00
|
|
|
text: i18n.ts._timelines.global,
|
2023-09-30 19:53:52 +00:00
|
|
|
icon: 'ph-globe-hemisphere-west ph-bold ph-lg',
|
2022-12-22 07:01:59 +00:00
|
|
|
action: () => { setSrc('global'); },
|
2023-12-12 01:26:37 +00:00
|
|
|
}, antennaItems.length > 0 ? { type: 'divider' } : undefined, ...antennaItems, listItems.length > 0 ? { type: 'divider' } : undefined, ...listItems], ev.currentTarget ?? ev.target).then(() => {
|
2022-01-08 11:30:01 +00:00
|
|
|
menuOpened.value = false;
|
|
|
|
});
|
|
|
|
};
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-01-08 11:30:01 +00:00
|
|
|
defineExpose<WidgetComponentExpose>({
|
|
|
|
name,
|
|
|
|
configure,
|
|
|
|
id: props.widget ? props.widget.id : null,
|
2020-01-29 19:37:25 +00:00
|
|
|
});
|
|
|
|
</script>
|
2023-03-12 01:20:33 +00:00
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.disabled {
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.disabledTitle {
|
|
|
|
margin: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.disabledDescription {
|
|
|
|
font-size: 90%;
|
|
|
|
}
|
|
|
|
</style>
|