Merge remote-tracking branch 'origin/release/next-js' into jo/gcp/conf

This commit is contained in:
Jōshin 2021-04-06 22:31:01 +00:00
commit 78faf9ba25
No known key found for this signature in database
GPG Key ID: A8BE5A9A521639D0
12 changed files with 66 additions and 60 deletions

View File

@ -1783,30 +1783,36 @@
"dependencies": {
"@babel/runtime": {
"version": "7.12.5",
"bundled": true,
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.5.tgz",
"integrity": "sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==",
"requires": {
"regenerator-runtime": "^0.13.4"
}
},
"@types/lodash": {
"version": "4.14.168",
"bundled": true
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.168.tgz",
"integrity": "sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q=="
},
"@urbit/eslint-config": {
"version": "1.0.0",
"bundled": true
"resolved": "https://registry.npmjs.org/@urbit/eslint-config/-/eslint-config-1.0.0.tgz",
"integrity": "sha512-Xmzb6MvM7KorlPJEq/hURZZ4BHSVy/7CoQXWogsBSTv5MOZnMqwNKw6yt24k2AO/2UpHwjGptimaNLqFfesJbw=="
},
"big-integer": {
"version": "1.6.48",
"bundled": true
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.48.tgz",
"integrity": "sha512-j51egjPa7/i+RdiRuJbPdJ2FIUYYPhvYLjzoYbcMMm62ooO6F94fETG4MTs46zPAF9Brs04OajboA/qTGuz78w=="
},
"lodash": {
"version": "4.17.20",
"bundled": true
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
},
"regenerator-runtime": {
"version": "0.13.7",
"bundled": true
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz",
"integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew=="
}
}
},

View File

@ -98,9 +98,8 @@
"lint-file": "eslint",
"tsc": "tsc",
"tsc:watch": "tsc --watch",
"preinstall": "./preinstall.sh",
"build:dev": "cross-env NODE_ENV=development webpack --config config/webpack.dev.js",
"build:prod": "cross-env NODE_ENV=production webpack --config config/webpack.prod.js",
"build:prod": "cd ../npm/api && npm i && cd ../../interface && cross-env NODE_ENV=production webpack --config config/webpack.prod.js",
"start": "webpack-dev-server --config config/webpack.dev.js",
"test": "echo \"Error: no test specified\" && exit 1"
},

View File

@ -1,12 +0,0 @@
#!/bin/sh
cd ../npm
for i in $(find . -type d -maxdepth 1) ; do
packageJson="${i}/package.json"
if [ -f "${packageJson}" ]; then
echo "installing ${i}..."
cd ./${i}
npm install
cd ..
fi
done

View File

