Skip to content
Snippets Groups Projects
Select Git revision
  • 456657f1e04131bd19d3c2baed3db18d2c0b3761
  • master default protected
  • dependabot/pip/py-1.10.0
  • dependabot/pip/django-2.2.13
  • dependabot/pip/bleach-3.1.4
5 results

test_views.py

Blame
  • stores.js 1.50 KiB
    import memoize from "lodash/memoize";
    import { Store } from "pullstate";
    
    /** @type {CF2021.GlobalInfoStorePayload} */
    const globalInfoStoreInitial = {
      connectionState: "connecting",
      onlineMembers: 0,
      onlineUsers: 0,
      streamUrl: null,
    };
    
    export const GlobalInfoStore = new Store(globalInfoStoreInitial);
    
    /** @type {CF2021.AuthStorePayload} */
    const authStoreInitial = {
      isAuthenticated: false,
    };
    
    export const AuthStore = new Store(authStoreInitial);
    
    /** @type {CF2021.ProgramStorePayload} */
    const programStoreInitial = {
      items: {},
      currentId: undefined,
      scheduleIds: [],
    };
    
    export const ProgramStore = new Store(programStoreInitial);
    
    /** @type {CF2021.AnnouncementStorePayload} */
    const announcementStoreInitial = {
      items: {},
      itemIds: [],
    };
    
    export const AnnouncementStore = new Store(announcementStoreInitial);
    
    /** @type {CF2021.PostStorePayload} */
    const postStoreInitial = {
      items: {},
      itemCount: 0,
      window: {
        items: [],
        itemCount: 0,
        page: 1,
        perPage: 20,
      },
      filters: {
        flags: "all",
        sort: "byDate",
        type: "all",
        showPendingProposals: false,
      },
    };
    
    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));
    });