mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 00:43:49 +01:00
Timetravel prototype
This commit is contained in:
parent
5a4417954b
commit
06ad3eeff1
@ -49,6 +49,8 @@ const props = defineProps<{
|
|||||||
antenna?: string;
|
antenna?: string;
|
||||||
channel?: string;
|
channel?: string;
|
||||||
sound?: boolean;
|
sound?: boolean;
|
||||||
|
sinceDate?: number;
|
||||||
|
untilDate?: number;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
let queue = $ref(0);
|
let queue = $ref(0);
|
||||||
@ -101,6 +103,8 @@ if (props.src === "antenna") {
|
|||||||
endpoint = "antennas/notes";
|
endpoint = "antennas/notes";
|
||||||
query = {
|
query = {
|
||||||
antennaId: props.antenna,
|
antennaId: props.antenna,
|
||||||
|
sinceDate: props.sinceDate,
|
||||||
|
untilDate: props.untilDate,
|
||||||
};
|
};
|
||||||
connection = stream.useChannel("antenna", {
|
connection = stream.useChannel("antenna", {
|
||||||
antennaId: props.antenna,
|
antennaId: props.antenna,
|
||||||
@ -113,6 +117,8 @@ if (props.src === "antenna") {
|
|||||||
endpoint = "notes/timeline";
|
endpoint = "notes/timeline";
|
||||||
query = {
|
query = {
|
||||||
withReplies: defaultStore.state.showTimelineReplies,
|
withReplies: defaultStore.state.showTimelineReplies,
|
||||||
|
sinceDate: props.sinceDate,
|
||||||
|
untilDate: props.untilDate,
|
||||||
};
|
};
|
||||||
connection = stream.useChannel("homeTimeline", {
|
connection = stream.useChannel("homeTimeline", {
|
||||||
withReplies: defaultStore.state.showTimelineReplies,
|
withReplies: defaultStore.state.showTimelineReplies,
|
||||||
@ -129,6 +135,8 @@ if (props.src === "antenna") {
|
|||||||
endpoint = "notes/local-timeline";
|
endpoint = "notes/local-timeline";
|
||||||
query = {
|
query = {
|
||||||
withReplies: defaultStore.state.showTimelineReplies,
|
withReplies: defaultStore.state.showTimelineReplies,
|
||||||
|
sinceDate: props.sinceDate,
|
||||||
|
untilDate: props.untilDate,
|
||||||
};
|
};
|
||||||
connection = stream.useChannel("localTimeline", {
|
connection = stream.useChannel("localTimeline", {
|
||||||
withReplies: defaultStore.state.showTimelineReplies,
|
withReplies: defaultStore.state.showTimelineReplies,
|
||||||
@ -141,6 +149,8 @@ if (props.src === "antenna") {
|
|||||||
endpoint = "notes/recommended-timeline";
|
endpoint = "notes/recommended-timeline";
|
||||||
query = {
|
query = {
|
||||||
withReplies: defaultStore.state.showTimelineReplies,
|
withReplies: defaultStore.state.showTimelineReplies,
|
||||||
|
sinceDate: props.sinceDate,
|
||||||
|
untilDate: props.untilDate,
|
||||||
};
|
};
|
||||||
connection = stream.useChannel("recommendedTimeline", {
|
connection = stream.useChannel("recommendedTimeline", {
|
||||||
withReplies: defaultStore.state.showTimelineReplies,
|
withReplies: defaultStore.state.showTimelineReplies,
|
||||||
@ -153,6 +163,8 @@ if (props.src === "antenna") {
|
|||||||
endpoint = "notes/hybrid-timeline";
|
endpoint = "notes/hybrid-timeline";
|
||||||
query = {
|
query = {
|
||||||
withReplies: defaultStore.state.showTimelineReplies,
|
withReplies: defaultStore.state.showTimelineReplies,
|
||||||
|
sinceDate: props.sinceDate,
|
||||||
|
untilDate: props.untilDate,
|
||||||
};
|
};
|
||||||
connection = stream.useChannel("hybridTimeline", {
|
connection = stream.useChannel("hybridTimeline", {
|
||||||
withReplies: defaultStore.state.showTimelineReplies,
|
withReplies: defaultStore.state.showTimelineReplies,
|
||||||
@ -165,6 +177,8 @@ if (props.src === "antenna") {
|
|||||||
endpoint = "notes/global-timeline";
|
endpoint = "notes/global-timeline";
|
||||||
query = {
|
query = {
|
||||||
withReplies: defaultStore.state.showTimelineReplies,
|
withReplies: defaultStore.state.showTimelineReplies,
|
||||||
|
sinceDate: props.sinceDate,
|
||||||
|
untilDate: props.untilDate,
|
||||||
};
|
};
|
||||||
connection = stream.useChannel("globalTimeline", {
|
connection = stream.useChannel("globalTimeline", {
|
||||||
withReplies: defaultStore.state.showTimelineReplies,
|
withReplies: defaultStore.state.showTimelineReplies,
|
||||||
@ -181,6 +195,8 @@ if (props.src === "antenna") {
|
|||||||
endpoint = "notes/mentions";
|
endpoint = "notes/mentions";
|
||||||
query = {
|
query = {
|
||||||
visibility: "specified",
|
visibility: "specified",
|
||||||
|
sinceDate: props.sinceDate,
|
||||||
|
untilDate: props.untilDate,
|
||||||
};
|
};
|
||||||
const onNote = (note) => {
|
const onNote = (note) => {
|
||||||
if (note.visibility === "specified") {
|
if (note.visibility === "specified") {
|
||||||
@ -193,6 +209,8 @@ if (props.src === "antenna") {
|
|||||||
endpoint = "notes/user-list-timeline";
|
endpoint = "notes/user-list-timeline";
|
||||||
query = {
|
query = {
|
||||||
listId: props.list,
|
listId: props.list,
|
||||||
|
sinceDate: props.sinceDate,
|
||||||
|
untilDate: props.untilDate,
|
||||||
};
|
};
|
||||||
connection = stream.useChannel("userList", {
|
connection = stream.useChannel("userList", {
|
||||||
listId: props.list,
|
listId: props.list,
|
||||||
@ -204,6 +222,8 @@ if (props.src === "antenna") {
|
|||||||
endpoint = "channels/timeline";
|
endpoint = "channels/timeline";
|
||||||
query = {
|
query = {
|
||||||
channelId: props.channel,
|
channelId: props.channel,
|
||||||
|
sinceDate: props.sinceDate,
|
||||||
|
untilDate: props.untilDate,
|
||||||
};
|
};
|
||||||
connection = stream.useChannel("channel", {
|
connection = stream.useChannel("channel", {
|
||||||
channelId: props.channel,
|
channelId: props.channel,
|
||||||
@ -245,12 +265,11 @@ onUnmounted(() => {
|
|||||||
if (connection2) connection2.dispose();
|
if (connection2) connection2.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
/* TODO
|
|
||||||
const timetravel = (date?: Date) => {
|
function timetravel(date?: Date) {
|
||||||
this.date = date;
|
this.sinceDate = date;
|
||||||
this.$refs.tl.reload();
|
this.$refs.tl.reload();
|
||||||
};
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
const newPostsButton = computed(
|
const newPostsButton = computed(
|
||||||
defaultStore.makeGetterSetter("newPostsButton"),
|
defaultStore.makeGetterSetter("newPostsButton"),
|
||||||
|
@ -53,6 +53,8 @@
|
|||||||
:key="src"
|
:key="src"
|
||||||
class="tl"
|
class="tl"
|
||||||
:src="src"
|
:src="src"
|
||||||
|
:sinceDate="sinceDate"
|
||||||
|
:untilDate="untilDate"
|
||||||
:sound="true"
|
:sound="true"
|
||||||
/>
|
/>
|
||||||
</swiper-slide>
|
</swiper-slide>
|
||||||
@ -77,6 +79,7 @@ import { instance } from "@/instance";
|
|||||||
import { $i } from "@/account";
|
import { $i } from "@/account";
|
||||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||||
import { deviceKind } from "@/scripts/device-kind";
|
import { deviceKind } from "@/scripts/device-kind";
|
||||||
|
import { useRouter } from "@/router.js";
|
||||||
import "swiper/scss";
|
import "swiper/scss";
|
||||||
import "swiper/scss/virtual";
|
import "swiper/scss/virtual";
|
||||||
|
|
||||||
@ -97,6 +100,8 @@ const keymap = {
|
|||||||
|
|
||||||
let timelines = ["home"];
|
let timelines = ["home"];
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
if (isLocalTimelineAvailable) {
|
if (isLocalTimelineAvailable) {
|
||||||
timelines.push("local");
|
timelines.push("local");
|
||||||
}
|
}
|
||||||
@ -121,7 +126,7 @@ window.addEventListener("resize", () => {
|
|||||||
deviceKind === "smartphone" || window.innerWidth <= MOBILE_THRESHOLD;
|
deviceKind === "smartphone" || window.innerWidth <= MOBILE_THRESHOLD;
|
||||||
});
|
});
|
||||||
|
|
||||||
const tlComponent = $ref<InstanceType<typeof XTimeline>>();
|
const tl = $ref<InstanceType<typeof XTimeline>>();
|
||||||
const rootEl = $ref<HTMLElement>();
|
const rootEl = $ref<HTMLElement>();
|
||||||
|
|
||||||
const src = $computed({
|
const src = $computed({
|
||||||
@ -132,6 +137,26 @@ const src = $computed({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getUrlParams = () =>
|
||||||
|
window.location.search
|
||||||
|
.substring(1)
|
||||||
|
.split("&")
|
||||||
|
.reduce((result, query) => {
|
||||||
|
const [k, v] = query.split("=");
|
||||||
|
result[k] = decodeURIComponent(v?.replace('+', '%20'));
|
||||||
|
return result;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
const sinceDate = $computed({
|
||||||
|
get: () => getUrlParams()['sinceDate'] !== undefined ? Number(getUrlParams()['sinceDate']) * 1000 : undefined,
|
||||||
|
set: (x) => x,
|
||||||
|
});
|
||||||
|
|
||||||
|
const untilDate = $computed({
|
||||||
|
get: () => getUrlParams()['untilDate'] !== undefined ? Number(getUrlParams()['untilDate']) * 1000 : undefined,
|
||||||
|
set: (x) => x,
|
||||||
|
});
|
||||||
|
|
||||||
const lists = os.api("users/lists/list");
|
const lists = os.api("users/lists/list");
|
||||||
async function chooseList(ev: MouseEvent) {
|
async function chooseList(ev: MouseEvent) {
|
||||||
await lists.then((res) => {
|
await lists.then((res) => {
|
||||||
@ -191,13 +216,16 @@ async function timetravel(): Promise<void> {
|
|||||||
const { canceled, result: date } = await os.inputDate({
|
const { canceled, result: date } = await os.inputDate({
|
||||||
title: i18n.ts.date,
|
title: i18n.ts.date,
|
||||||
});
|
});
|
||||||
if (canceled) return;
|
if (canceled || isNaN(date.getTime())) return;
|
||||||
|
|
||||||
tlComponent.timetravel(date);
|
const dateUnix = Math.floor(date.getTime() / 1000);
|
||||||
|
|
||||||
|
router.push(`/?untilDate=${dateUnix}`);
|
||||||
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
function focus(): void {
|
function focus(): void {
|
||||||
tlComponent.focus();
|
tl.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerActions = $computed(() => [
|
const headerActions = $computed(() => [
|
||||||
|
Loading…
Reference in New Issue
Block a user