mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-13 08:38:43 +03:00
interface: remove unused Type declarations and permission reducers
This commit is contained in:
parent
7c3a43984c
commit
c15fb64629
@ -1 +0,0 @@
|
|||||||
|
|
@ -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<StoreState, "permissions">;
|
|
||||||
|
|
||||||
export default class PermissionReducer<S extends PermissionState> {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,6 @@ import ContactReducer from '../reducers/contact-update';
|
|||||||
import S3Reducer from '../reducers/s3-update';
|
import S3Reducer from '../reducers/s3-update';
|
||||||
import { GraphReducer } from '../reducers/graph-update';
|
import { GraphReducer } from '../reducers/graph-update';
|
||||||
import GroupReducer from '../reducers/group-update';
|
import GroupReducer from '../reducers/group-update';
|
||||||
import PermissionReducer from '../reducers/permission-update';
|
|
||||||
import PublishUpdateReducer from '../reducers/publish-update';
|
import PublishUpdateReducer from '../reducers/publish-update';
|
||||||
import PublishResponseReducer from '../reducers/publish-response';
|
import PublishResponseReducer from '../reducers/publish-response';
|
||||||
import LaunchReducer from '../reducers/launch-update';
|
import LaunchReducer from '../reducers/launch-update';
|
||||||
@ -38,7 +37,6 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
|||||||
contactReducer = new ContactReducer();
|
contactReducer = new ContactReducer();
|
||||||
s3Reducer = new S3Reducer();
|
s3Reducer = new S3Reducer();
|
||||||
groupReducer = new GroupReducer();
|
groupReducer = new GroupReducer();
|
||||||
permissionReducer = new PermissionReducer();
|
|
||||||
publishUpdateReducer = new PublishUpdateReducer();
|
publishUpdateReducer = new PublishUpdateReducer();
|
||||||
publishResponseReducer = new PublishResponseReducer();
|
publishResponseReducer = new PublishResponseReducer();
|
||||||
launchReducer = new LaunchReducer();
|
launchReducer = new LaunchReducer();
|
||||||
@ -88,7 +86,6 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
|||||||
},
|
},
|
||||||
weather: {},
|
weather: {},
|
||||||
userLocation: null,
|
userLocation: null,
|
||||||
permissions: {},
|
|
||||||
s3: {
|
s3: {
|
||||||
configuration: {
|
configuration: {
|
||||||
buckets: new Set(),
|
buckets: new Set(),
|
||||||
@ -112,7 +109,6 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
|||||||
this.contactReducer.reduce(data, this.state);
|
this.contactReducer.reduce(data, this.state);
|
||||||
this.s3Reducer.reduce(data, this.state);
|
this.s3Reducer.reduce(data, this.state);
|
||||||
this.groupReducer.reduce(data, this.state);
|
this.groupReducer.reduce(data, this.state);
|
||||||
this.permissionReducer.reduce(data, this.state);
|
|
||||||
this.publishUpdateReducer.reduce(data, this.state);
|
this.publishUpdateReducer.reduce(data, this.state);
|
||||||
this.publishResponseReducer.reduce(data, this.state);
|
this.publishResponseReducer.reduce(data, this.state);
|
||||||
this.launchReducer.reduce(data, this.state);
|
this.launchReducer.reduce(data, this.state);
|
||||||
|
@ -7,7 +7,6 @@ import { Rolodex } from '~/types/contact-update';
|
|||||||
import { Notebooks } from '~/types/publish-update';
|
import { Notebooks } from '~/types/publish-update';
|
||||||
import { Groups } from '~/types/group-update';
|
import { Groups } from '~/types/group-update';
|
||||||
import { S3State } from '~/types/s3-update';
|
import { S3State } from '~/types/s3-update';
|
||||||
import { Permissions } from '~/types/permission-update';
|
|
||||||
import { LaunchState, WeatherState } from '~/types/launch-update';
|
import { LaunchState, WeatherState } from '~/types/launch-update';
|
||||||
import { ConnectionStatus } from '~/types/connection';
|
import { ConnectionStatus } from '~/types/connection';
|
||||||
import { BackgroundConfig, LocalUpdateRemoteContentPolicy } from '~/types/local-update';
|
import { BackgroundConfig, LocalUpdateRemoteContentPolicy } from '~/types/local-update';
|
||||||
@ -25,6 +24,7 @@ export interface StoreState {
|
|||||||
remoteContentPolicy: LocalUpdateRemoteContentPolicy;
|
remoteContentPolicy: LocalUpdateRemoteContentPolicy;
|
||||||
hideAvatars: boolean;
|
hideAvatars: boolean;
|
||||||
hideNicknames: boolean;
|
hideNicknames: boolean;
|
||||||
|
|
||||||
// invite state
|
// invite state
|
||||||
invites: Invites;
|
invites: Invites;
|
||||||
// metadata state
|
// metadata state
|
||||||
@ -34,7 +34,6 @@ export interface StoreState {
|
|||||||
// groups state
|
// groups state
|
||||||
groups: Groups;
|
groups: Groups;
|
||||||
groupKeys: Set<Path>;
|
groupKeys: Set<Path>;
|
||||||
permissions: Permissions;
|
|
||||||
s3: S3State;
|
s3: S3State;
|
||||||
graphs: Graphs;
|
graphs: Graphs;
|
||||||
graphKeys: Set<string>;
|
graphKeys: Set<string>;
|
||||||
|
@ -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;
|
|
@ -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<S> = {
|
|
||||||
local: LocalPages;
|
|
||||||
[p: number]: S[];
|
|
||||||
totalItems: number;
|
|
||||||
totalPages: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type LinkComments = {
|
|
||||||
[p in Path]: {
|
|
||||||
[url: string]: Pagination<LinkComment> & {
|
|
||||||
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<Link>;
|
|
||||||
|
|
||||||
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;
|
|
@ -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<PatpNoSig>;
|
|
||||||
kind: PermissionKind;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type PermissionKind = 'white' | 'black';
|
|
Loading…
Reference in New Issue
Block a user