Skip to content

Commit

Permalink
Remove multiTs from location hash (#340)
Browse files Browse the repository at this point in the history
Just keep as regular property on Item, as no need to read it from user
input, as multiTs is looked up from wabac API.
  • Loading branch information
ikreymer authored Jun 21, 2024
1 parent 105562a commit 11ca78c
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export type EmbedReplayEvent = EmbedReplayData & {
};

export type TabData = EmbedReplayData & {
multiTs?: string[];
currList?: number;
urlSearchType?: string;
currMime?: string;
Expand Down Expand Up @@ -189,6 +188,9 @@ class Item extends LitElement {
@property({ type: Boolean })
replayNotFoundError = false;

@property({ type: Array })
multiTs?: string[] = [];

private splitter: Split.Instance | null = null;

private _replaceLoc = false;
Expand Down Expand Up @@ -262,10 +264,11 @@ class Item extends LitElement {
window.encodeURIComponent(this.tabData.url),
);
if (resp.status !== 200) {
this.multiTs = [];
return;
}
const json = await resp.json();
this.updateTabData({ multiTs: json.timestamps }, true);
this.multiTs = json.timestamps;
}

willUpdate(changedProperties: Map<string, Record<string, unknown>>) {
Expand All @@ -274,12 +277,8 @@ class Item extends LitElement {
const tabData: TabData = {};
Object.entries(this.tabData).forEach(([key, value]) => {
if (!value) return;
if (key === "multiTs" && typeof value === "string") {
tabData[key] = value.split(",");
} else {
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7053 - Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
tabData[key] = value;
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7053 - Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
tabData[key] = value;
});
this.tabData = tabData;

Expand All @@ -291,18 +290,8 @@ class Item extends LitElement {
}

updated(changedProperties: PropertyValues<this>) {
// if (changedProperties.has("url") || changedProperties.has("ts")) {
// if (this.url.startsWith("rwp?")) {
// this.tabData = Object.fromEntries(new URLSearchParams(this.url.slice(4)).entries());
// } else {
// this.tabData = {view: "replay", url: this.url, ts: this.ts};
// }
// }

if (changedProperties.has("sourceUrl")) {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.doUpdateInfo();
void this.doUpdateInfo();
}
if (changedProperties.has("editable")) {
if (this.editable && this.autoUpdateInterval && !this._autoUpdater) {
Expand Down Expand Up @@ -1422,7 +1411,7 @@ class Item extends LitElement {

private renderTimestamp() {
const timestampStrs: { date: string; label: string }[] = [];
this.tabData.multiTs?.forEach((ts) => {
this.multiTs?.forEach((ts) => {
// Filter out invalid dates
try {
const date = getDateFromTS(+ts);
Expand Down

0 comments on commit 11ca78c

Please sign in to comment.