@ -1,7 +1,6 @@
import _ from 'lodash';
import {StoreState} from '../store/type';
import {GcpToken} from '../../types/gcp-state';
import { Cage } from '~/types/cage';
import type {GcpToken} from '../../types/gcp-state';
import type {Cage} from '~/types/cage';
import useStorageState, { StorageState } from '../state/storage';
import { reduceState } from '../state/base';
@ -16,7 +15,7 @@ export default class GcpReducer {
const reduceToken = (json: Cage, state: StorageState): StorageState => {
let data = json['gcp-token'];
if (data) {
state = setToken(data, state);
setToken(data, state);
}
return state;
}
@ -28,7 +27,7 @@ const setToken = (data: any, state: StorageState): StorageState => {
return state;
}
const isToken = (token: any): boolean => {
const isToken = (token: any): token is GcpToken => {
return (typeof(token.accessKey) === 'string' &&
typeof(token.expiresIn) === 'number');
}

View File

@ -17,7 +17,7 @@ import bigInt, {BigInteger} from 'big-integer';
export const HarkReducer = (json: any) => {
const data = _.get(json, 'harkUpdate', false);
if (data) {
reduce(data);
reduceState(useHarkState, data, [reduce]);
}
const graphHookData = _.get(json, 'hark-graph-hook-update', false);
if (graphHookData) {
@ -39,8 +39,9 @@ export const HarkReducer = (json: any) => {
}
};
function reduce(data) {
reduceState<HarkState, any>(useHarkState, data, [
function reduce(data, state) {
const reducers = [
calculateCount,
unread,
read,
archive,
@ -56,8 +57,11 @@ function reduce(data) {
seenIndex,
removeGraph,
readAll,
calculateCount
]);
];
const reducer = compose(reducers.map(r => s => {
return r(data, s);
}));
return reducer(state);
}
function calculateCount(json: any, state: HarkState) {
@ -148,7 +152,7 @@ function graphWatchSelf(json: any, state: HarkState): HarkState {
function readAll(json: any, state: HarkState): HarkState {
const data = _.get(json, 'read-all');
if(data) {
state = clearState(state);
clearState(state);
}
return state;
}
@ -164,7 +168,7 @@ function removeGraph(json: any, state: HarkState): HarkState {
function seenIndex(json: any, state: HarkState): HarkState {
const data = _.get(json, 'seen-index');
if(data) {
state = updateNotificationStats(state, data.index, 'last', () => data.time);
updateNotificationStats(state, data.index, 'last', () => data.time);
}
return state;
}
@ -172,7 +176,7 @@ function seenIndex(json: any, state: HarkState): HarkState {
function readEach(json: any, state: HarkState): HarkState {
const data = _.get(json, 'read-each');
if (data) {
state = updateUnreads(state, data.index, u => u.delete(data.target));
updateUnreads(state, data.index, u => u.delete(data.target));
}
return state;
}
@ -180,7 +184,7 @@ function readEach(json: any, state: HarkState): HarkState {
function readSince(json: any, state: HarkState): HarkState {
const data = _.get(json, 'read-count');
if(data) {
state = updateUnreadCount(state, data, () => 0);
updateUnreadCount(state, data, () => 0);
}
return state;
}
@ -188,7 +192,7 @@ function readSince(json: any, state: HarkState): HarkState {
function unreadSince(json: any, state: HarkState): HarkState {
const data = _.get(json, 'unread-count');
if(data) {
state = updateUnreadCount(state, data.index, u => u + 1);
updateUnreadCount(state, data.index, u => u + 1);
}
return state;
}
@ -196,7 +200,7 @@ function unreadSince(json: any, state: HarkState): HarkState {
function unreadEach(json: any, state: HarkState): HarkState {
const data = _.get(json, 'unread-each');
if(data) {
state = updateUnreads(state, data.index, us => us.add(data.target));
updateUnreads(state, data.index, us => us.add(data.target));
}
return state;
}
@ -204,7 +208,7 @@ function unreadEach(json: any, state: HarkState): HarkState {
function unreads(json: any, state: HarkState): HarkState {
const data = _.get(json, 'unreads');
if(data) {
state = clearState(state);
clearState(state);
data.forEach(({ index, stats }) => {
const { unreads, notifications, last } = stats;
updateNotificationStats(state, index, 'last', () => last);
@ -212,11 +216,11 @@ function unreads(json: any, state: HarkState): HarkState {
addNotificationToUnread(state, index, makePatDa(time));
});
if('count' in unreads) {
state = updateUnreadCount(state, index, (u = 0) => u + unreads.count);
updateUnreadCount(state, index, (u = 0) => u + unreads.count);
} else {
state = updateUnreads(state, index, s => new Set());
updateUnreads(state, index, s => new Set());
unreads.each.forEach((u: string) => {
state = updateUnreads(state, index, s => s.add(u));
updateUnreads(state, index, s => s.add(u));
});
}
});
@ -240,10 +244,8 @@ function clearState(state: HarkState): HarkState {
},
notificationsCount: 0
};
Object.assign(state, initialState);
Object.keys(initialState).forEach((key) => {
state[key] = initialState[key];
});
return state;
}
@ -361,7 +363,9 @@ const timebox = (json: any, state: HarkState): HarkState => {
function more(json: any, state: HarkState): HarkState {
const data = _.get(json, 'more', false);
if (data) {
_.forEach(data, d => reduce(d));
_.forEach(data, d => {
reduce(d, state);
});
}
return state;
}

View File

@ -25,7 +25,7 @@ export default class MetadataReducer {
const groupInitial = (json: MetadataUpdate, state: MetadataState): MetadataState => {
const data = _.get(json, 'initial-group', false);
if(data) {
state = associations(data, state);
associations(data, state);
}
return state;
}

View File

@ -8,13 +8,7 @@ export const stateSetter = <StateType>(
fn: (state: StateType) => void,
set
): void => {
// fn = (state: StateType) => {
// // TODO this is a stub for the store debugging
// fn(state);
// }
return set(fn);
// TODO we want to use the below, but it makes everything read-only
return set(produce(fn));
set(produce(fn));
};
export const reduceState = <
@ -25,10 +19,10 @@ export const reduceState = <
data: UpdateType,
reducers: ((data: UpdateType, state: StateType) => StateType)[]
): void => {
const oldState = state.getState();
const reducer = compose(reducers.map(reducer => reducer.bind(reducer, data)));
const newState = reducer(oldState);
state.getState().set(state => state = newState);
const reducer = compose(reducers.map(r => sta => r(data, sta)));
state.getState().set(state => {
reducer(state);
});
};
export let stateStorageKeys: string[] = [];

View File

@ -32,7 +32,9 @@ export default class BaseStore<S extends object> {
}
this.reduce(json, this.state);
this.setState(this.state);
if('connection' in json) {
this.setState(this.state);
}
}
reduce(data, state) {

View File

@ -49,6 +49,7 @@ export default class GlobalSubscription extends BaseSubscription<StoreState> {
}
restart() {
this.start();
this.openSubscriptions = {};
super.restart();
}
}

View File

@ -168,6 +168,7 @@ blockquote {
}
.chat .react-codemirror2 {
width: 100%;
height: 100%;
}
.chat .CodeMirror {
@ -186,6 +187,18 @@ blockquote {
font-size: 14px;
}
.chat .CodeMirror-scroll {
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
}
.chat .CodeMirror-sizer {
min-height: 0 !important;
max-height: 100%;
}
.chat.code .react-codemirror2 .CodeMirror * {
font-family: 'Source Code Pro';
}

View File

@ -62,7 +62,7 @@ export function ViewProfile(props: any): ReactElement {
<Col gapY='3' mb='3' mt='6' alignItems='flex-start'>
<Text gray>Pinned Groups</Text>
<Col>
{contact?.groups.sort(lengthOrder).map((g) => (
{contact?.groups.slice().sort(lengthOrder).map((g) => (
<GroupLink
api={api}
resource={g}

View File

@ -120,7 +120,7 @@ const ProfileOverlay = (props: ProfileOverlayProps) => {
borderRadius={2}
/>
) : (
<Box size={60} backgroundColor={color}>
<Box size={60} borderRadius={2} backgroundColor={color}>
<Center height={60}>
<Sigil ship={ship} size={32} color={color} />
</Center>