From c15fb6462938fcdd586cdd4bc53e8f114be90234 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 6 Oct 2020 13:16:56 -0500 Subject: [PATCH] interface: remove unused Type declarations and permission reducers --- pkg/interface/src/logic/lib/Home.ts | 1 - .../src/logic/reducers/permission-update.ts | 66 --------------- pkg/interface/src/logic/store/store.ts | 4 - pkg/interface/src/logic/store/type.ts | 3 +- pkg/interface/src/types/link-listen-update.ts | 18 ---- pkg/interface/src/types/link-update.ts | 84 ------------------- pkg/interface/src/types/permission-update.ts | 55 ------------ 7 files changed, 1 insertion(+), 230 deletions(-) delete mode 100644 pkg/interface/src/logic/lib/Home.ts delete mode 100644 pkg/interface/src/logic/reducers/permission-update.ts delete mode 100644 pkg/interface/src/types/link-listen-update.ts delete mode 100644 pkg/interface/src/types/link-update.ts delete mode 100644 pkg/interface/src/types/permission-update.ts diff --git a/pkg/interface/src/logic/lib/Home.ts b/pkg/interface/src/logic/lib/Home.ts deleted file mode 100644 index 8b1378917..000000000 --- a/pkg/interface/src/logic/lib/Home.ts +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pkg/interface/src/logic/reducers/permission-update.ts b/pkg/interface/src/logic/reducers/permission-update.ts deleted file mode 100644 index 0d3dd438f..000000000 --- a/pkg/interface/src/logic/reducers/permission-update.ts +++ /dev/null @@ -1,66 +0,0 @@ -import _ from 'lodash'; -import { StoreState } from '../../store/type'; -import { Cage } from '~/types/cage'; -import { PermissionUpdate } from '~/types/permission-update'; - -type PermissionState = Pick; - -export default class PermissionReducer { - reduce(json: Cage, state: S) { - const data = _.get(json, 'permission-update', false); - if (data) { - this.initial(data, state); - this.create(data, state); - this.delete(data, state); - this.add(data, state); - this.remove(data, state); - } - } - - initial(json: PermissionUpdate, state: S) { - const data = _.get(json, 'initial', false); - if (data) { - for (const perm in data) { - state.permissions[perm] = { - who: new Set(data[perm].who), - kind: data[perm].kind - }; - } - } - } - - create(json: PermissionUpdate, state: S) { - const data = _.get(json, 'create', false); - if (data) { - state.permissions[data.path] = { - kind: data.kind, - who: new Set(data.who) - }; - } - } - - delete(json: PermissionUpdate, state: S) { - const data = _.get(json, 'delete', false); - if (data) { - delete state.permissions[data.path]; - } - } - - add(json: PermissionUpdate, state: S) { - const data = _.get(json, 'add', false); - if (data) { - for (const member of data.who) { - state.permissions[data.path].who.add(member); - } - } - } - - remove(json: PermissionUpdate, state: S) { - const data = _.get(json, 'remove', false); - if (data) { - for (const member of data.who) { - state.permissions[data.path].who.delete(member); - } - } - } -} diff --git a/pkg/interface/src/logic/store/store.ts b/pkg/interface/src/logic/store/store.ts index 4175f442c..14f523e31 100644 --- a/pkg/interface/src/logic/store/store.ts +++ b/pkg/interface/src/logic/store/store.ts @@ -10,7 +10,6 @@ import ContactReducer from '../reducers/contact-update'; import S3Reducer from '../reducers/s3-update'; import { GraphReducer } from '../reducers/graph-update'; import GroupReducer from '../reducers/group-update'; -import PermissionReducer from '../reducers/permission-update'; import PublishUpdateReducer from '../reducers/publish-update'; import PublishResponseReducer from '../reducers/publish-response'; import LaunchReducer from '../reducers/launch-update'; @@ -38,7 +37,6 @@ export default class GlobalStore extends BaseStore { contactReducer = new ContactReducer(); s3Reducer = new S3Reducer(); groupReducer = new GroupReducer(); - permissionReducer = new PermissionReducer(); publishUpdateReducer = new PublishUpdateReducer(); publishResponseReducer = new PublishResponseReducer(); launchReducer = new LaunchReducer(); @@ -88,7 +86,6 @@ export default class GlobalStore extends BaseStore { }, weather: {}, userLocation: null, - permissions: {}, s3: { configuration: { buckets: new Set(), @@ -112,7 +109,6 @@ export default class GlobalStore extends BaseStore { this.contactReducer.reduce(data, this.state); this.s3Reducer.reduce(data, this.state); this.groupReducer.reduce(data, this.state); - this.permissionReducer.reduce(data, this.state); this.publishUpdateReducer.reduce(data, this.state); this.publishResponseReducer.reduce(data, this.state); this.launchReducer.reduce(data, this.state); diff --git a/pkg/interface/src/logic/store/type.ts b/pkg/interface/src/logic/store/type.ts index 8e6269dd3..a7b666b62 100644 --- a/pkg/interface/src/logic/store/type.ts +++ b/pkg/interface/src/logic/store/type.ts @@ -7,7 +7,6 @@ import { Rolodex } from '~/types/contact-update'; import { Notebooks } from '~/types/publish-update'; import { Groups } from '~/types/group-update'; import { S3State } from '~/types/s3-update'; -import { Permissions } from '~/types/permission-update'; import { LaunchState, WeatherState } from '~/types/launch-update'; import { ConnectionStatus } from '~/types/connection'; import { BackgroundConfig, LocalUpdateRemoteContentPolicy } from '~/types/local-update'; @@ -25,6 +24,7 @@ export interface StoreState { remoteContentPolicy: LocalUpdateRemoteContentPolicy; hideAvatars: boolean; hideNicknames: boolean; + // invite state invites: Invites; // metadata state @@ -34,7 +34,6 @@ export interface StoreState { // groups state groups: Groups; groupKeys: Set; - permissions: Permissions; s3: S3State; graphs: Graphs; graphKeys: Set; diff --git a/pkg/interface/src/types/link-listen-update.ts b/pkg/interface/src/types/link-listen-update.ts deleted file mode 100644 index 3ba9f76c7..000000000 --- a/pkg/interface/src/types/link-listen-update.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Path } from './noun'; - -interface LinkListenUpdateListening { - listening: Path[]; -} - -interface LinkListenUpdateWatch { - watch: Path; -} - -interface LinkListenUpdateLeave { - leave: Path; -} - -export type LinkListenUpdate = - LinkListenUpdateListening -| LinkListenUpdateWatch -| LinkListenUpdateLeave; diff --git a/pkg/interface/src/types/link-update.ts b/pkg/interface/src/types/link-update.ts deleted file mode 100644 index 4cbfeb1d5..000000000 --- a/pkg/interface/src/types/link-update.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { PatpNoSig, Path } from "./noun"; - -export type LinkCollections = { - [p in Path]: Collection; -}; - -export type LinkSeen = { - [p in Path]: { - [url: string]: boolean; - }; -}; - -export type Pagination = { - local: LocalPages; - [p: number]: S[]; - totalItems: number; - totalPages: number; -} - -export type LinkComments = { - [p in Path]: { - [url: string]: Pagination & { - totalItems: number; - totalPages: number; - } - } -} - -interface LinkComment { - ship: PatpNoSig; - time: number; - udon: string; -} - -interface CollectionStats { - unseenCount: number; -} - -type LocalPages = { - [p: number]: boolean; -} - -type Collection = CollectionStats & Pagination; - -interface Link { - commentCount: number; - seen: boolean; - ship: PatpNoSig; - time: number; - title: string; - url: string; -} - -interface LinkInitialSubmissions { - 'initial-submissions': { - [p in Path]: CollectionStats & { - pageNumber?: number; - pages?: Link[]; - } - }; -}; - -interface LinkUpdateSubmission { - 'submissions': { - path: Path; - pages: Link[]; - } -} - -interface LinkInitialDiscussion { - 'intitial-discussion': { - path: Path; - url: string; - page: Comment[]; - totalItems: number; - totalPages: number; - pageNumber: number; - } -} - -export type LinkUpdate = - LinkInitialSubmissions -| LinkUpdateSubmission -| LinkInitialDiscussion; diff --git a/pkg/interface/src/types/permission-update.ts b/pkg/interface/src/types/permission-update.ts deleted file mode 100644 index 6d076f2c7..000000000 --- a/pkg/interface/src/types/permission-update.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Path, PatpNoSig } from './noun'; - -export type PermissionUpdate = - PermissionUpdateInitial -| PermissionUpdateCreate -| PermissionUpdateDelete -| PermissionUpdateRemove -| PermissionUpdateAdd; - -interface PermissionUpdateInitial { - initial: { - [p in Path]: { - who: PatpNoSig[]; - kind: PermissionKind; - }; - } -} - -interface PermissionUpdateCreate { - create: { - path: Path; - kind: PermissionKind; - who: PatpNoSig[]; - } -} - -interface PermissionUpdateDelete { - delete: { - path: Path; - } -} - -interface PermissionUpdateAdd { - add: { - path: Path; - who: PatpNoSig[]; - } -} - -interface PermissionUpdateRemove { - remove: { - path: Path; - who: PatpNoSig[]; - } -} - -export type Permissions = { - [p in Path]: Permission; -}; -export interface Permission { - who: Set; - kind: PermissionKind; -} - -export type PermissionKind = 'white' | 'black';