Skip to content
Snippets Groups Projects
Select Git revision
  • 82a6e76c6a82135178d6dd64a77a97bc6f065181
  • test default protected
  • master protected
  • feat/custom-css
  • feat/redesign-improvements-10
  • feat/redesign-improvements-8
  • feat/redesign-fixes-3
  • feat/pirstan-changes
  • feat/separate-import-thread
  • feat/dary-improvements
  • features/add-pdf-page
  • features/add-typed-table
  • features/fix-broken-calendar-categories
  • features/add-embed-to-articles
  • features/create-mastodon-feed-block
  • features/add-custom-numbering-for-candidates
  • features/add-timeline
  • features/create-wordcloud-from-article-page
  • features/create-collapsible-extra-legal-info
  • features/extend-hero-banner
  • features/add-link-to-images
21 results

0005_mainpersonpage_twitter_username_and_more.py

Blame
  • stores.js 8.20 KiB
    import keyBy from "lodash/keyBy";
    import memoize from "lodash/memoize";
    import property from "lodash/property";
    import { Store } from "pullstate";
    
    import { filterPosts } from "utils";
    
    /** @type {CF2021.AuthStorePayload} */
    const authStoreInitial = {
      isAuthenticated: false,
      groupMappings: [],
    };
    
    export const AuthStore = new Store(authStoreInitial);
    
    /** @type {CF2021.AnnouncementStorePayload} */
    const announcementStoreInitial = {
      items: [
        {
          id: "1",
          content:
            "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
          datetime: new Date(),
          seen: false,
          type: "rejected-procedure-proposal",
        },
        {
          id: "2",
          content:
            "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
          datetime: new Date(),
          seen: false,
          type: "accepted-procedure-proposal",
        },
        {
          id: "3",
          content:
            "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
          datetime: new Date(),
          seen: true,
          type: "suggested-procedure-proposal",
        },
        {
          id: "4",
          content:
            "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
          datetime: new Date(),
          seen: true,
          type: "voting",
        },
        {
          id: "5",
          content:
            "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
          datetime: new Date(),
          seen: true,
          type: "announcement",
        },
        {
          id: "6",
          content:
            "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
          datetime: new Date(),
          seen: true,
          type: "user-ban",
        },
      ],
    };
    
    export const AnnouncementStore = new Store(announcementStoreInitial);
    
    const allPosts = [
      {
        id: "1",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "cf",
        },
        ranking: {
          likes: 0,
          dislikes: 0,
          score: 0,
          myVote: "none",
        },
        seen: false,
        archived: false,
        type: "post",
      },
      {
        id: "2",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "cf",
        },
        ranking: {
          likes: 1,
          dislikes: 0,
          score: 1,
          myVote: "none",
        },
        seen: false,
        archived: false,
        type: "post",
      },
      {
        id: "3",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "cf",
        },
        ranking: {
          likes: 5,
          dislikes: 5,
          score: 0,
          myVote: "none",
        },
        seen: true,
        archived: false,
        type: "post",
      },
      {
        id: "4",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "KS Pardubický kraj",
        },
        ranking: {
          likes: 0,
          dislikes: 10,
          score: -10,
          myVote: "none",
        },
        seen: true,
        archived: false,
        type: "post",
      },
      {
        id: "5",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "KS Pardubický kraj",
        },
        ranking: {
          likes: 1,
          dislikes: 1,
          score: 0,
          myVote: "none",
        },
        seen: true,
        archived: false,
        type: "post",
      },
      {
        id: "6",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "KS Pardubický kraj",
        },
        ranking: {
          likes: 5,
          dislikes: 3,
          score: 2,
          myVote: "none",
        },
        seen: true,
        archived: true,
        type: "post",
      },
      {
        id: "7",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "KS Pardubický kraj",
        },
        ranking: {
          likes: 5,
          dislikes: 8,
          score: -3,
          myVote: "none",
        },
        seen: true,
        archived: true,
        type: "procedure-proposal",
        state: "pending",
      },
      {
        id: "8",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "KS Pardubický kraj",
        },
        ranking: {
          likes: 2,
          dislikes: 1,
          score: 1,
          myVote: "like",
        },
        seen: true,
        archived: false,
        type: "procedure-proposal",
        state: "announced",
        historyLog: [
          {
            attribute: "content",
            datetime: new Date(),
            newValue: "Lemme know",
            originator: "chairman",
          },
        ],
      },
      {
        id: "9",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "KS Pardubický kraj",
        },
        ranking: {
          likes: 5,
          dislikes: 0,
          score: 5,
          myVote: "dislike",
        },
        seen: true,
        archived: false,
        type: "procedure-proposal",
        state: "accepted",
      },
      {
        id: "10",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "KS Pardubický kraj",
        },
        ranking: {
          likes: 5,
          dislikes: 8,
          score: -3,
          myVote: "none",
        },
        seen: true,
        archived: false,
        type: "procedure-proposal",
        state: "rejected",
      },
      {
        id: "11",
        content:
          "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
        datetime: new Date(),
        author: {
          name: "John Doe",
          group: "KS Pardubický kraj",
        },
        ranking: {
          likes: 10,
          dislikes: 1,
          score: 9,
          myVote: "none",
        },
        seen: true,
        archived: true,
        type: "procedure-proposal",
        state: "rejected-by-chairman",
      },
    ];
    
    const initialPostFilters = {
      flags: "all",
      sort: "byDate",
      type: "all",
    };
    
    const filteredPosts = filterPosts(initialPostFilters, allPosts);
    
    /** @type {CF2021.PostStorePayload} */
    const postStoreInitial = {
      items: keyBy(allPosts, property("id")),
      itemCount: allPosts.length,
      window: {
        items: filteredPosts.map(property("id")),
        itemCount: filteredPosts.length,
        page: 1,
        perPage: 5,
      },
      filters: initialPostFilters,
    };
    
    export const PostStore = new Store(postStoreInitial);
    
    export const getGroupByCode = memoize(
      (groupMappings, groupCode) => {
        return groupMappings.find((gm) => gm.code === groupCode);
      },
      (groupMappings, groupCode) => [groupMappings, groupCode]
    );
    
    export const getGroupsByCode = memoize((groupMappings, groupCodes) => {
      return groupCodes.map((code) => getGroupByCode(groupMappings, code));
    });