}
type Configuration = {
- endpoint: string;
+ endpoint: string | ((objectId: number) => Promise<string>);
identifier: string;
selector: string;
};
export class SharedCache {
readonly #data = new Map<ObjectId, string>();
- readonly #endpoint: URL;
-
- constructor(endpoint: string) {
- this.#endpoint = new URL(endpoint);
+ readonly #callback: (objectId: number) => Promise<string>;
+
+ constructor(endpoint: string | ((objectId: number) => Promise<string>)) {
+ if (typeof endpoint === "string") {
+ this.#callback = async (objectId: number) => {
+ const url = new URL(endpoint);
+ url.searchParams.set("id", objectId.toString());
+ const response = await prepareRequest(url).get().fetchAsResponse();
+ if (!response?.ok) {
+ return "";
+ }
+
+ return await response.text();
+ };
+ } else {
+ this.#callback = endpoint;
+ }
}
async get(objectId: ObjectId): Promise<string> {
return content;
}
- this.#endpoint.searchParams.set("id", objectId.toString());
-
- const response = await prepareRequest(this.#endpoint).get().fetchAsResponse();
- if (!response?.ok) {
- return "";
- }
-
- content = await response.text();
+ content = await this.#callback(objectId);
this.#data.set(objectId, content);
return content;
exports.SharedCache = void 0;
class SharedCache {
#data = new Map();
- #endpoint;
+ #callback;
constructor(endpoint) {
- this.#endpoint = new URL(endpoint);
+ if (typeof endpoint === "string") {
+ this.#callback = async (objectId) => {
+ const url = new URL(endpoint);
+ url.searchParams.set("id", objectId.toString());
+ const response = await (0, Backend_1.prepareRequest)(url).get().fetchAsResponse();
+ if (!response?.ok) {
+ return "";
+ }
+ return await response.text();
+ };
+ }
+ else {
+ this.#callback = endpoint;
+ }
}
async get(objectId) {
let content = this.#data.get(objectId);
if (content !== undefined) {
return content;
}
- this.#endpoint.searchParams.set("id", objectId.toString());
- const response = await (0, Backend_1.prepareRequest)(this.#endpoint).get().fetchAsResponse();
- if (!response?.ok) {
- return "";
- }
- content = await response.text();
+ content = await this.#callback(objectId);
this.#data.set(objectId, content);
return content;
}
max-height: var(--maxHeight);
max-width: var(--maxWidth);
opacity: 0;
+ overflow: hidden;
padding: var(--padding);
position: absolute;
transform: translateY(-20px);
display: block;
}
}
+
+.popover__layout {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+}
+
+.popover__header {
+ display: grid;
+ grid-template-areas:
+ "avatar title"
+ "avatar time";
+ grid-template-columns: min-content 1fr;
+ grid-template-rows: min-content 1fr;
+ column-gap: 10px;
+ margin-bottom: 10px;
+}
+
+.popover__avatar {
+ grid-area: avatar;
+}
+
+.popover__title {
+ grid-area: title;
+ font-weight: 600;
+ @include wcfFontHeadline;
+}
+
+.popover__title a,
+.popover__title a:hover {
+ color: inherit;
+}
+
+.popover__time {
+ color: var(--wcfContentDimmedText);
+ grid-area: time;
+ @include wcfFontSmall;
+}