Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • cf2023-euro
  • cf2023-offline
  • cf2024
  • cf2025
  • main
5 results

Target

Select target project
  • to/cf-online-ui
  • vpfafrin/cf2021
2 results
Select Git revision
  • master
1 result
Show changes
......@@ -6,5 +6,8 @@ export const handleOnlineUsersUpdated = (payload) => {
GlobalInfoStore.update((state) => {
state.onlineUsers = isNumber(payload.all) ? payload.all : 0;
state.onlineMembers = isNumber(payload.members) ? payload.members : 0;
state.groupSizeHalf = isNumber(payload.group_size_half)
? payload.group_size_half
: null;
});
};
import has from "lodash/has";
import throttle from "lodash/throttle";
import { markdownConverter } from "markdown";
import { PostStore } from "stores";
import { parseRawPost, postsStateMapping, updateWindowPosts } from "utils";
/**
* Re-apply sorting by rank but no more than once every 3 seconds.
*/
const sortOnRankThrottled = throttle(() => {
PostStore.update((state) => {
if (state.filters.sort === "byScore") {
updateWindowPosts(state);
}
});
}, 5000);
export const handlePostRanked = (payload) => {
PostStore.update((state) => {
if (state.items[payload.id]) {
......@@ -12,12 +24,11 @@ export const handlePostRanked = (payload) => {
state.items[payload.id].ranking.score =
state.items[payload.id].ranking.likes -
state.items[payload.id].ranking.dislikes;
if (state.filters.sort === "byScore") {
updateWindowPosts(state);
}
}
});
// Run sorting in a throttled manner.
sortOnRankThrottled();
};
export const handlePostChanged = (payload) => {
......@@ -26,21 +37,21 @@ export const handlePostChanged = (payload) => {
if (has(payload, "content")) {
state.items[payload.id].content = payload.content;
state.items[payload.id].contentHtml = markdownConverter.makeHtml(
payload.content
payload.content,
);
state.items[payload.id].modified = true;
}
if (has(payload, "state")) {
state.items[payload.id].state = postsStateMapping[payload.state];
updateWindowPosts(state);
}
if (has(payload, "is_archived")) {
state.items[payload.id].archived = payload.is_archived;
}
updateWindowPosts(state);
}
}
});
};
......
import has from "lodash/has";
import { loadPosts } from "actions/posts";
import { markdownConverter } from "markdown";
import { ProgramStore } from "stores";
export const handleProgramEntryChanged = (payload) => {
ProgramStore.update((state) => {
if (state.items[payload.id]) {
const entry = state.items[payload.id];
if (entry) {
if (has(payload, "discussion_opened")) {
state.items[payload.id].discussionOpened = payload.discussion_opened;
}
if (has(payload, "title")) {
state.items[payload.id].title = payload.title;
state.items[payload.id].fullTitle =
entry.number !== "" ? `${entry.number}. ${entry.title}` : entry.title;
}
if (has(payload, "description")) {
state.items[payload.id].description = payload.description;
state.items[payload.id].htmlContent = markdownConverter.makeHtml(
payload.description,
);
}
if (has(payload, "is_live") && payload.is_live) {
state.currentId = payload.id;
}
}
});
if (has(payload, "is_live") && payload.is_live) {
// Re-load posts - these are bound directly to the program schedule entry.
loadPosts.run({}, { respectCache: false });
}
};
declare namespace CF2021 {
export interface GlobalInfoStorePayload {
connectionState: "connected" | "offline" | "connecting";
onlineMembers: number;
onlineUsers: number;
websocketUrl: string;
groupSizeHalf?: number;
streamUrl?: string;
protocolUrl?: string;
protocol?: string;
......@@ -12,9 +14,12 @@ declare namespace CF2021 {
id: number;
number: string;
title: string;
fullTitle: string;
proposer: string;
speakers: string;
discussionOpened: boolean;
description?: string;
htmlContent?: string;
expectedStartAt: Date;
expectedFinishAt?: Date;
}
......@@ -153,8 +158,6 @@ declare namespace CF2021 {
window: {
items: string[];
itemCount: number;
page: number;
perPage: number;
};
filters: PostStoreFilters;
}
......