2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-05-29 22:17:42 +02:00
|
|
|
<MkInfo
|
|
|
|
v-if="tlHint && !tlHintClosed"
|
|
|
|
:closeable="true"
|
|
|
|
class="_gap"
|
|
|
|
@close="closeHint"
|
|
|
|
>
|
|
|
|
<I18n :src="tlHint">
|
2023-05-29 20:51:02 +02:00
|
|
|
<template #icon></template>
|
|
|
|
</I18n>
|
|
|
|
</MkInfo>
|
2023-07-02 03:35:05 +02:00
|
|
|
<div v-if="queue > 0" class="new">
|
|
|
|
<button
|
|
|
|
class="_buttonPrimary _shadow"
|
2023-07-02 03:48:18 +02:00
|
|
|
@click="tlComponent.scrollTop()"
|
2023-07-02 03:35:05 +02:00
|
|
|
:class="{ instant: !$store.state.animation }"
|
|
|
|
>
|
|
|
|
{{ i18n.ts.newNoteRecived }}
|
|
|
|
<i class="ph-arrow-up ph-bold"></i>
|
|
|
|
</button>
|
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<XNotes
|
|
|
|
ref="tlComponent"
|
|
|
|
:no-gap="!$store.state.showGapBetweenNotesInTimeline"
|
|
|
|
:pagination="pagination"
|
2023-07-02 03:35:05 +02:00
|
|
|
@queue="(x) => queue = x"
|
2023-04-08 02:01:42 +02:00
|
|
|
/>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-09 14:57:27 +01:00
|
|
|
<script lang="ts" setup>
|
2023-07-02 03:35:05 +02:00
|
|
|
import { ref, watch, computed, provide, onUnmounted } from "vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import XNotes from "@/components/MkNotes.vue";
|
2023-05-29 20:51:02 +02:00
|
|
|
import MkInfo from "@/components/MkInfo.vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import * as os from "@/os";
|
|
|
|
import { stream } from "@/stream";
|
|
|
|
import * as sound from "@/scripts/sound";
|
|
|
|
import { $i } from "@/account";
|
2023-05-29 20:51:02 +02:00
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { defaultStore } from "@/store";
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-01-09 14:57:27 +01:00
|
|
|
const props = defineProps<{
|
|
|
|
src: string;
|
|
|
|
list?: string;
|
|
|
|
antenna?: string;
|
|
|
|
channel?: string;
|
|
|
|
sound?: boolean;
|
|
|
|
}>();
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-07-02 03:35:05 +02:00
|
|
|
let queue = $ref(0);
|
|
|
|
|
2022-01-09 14:57:27 +01:00
|
|
|
const emit = defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "note"): void;
|
|
|
|
(ev: "queue", count: number): void;
|
2022-01-09 14:57:27 +01:00
|
|
|
}>();
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
provide(
|
|
|
|
"inChannel",
|
|
|
|
computed(() => props.src === "channel")
|
|
|
|
);
|
2022-01-09 14:57:27 +01:00
|
|
|
|
2022-01-21 08:43:56 +01:00
|
|
|
const tlComponent: InstanceType<typeof XNotes> = $ref();
|
2022-01-09 14:57:27 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const prepend = (note) => {
|
2022-01-21 08:43:56 +01:00
|
|
|
tlComponent.pagingComponent?.prepend(note);
|
2022-01-09 14:57:27 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
emit("note");
|
2022-01-09 14:57:27 +01:00
|
|
|
|
|
|
|
if (props.sound) {
|
2023-04-08 02:01:42 +02:00
|
|
|
sound.play($i && note.userId === $i.id ? "noteMy" : "note");
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2022-01-09 14:57:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const onUserAdded = () => {
|
2022-01-21 08:43:56 +01:00
|
|
|
tlComponent.pagingComponent?.reload();
|
2022-01-09 14:57:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const onUserRemoved = () => {
|
2022-01-21 08:43:56 +01:00
|
|
|
tlComponent.pagingComponent?.reload();
|
2022-01-09 14:57:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const onChangeFollowing = () => {
|
2022-01-21 08:43:56 +01:00
|
|
|
if (!tlComponent.pagingComponent?.backed) {
|
|
|
|
tlComponent.pagingComponent?.reload();
|
2022-01-09 14:57:27 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let endpoint;
|
|
|
|
let query;
|
|
|
|
let connection;
|
|
|
|
let connection2;
|
|
|
|
|
2023-05-29 20:51:02 +02:00
|
|
|
let tlHint;
|
|
|
|
let tlHintClosed;
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
if (props.src === "antenna") {
|
|
|
|
endpoint = "antennas/notes";
|
2022-01-09 14:57:27 +01:00
|
|
|
query = {
|
2022-08-30 17:24:33 +02:00
|
|
|
antennaId: props.antenna,
|
2022-01-09 14:57:27 +01:00
|
|
|
};
|
2023-04-08 02:01:42 +02:00
|
|
|
connection = stream.useChannel("antenna", {
|
2022-08-30 17:24:33 +02:00
|
|
|
antennaId: props.antenna,
|
2022-01-09 14:57:27 +01:00
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.on("note", prepend);
|
|
|
|
} else if (props.src === "home") {
|
|
|
|
endpoint = "notes/timeline";
|
2023-06-15 05:17:56 +02:00
|
|
|
query = {
|
|
|
|
withReplies: defaultStore.state.showTimelineReplies,
|
|
|
|
};
|
|
|
|
connection = stream.useChannel("homeTimeline", {
|
|
|
|
withReplies: defaultStore.state.showTimelineReplies,
|
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.on("note", prepend);
|
|
|
|
|
|
|
|
connection2 = stream.useChannel("main");
|
|
|
|
connection2.on("follow", onChangeFollowing);
|
|
|
|
connection2.on("unfollow", onChangeFollowing);
|
2023-05-29 20:51:02 +02:00
|
|
|
|
|
|
|
tlHint = i18n.ts._tutorial.step5_3;
|
|
|
|
tlHintClosed = defaultStore.state.tlHomeHintClosed;
|
2023-04-08 02:01:42 +02:00
|
|
|
} else if (props.src === "local") {
|
|
|
|
endpoint = "notes/local-timeline";
|
2023-06-15 05:17:56 +02:00
|
|
|
query = {
|
|
|
|
withReplies: defaultStore.state.showTimelineReplies,
|
|
|
|
};
|
|
|
|
connection = stream.useChannel("localTimeline", {
|
|
|
|
withReplies: defaultStore.state.showTimelineReplies,
|
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.on("note", prepend);
|
2023-05-29 20:51:02 +02:00
|
|
|
|
|
|
|
tlHint = i18n.ts._tutorial.step5_4;
|
|
|
|
tlHintClosed = defaultStore.state.tlLocalHintClosed;
|
2023-04-08 02:01:42 +02:00
|
|
|
} else if (props.src === "recommended") {
|
|
|
|
endpoint = "notes/recommended-timeline";
|
2023-06-15 05:17:56 +02:00
|
|
|
query = {
|
|
|
|
withReplies: defaultStore.state.showTimelineReplies,
|
|
|
|
};
|
|
|
|
connection = stream.useChannel("recommendedTimeline", {
|
|
|
|
withReplies: defaultStore.state.showTimelineReplies,
|
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.on("note", prepend);
|
2023-05-29 20:51:02 +02:00
|
|
|
|
|
|
|
tlHint = i18n.ts._tutorial.step5_6;
|
|
|
|
tlHintClosed = defaultStore.state.tlRecommendedHintClosed;
|
2023-04-08 02:01:42 +02:00
|
|
|
} else if (props.src === "social") {
|
|
|
|
endpoint = "notes/hybrid-timeline";
|
2023-06-15 05:17:56 +02:00
|
|
|
query = {
|
|
|
|
withReplies: defaultStore.state.showTimelineReplies,
|
|
|
|
};
|
|
|
|
connection = stream.useChannel("hybridTimeline", {
|
|
|
|
withReplies: defaultStore.state.showTimelineReplies,
|
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.on("note", prepend);
|
2023-05-29 20:51:02 +02:00
|
|
|
|
|
|
|
tlHint = i18n.ts._tutorial.step5_5;
|
|
|
|
tlHintClosed = defaultStore.state.tlSocialHintClosed;
|
2023-04-08 02:01:42 +02:00
|
|
|
} else if (props.src === "global") {
|
|
|
|
endpoint = "notes/global-timeline";
|
2023-06-15 05:17:56 +02:00
|
|
|
query = {
|
|
|
|
withReplies: defaultStore.state.showTimelineReplies,
|
|
|
|
};
|
|
|
|
connection = stream.useChannel("globalTimeline", {
|
|
|
|
withReplies: defaultStore.state.showTimelineReplies,
|
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.on("note", prepend);
|
2023-05-29 20:51:02 +02:00
|
|
|
|
|
|
|
tlHint = i18n.ts._tutorial.step5_7;
|
|
|
|
tlHintClosed = defaultStore.state.tlGlobalHintClosed;
|
2023-04-08 02:01:42 +02:00
|
|
|
} else if (props.src === "mentions") {
|
|
|
|
endpoint = "notes/mentions";
|
|
|
|
connection = stream.useChannel("main");
|
|
|
|
connection.on("mention", prepend);
|
|
|
|
} else if (props.src === "directs") {
|
|
|
|
endpoint = "notes/mentions";
|
2022-01-09 14:57:27 +01:00
|
|
|
query = {
|
2023-04-08 02:01:42 +02:00
|
|
|
visibility: "specified",
|
2022-01-09 14:57:27 +01:00
|
|
|
};
|
2023-04-08 02:01:42 +02:00
|
|
|
const onNote = (note) => {
|
|
|
|
if (note.visibility === "specified") {
|
2022-01-09 14:57:27 +01:00
|
|
|
prepend(note);
|
|
|
|
}
|
|
|
|
};
|
2023-04-08 02:01:42 +02:00
|
|
|
connection = stream.useChannel("main");
|
|
|
|
connection.on("mention", onNote);
|
|
|
|
} else if (props.src === "list") {
|
|
|
|
endpoint = "notes/user-list-timeline";
|
2022-01-09 14:57:27 +01:00
|
|
|
query = {
|
2022-08-30 17:24:33 +02:00
|
|
|
listId: props.list,
|
2022-01-09 14:57:27 +01:00
|
|
|
};
|
2023-04-08 02:01:42 +02:00
|
|
|
connection = stream.useChannel("userList", {
|
2022-08-30 17:24:33 +02:00
|
|
|
listId: props.list,
|
2022-01-09 14:57:27 +01:00
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.on("note", prepend);
|
|
|
|
connection.on("userAdded", onUserAdded);
|
|
|
|
connection.on("userRemoved", onUserRemoved);
|
|
|
|
} else if (props.src === "channel") {
|
|
|
|
endpoint = "channels/timeline";
|
2022-01-09 14:57:27 +01:00
|
|
|
query = {
|
2022-08-30 17:24:33 +02:00
|
|
|
channelId: props.channel,
|
2022-01-09 14:57:27 +01:00
|
|
|
};
|
2023-04-08 02:01:42 +02:00
|
|
|
connection = stream.useChannel("channel", {
|
2022-08-30 17:24:33 +02:00
|
|
|
channelId: props.channel,
|
2022-01-09 14:57:27 +01:00
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.on("note", prepend);
|
2022-01-09 14:57:27 +01:00
|
|
|
}
|
|
|
|
|
2023-05-29 20:51:02 +02:00
|
|
|
function closeHint() {
|
|
|
|
switch (props.src) {
|
2023-05-29 22:17:42 +02:00
|
|
|
case "home":
|
2023-05-29 20:51:02 +02:00
|
|
|
defaultStore.set("tlHomeHintClosed", true);
|
|
|
|
break;
|
2023-05-29 22:17:42 +02:00
|
|
|
case "local":
|
2023-05-29 20:51:02 +02:00
|
|
|
defaultStore.set("tlLocalHintClosed", true);
|
|
|
|
break;
|
2023-05-29 22:17:42 +02:00
|
|
|
case "recommended":
|
2023-05-29 20:51:02 +02:00
|
|
|
defaultStore.set("tlRecommendedHintClosed", true);
|
|
|
|
break;
|
2023-05-29 22:17:42 +02:00
|
|
|
case "social":
|
2023-05-29 20:51:02 +02:00
|
|
|
defaultStore.set("tlSocialHintClosed", true);
|
|
|
|
break;
|
2023-05-29 22:17:42 +02:00
|
|
|
case "global":
|
2023-05-29 20:51:02 +02:00
|
|
|
defaultStore.set("tlGlobalHintClosed", true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-09 14:57:27 +01:00
|
|
|
const pagination = {
|
|
|
|
endpoint: endpoint,
|
|
|
|
limit: 10,
|
|
|
|
params: query,
|
|
|
|
};
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
connection.dispose();
|
|
|
|
if (connection2) connection2.dispose();
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
2022-01-09 14:57:27 +01:00
|
|
|
|
|
|
|
/* TODO
|
|
|
|
const timetravel = (date?: Date) => {
|
|
|
|
this.date = date;
|
|
|
|
this.$refs.tl.reload();
|
|
|
|
};
|
|
|
|
*/
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
2023-07-02 03:35:05 +02:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
@keyframes slideUp {
|
|
|
|
to {
|
|
|
|
transform: translateY(-100%);
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.new {
|
|
|
|
position: sticky;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
top: calc(var(--stickyTop, 0px) - 60px);
|
|
|
|
width: 600px;
|
|
|
|
max-width: 100%;
|
|
|
|
height: 60px;
|
|
|
|
pointer-events: none;
|
|
|
|
margin: auto;
|
|
|
|
margin-top: -60px;
|
|
|
|
z-index: 1001;
|
|
|
|
box-shadow: 0 24px 24px -20px var(--accentedBg);
|
|
|
|
&::after {
|
|
|
|
content: "";
|
|
|
|
position: absolute;
|
|
|
|
inset: -2px 0;
|
|
|
|
border: 2px solid var(--accentDarken);
|
|
|
|
mask: linear-gradient(
|
|
|
|
to right,
|
|
|
|
transparent,
|
|
|
|
black 40% 60%,
|
|
|
|
transparent
|
|
|
|
);
|
|
|
|
-webkit-mask: linear-gradient(
|
|
|
|
to right,
|
|
|
|
transparent,
|
|
|
|
black 40% 60%,
|
|
|
|
transparent
|
|
|
|
);
|
|
|
|
}
|
|
|
|
> button {
|
|
|
|
display: flex;
|
|
|
|
position: absolute;
|
|
|
|
top: 120%;
|
|
|
|
margin-inline: auto;
|
|
|
|
border-radius: 2em;
|
|
|
|
padding: 0.5em 1.2em;
|
|
|
|
background: var(--accentedBg);
|
|
|
|
border: 0;
|
|
|
|
color: var(--accent);
|
|
|
|
overflow: hidden;
|
|
|
|
pointer-events: all;
|
|
|
|
transform: translateY(-100%);
|
|
|
|
opacity: 0;
|
|
|
|
animation: reset 0.4s forwards cubic-bezier(0, 0.4, 0, 1.1),
|
|
|
|
slideUp 1s 5s forwards cubic-bezier(1, 0, 1, 1);
|
|
|
|
&::before {
|
|
|
|
content: "";
|
|
|
|
position: absolute;
|
|
|
|
inset: 0;
|
|
|
|
background: var(--bg);
|
|
|
|
z-index: -1;
|
|
|
|
}
|
|
|
|
i {
|
|
|
|
margin-left: 0.7em;
|
|
|
|
border-left: 1px solid var(--accentedBg);
|
|
|
|
padding-left: 0.4em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|