Update tslint config and update code to conform.

master
Tom Hacohen 6 years ago
parent 3d67ad13b6
commit 9913adc756

@ -52,6 +52,8 @@
"@types/sjcl": "^1.0.28", "@types/sjcl": "^1.0.28",
"@types/urijs": "^1.15.38", "@types/urijs": "^1.15.38",
"@types/uuid": "^3.4.3", "@types/uuid": "^3.4.3",
"tslint": "^5.12.1",
"tslint-react": "^3.6.0",
"typescript": "^3.3.3" "typescript": "^3.3.3"
}, },
"browserslist": [ "browserslist": [

@ -96,7 +96,7 @@ export const routeResolver = new RouteResolver({
const AppBarWitHistory = withRouter( const AppBarWitHistory = withRouter(
class extends React.PureComponent { class extends React.PureComponent {
props: { public props: {
title: string, title: string,
toggleDrawerIcon: any, toggleDrawerIcon: any,
history?: History; history?: History;
@ -110,19 +110,7 @@ const AppBarWitHistory = withRouter(
this.canGoBack = this.canGoBack.bind(this); this.canGoBack = this.canGoBack.bind(this);
} }
canGoBack() { public render() {
return (
(this.props.history!.length > 1) &&
(this.props.history!.location.pathname !== routeResolver.getRoute('pim')) &&
(this.props.history!.location.pathname !== routeResolver.getRoute('home'))
);
}
goBack() {
this.props.history!.goBack();
}
render() {
const { const {
staticContext, staticContext,
toggleDrawerIcon, toggleDrawerIcon,
@ -136,7 +124,7 @@ const AppBarWitHistory = withRouter(
{...props} {...props}
> >
<Toolbar> <Toolbar>
<div style={{ marginLeft: -12, marginRight: 20, }}> <div style={{ marginLeft: -12, marginRight: 20 }}>
{!this.canGoBack() ? {!this.canGoBack() ?
toggleDrawerIcon : toggleDrawerIcon :
<IconButton onClick={this.goBack}><NavigationBack /></IconButton> <IconButton onClick={this.goBack}><NavigationBack /></IconButton>
@ -152,17 +140,29 @@ const AppBarWitHistory = withRouter(
</AppBar> </AppBar>
); );
} }
private canGoBack() {
return (
(this.props.history!.length > 1) &&
(this.props.history!.location.pathname !== routeResolver.getRoute('pim')) &&
(this.props.history!.location.pathname !== routeResolver.getRoute('home'))
);
} }
private goBack() {
this.props.history!.goBack();
}
},
); );
const IconRefreshWithSpin = withSpin(NavigationRefresh); const IconRefreshWithSpin = withSpin(NavigationRefresh);
class App extends React.PureComponent { class App extends React.PureComponent {
state: { public state: {
drawerOpen: boolean, drawerOpen: boolean,
}; };
props: { public props: {
credentials: store.CredentialsType; credentials: store.CredentialsType;
entries: store.EntriesType; entries: store.EntriesType;
fetchCount: number; fetchCount: number;
@ -177,19 +177,7 @@ class App extends React.PureComponent {
this.refresh = this.refresh.bind(this); this.refresh = this.refresh.bind(this);
} }
toggleDrawer() { public render() {
this.setState({drawerOpen: !this.state.drawerOpen});
}
closeDrawer() {
this.setState({drawerOpen: false});
}
refresh() {
store.store.dispatch<any>(actions.fetchAll(this.props.credentials.value!, this.props.entries));
}
render() {
const credentials = (this.props.credentials) ? this.props.credentials.value : null; const credentials = (this.props.credentials) ? this.props.credentials.value : null;
const fetching = this.props.fetchCount > 0; const fetching = this.props.fetchCount > 0;
@ -198,7 +186,7 @@ class App extends React.PureComponent {
main: { main: {
backgroundColor: muiTheme.palette.background.default, backgroundColor: muiTheme.palette.background.default,
color: muiTheme.palette.text.primary, color: muiTheme.palette.text.primary,
flexGrow: 1 flexGrow: 1,
}, },
}; };
@ -229,6 +217,18 @@ class App extends React.PureComponent {
</ThemeProvider> </ThemeProvider>
); );
} }
private toggleDrawer() {
this.setState({drawerOpen: !this.state.drawerOpen});
}
private closeDrawer() {
this.setState({drawerOpen: false});
}
private refresh() {
store.store.dispatch<any>(actions.fetchAll(this.props.credentials.value!, this.props.entries));
}
} }
const credentialsSelector = createSelector( const credentialsSelector = createSelector(
@ -242,14 +242,14 @@ const credentialsSelector = createSelector(
} }
return { return {
error: error, error,
fetching: fetching, fetching,
value: { value: {
...value, ...value,
encryptionKey: encryptionKey, encryptionKey,
} },
}; };
} },
); );
const mapStateToProps = (state: store.StoreState) => { const mapStateToProps = (state: store.StoreState) => {
@ -261,5 +261,5 @@ const mapStateToProps = (state: store.StoreState) => {
}; };
export default connect( export default connect(
mapStateToProps mapStateToProps,
)(App); )(App);

@ -59,7 +59,7 @@ const AddressBookItem = pure((_props: any) => {
}); });
const sortSelector = createSelector( const sortSelector = createSelector(
(entries: Array<ContactType>) => entries, (entries: ContactType[]) => entries,
(entries) => { (entries) => {
return entries.sort((_a, _b) => { return entries.sort((_a, _b) => {
const a = _a.fn; const a = _a.fn;
@ -73,24 +73,24 @@ const sortSelector = createSelector(
return 0; return 0;
} }
}); });
}, }
); );
class AddressBook extends React.PureComponent { interface PropsType {
props: { entries: ContactType[];
entries: Array<ContactType>, onItemClick: (contact: ContactType) => void;
onItemClick: (contact: ContactType) => void, filter?: (a: ContactType) => boolean;
filter?: (a: ContactType) => boolean, }
};
render() { class AddressBook extends React.PureComponent<PropsType> {
public render() {
const sortedEntries = sortSelector(this.props.entries); const sortedEntries = sortSelector(this.props.entries);
const entries = (this.props.filter) ? const entries = (this.props.filter) ?
sortedEntries.filter(this.props.filter) sortedEntries.filter(this.props.filter)
: sortedEntries; : sortedEntries;
let itemList = entries.map((entry, idx, array) => { const itemList = entries.map((entry, idx, array) => {
const uid = entry.uid; const uid = entry.uid;
return ( return (

@ -17,7 +17,7 @@ function eventPropGetter(event: EventType) {
return { return {
style: { style: {
backgroundColor: event.color, backgroundColor: event.color,
} },
}; };
} }
@ -26,18 +26,18 @@ function agendaHeaderFormat(date: {start: Date, end: Date}, culture: string, loc
return localizer.format(date.start, format) + ' - ' + localizer.format(date.end, format); return localizer.format(date.start, format) + ' - ' + localizer.format(date.end, format);
} }
class Calendar extends React.PureComponent { interface PropsType {
state: { entries: EventType[];
onItemClick: (contact: EventType) => void;
onSlotClick?: (start: Date, end: Date) => void;
}
class Calendar extends React.PureComponent<PropsType> {
public state: {
currentDate?: Date; currentDate?: Date;
view?: View; view?: View;
}; };
props: {
entries: Array<EventType>,
onItemClick: (contact: EventType) => void,
onSlotClick?: (start: Date, end: Date) => void,
};
constructor(props: any) { constructor(props: any) {
super(props); super(props);
this.state = {}; this.state = {};
@ -47,22 +47,8 @@ class Calendar extends React.PureComponent {
this.slotClicked = this.slotClicked.bind(this); this.slotClicked = this.slotClicked.bind(this);
} }
onNavigate(currentDate: Date) { public render() {
this.setState({currentDate}); const entries = [] as EventType[];
}
onView(view: string) {
this.setState({view});
}
slotClicked(slotInfo: {start: Date, end: Date}) {
if (this.props.onSlotClick) {
this.props.onSlotClick(slotInfo.start, slotInfo.end);
}
}
render() {
const entries = [] as Array<EventType>;
this.props.entries.forEach((event) => { this.props.entries.forEach((event) => {
entries.push(event); entries.push(event);
@ -103,6 +89,20 @@ class Calendar extends React.PureComponent {
</div> </div>
); );
} }
private onNavigate(currentDate: Date) {
this.setState({currentDate});
}
private onView(view: string) {
this.setState({view});
}
private slotClicked(slotInfo: {start: Date, end: Date}) {
if (this.props.onSlotClick) {
this.props.onSlotClick(slotInfo.start, slotInfo.end);
}
}
} }
export default Calendar; export default Calendar;

@ -11,7 +11,7 @@ export function createJournalEntry(
action: EteSync.SyncEntryAction, action: EteSync.SyncEntryAction,
content: string) { content: string) {
let syncEntry = new EteSync.SyncEntry(); const syncEntry = new EteSync.SyncEntry();
syncEntry.action = action; syncEntry.action = action;
syncEntry.content = content; syncEntry.content = content;
@ -27,7 +27,7 @@ export function createJournalEntry(
} else { } else {
cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version); cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version);
} }
let entry = new EteSync.Entry(); const entry = new EteSync.Entry();
entry.setSyncEntry(cryptoManager, syncEntry, prevUid); entry.setSyncEntry(cryptoManager, syncEntry, prevUid);
return createEntries(etesync, journal.uid, [entry], prevUid); return createEntries(etesync, journal.uid, [entry], prevUid);

@ -8,10 +8,10 @@ import * as EteSync from './api/EteSync';
export function syncEntriesToItemMap( export function syncEntriesToItemMap(
collection: EteSync.CollectionInfo, entries: List<EteSync.SyncEntry>, base: {[key: string]: ContactType} = {}) { collection: EteSync.CollectionInfo, entries: List<EteSync.SyncEntry>, base: {[key: string]: ContactType} = {}) {
let items = base; const items = base;
entries.forEach((syncEntry) => { entries.forEach((syncEntry) => {
let comp = new ContactType(new ICAL.Component(ICAL.parse(syncEntry.content))); const comp = new ContactType(new ICAL.Component(ICAL.parse(syncEntry.content)));
const uid = comp.uid; const uid = comp.uid;
@ -42,7 +42,7 @@ function colorIntToHtml(color: number) {
// tslint:enable // tslint:enable
function toHex(num: number) { function toHex(num: number) {
let ret = num.toString(16); const ret = num.toString(16);
return (ret.length === 1) ? '0' + ret : ret; return (ret.length === 1) ? '0' + ret : ret;
} }
@ -53,12 +53,12 @@ function colorIntToHtml(color: number) {
function syncEntriesToCalendarItemMap<T extends EventType>( function syncEntriesToCalendarItemMap<T extends EventType>(
ItemType: any, ItemType: any,
collection: EteSync.CollectionInfo, entries: List<EteSync.SyncEntry>, base: {[key: string]: T} = {}) { collection: EteSync.CollectionInfo, entries: List<EteSync.SyncEntry>, base: {[key: string]: T} = {}) {
let items = base; const items = base;
const color = colorIntToHtml(collection.color); const color = colorIntToHtml(collection.color);
entries.forEach((syncEntry) => { entries.forEach((syncEntry) => {
let comp = ItemType.fromVCalendar(new ICAL.Component(ICAL.parse(syncEntry.content))); const comp = ItemType.fromVCalendar(new ICAL.Component(ICAL.parse(syncEntry.content)));
if (comp === null) { if (comp === null) {
return; return;

@ -7,16 +7,16 @@ export interface PimType {
} }
export class EventType extends ICAL.Event implements PimType { export class EventType extends ICAL.Event implements PimType {
color: string; public static isEvent(comp: ICAL.Component) {
static isEvent(comp: ICAL.Component) {
return !!comp.getFirstSubcomponent('vevent'); return !!comp.getFirstSubcomponent('vevent');
} }
static fromVCalendar(comp: ICAL.Component) { public static fromVCalendar(comp: ICAL.Component) {
return new EventType(comp.getFirstSubcomponent('vevent')); return new EventType(comp.getFirstSubcomponent('vevent'));
} }
public color: string;
get timezone() { get timezone() {
if (this.startDate) { if (this.startDate) {
return this.startDate.timezone; return this.startDate.timezone;
@ -47,8 +47,8 @@ export class EventType extends ICAL.Event implements PimType {
return this.description; return this.description;
} }
toIcal() { public toIcal() {
let comp = new ICAL.Component(['vcalendar', [], []]); const comp = new ICAL.Component(['vcalendar', [], []]);
comp.updatePropertyWithValue('prodid', '-//iCal.js EteSync Web'); comp.updatePropertyWithValue('prodid', '-//iCal.js EteSync Web');
comp.updatePropertyWithValue('version', '4.0'); comp.updatePropertyWithValue('version', '4.0');
@ -56,7 +56,7 @@ export class EventType extends ICAL.Event implements PimType {
return comp.toString(); return comp.toString();
} }
clone() { public clone() {
const ret = new EventType(new ICAL.Component(this.component.toJSON())); const ret = new EventType(new ICAL.Component(this.component.toJSON()));
ret.color = this.color; ret.color = this.color;
return ret; return ret;
@ -71,12 +71,12 @@ export enum TaskStatusType {
} }
export class TaskType extends EventType { export class TaskType extends EventType {
color: string; public static fromVCalendar(comp: ICAL.Component) {
static fromVCalendar(comp: ICAL.Component) {
return new TaskType(comp.getFirstSubcomponent('vtodo')); return new TaskType(comp.getFirstSubcomponent('vtodo'));
} }
public color: string;
constructor(comp: ICAL.Component | null) { constructor(comp: ICAL.Component | null) {
super(comp ? comp : new ICAL.Component('vtodo')); super(comp ? comp : new ICAL.Component('vtodo'));
} }
@ -106,7 +106,7 @@ export class TaskType extends EventType {
return this.component.getFirstPropertyValue('due'); return this.component.getFirstPropertyValue('due');
} }
clone() { public clone() {
const ret = new TaskType(new ICAL.Component(this.component.toJSON())); const ret = new TaskType(new ICAL.Component(this.component.toJSON()));
ret.color = this.color; ret.color = this.color;
return ret; return ret;
@ -114,17 +114,17 @@ export class TaskType extends EventType {
} }
export class ContactType implements PimType { export class ContactType implements PimType {
comp: ICAL.Component; public comp: ICAL.Component;
constructor(comp: ICAL.Component) { constructor(comp: ICAL.Component) {
this.comp = comp; this.comp = comp;
} }
toIcal() { public toIcal() {
return this.comp.toString(); return this.comp.toString();
} }
clone() { public clone() {
return new ContactType(new ICAL.Component(this.comp.toJSON())); return new ContactType(new ICAL.Component(this.comp.toJSON()));
} }

@ -1,13 +1,15 @@
export type RouteKeysType = { [Identifier: string]: any }; export interface RouteKeysType {
[Identifier: string]: any;
}
export class RouteResolver { export class RouteResolver {
routes: {}; public routes: {};
constructor(routes: {}) { constructor(routes: {}) {
this.routes = routes; this.routes = routes;
} }
getRoute(name: string, _keys?: RouteKeysType): string { public getRoute(name: string, _keys?: RouteKeysType): string {
let dict = this.routes; let dict = this.routes;
let path: string[] = []; let path: string[] = [];
@ -19,7 +21,7 @@ export class RouteResolver {
}); });
if (_keys) { if (_keys) {
let keys = Object.assign({}, _keys); const keys = Object.assign({}, _keys);
path = path.map((pathComponent) => { path = path.map((pathComponent) => {
return pathComponent.split('/').map((val) => { return pathComponent.split('/').map((val) => {

@ -48,7 +48,7 @@ export const { fetchListJournal } = createActions({
FETCH_LIST_JOURNAL: (etesync: CredentialsData) => { FETCH_LIST_JOURNAL: (etesync: CredentialsData) => {
const creds = etesync.credentials; const creds = etesync.credentials;
const apiBase = etesync.serviceApiUrl; const apiBase = etesync.serviceApiUrl;
let journalManager = new EteSync.JournalManager(creds, apiBase); const journalManager = new EteSync.JournalManager(creds, apiBase);
return journalManager.list(); return journalManager.list();
}, },
@ -59,13 +59,13 @@ export const addJournal = createAction(
(etesync: CredentialsData, journal: EteSync.Journal) => { (etesync: CredentialsData, journal: EteSync.Journal) => {
const creds = etesync.credentials; const creds = etesync.credentials;
const apiBase = etesync.serviceApiUrl; const apiBase = etesync.serviceApiUrl;
let journalManager = new EteSync.JournalManager(creds, apiBase); const journalManager = new EteSync.JournalManager(creds, apiBase);
return journalManager.create(journal); return journalManager.create(journal);
}, },
(etesync: CredentialsData, journal: EteSync.Journal) => { (etesync: CredentialsData, journal: EteSync.Journal) => {
return { item: journal }; return { item: journal };
}, }
); );
export const updateJournal = createAction( export const updateJournal = createAction(
@ -73,13 +73,13 @@ export const updateJournal = createAction(
(etesync: CredentialsData, journal: EteSync.Journal) => { (etesync: CredentialsData, journal: EteSync.Journal) => {
const creds = etesync.credentials; const creds = etesync.credentials;
const apiBase = etesync.serviceApiUrl; const apiBase = etesync.serviceApiUrl;
let journalManager = new EteSync.JournalManager(creds, apiBase); const journalManager = new EteSync.JournalManager(creds, apiBase);
return journalManager.update(journal); return journalManager.update(journal);
}, },
(etesync: CredentialsData, journal: EteSync.Journal) => { (etesync: CredentialsData, journal: EteSync.Journal) => {
return { item: journal }; return { item: journal };
}, }
); );
export const deleteJournal = createAction( export const deleteJournal = createAction(
@ -87,13 +87,13 @@ export const deleteJournal = createAction(
(etesync: CredentialsData, journal: EteSync.Journal) => { (etesync: CredentialsData, journal: EteSync.Journal) => {
const creds = etesync.credentials; const creds = etesync.credentials;
const apiBase = etesync.serviceApiUrl; const apiBase = etesync.serviceApiUrl;
let journalManager = new EteSync.JournalManager(creds, apiBase); const journalManager = new EteSync.JournalManager(creds, apiBase);
return journalManager.delete(journal); return journalManager.delete(journal);
}, },
(etesync: CredentialsData, journal: EteSync.Journal) => { (etesync: CredentialsData, journal: EteSync.Journal) => {
return { item: journal }; return { item: journal };
}, }
); );
export const { fetchEntries, createEntries } = createActions({ export const { fetchEntries, createEntries } = createActions({
@ -101,33 +101,33 @@ export const { fetchEntries, createEntries } = createActions({
(etesync: CredentialsData, journalUid: string, prevUid: string | null) => { (etesync: CredentialsData, journalUid: string, prevUid: string | null) => {
const creds = etesync.credentials; const creds = etesync.credentials;
const apiBase = etesync.serviceApiUrl; const apiBase = etesync.serviceApiUrl;
let entryManager = new EteSync.EntryManager(creds, apiBase, journalUid); const entryManager = new EteSync.EntryManager(creds, apiBase, journalUid);
return entryManager.list(prevUid); return entryManager.list(prevUid);
}, },
(etesync: CredentialsData, journalUid: string, prevUid: string | null) => { (etesync: CredentialsData, journalUid: string, prevUid: string | null) => {
return { journal: journalUid, prevUid }; return { journal: journalUid, prevUid };
} },
], ],
CREATE_ENTRIES: [ CREATE_ENTRIES: [
(etesync: CredentialsData, journalUid: string, newEntries: Array<EteSync.Entry>, prevUid: string | null) => { (etesync: CredentialsData, journalUid: string, newEntries: EteSync.Entry[], prevUid: string | null) => {
const creds = etesync.credentials; const creds = etesync.credentials;
const apiBase = etesync.serviceApiUrl; const apiBase = etesync.serviceApiUrl;
let entryManager = new EteSync.EntryManager(creds, apiBase, journalUid); const entryManager = new EteSync.EntryManager(creds, apiBase, journalUid);
return entryManager.create(newEntries, prevUid).then(response => newEntries); return entryManager.create(newEntries, prevUid).then((response) => newEntries);
}, },
(etesync: CredentialsData, journalUid: string, newEntries: Array<EteSync.Entry>, prevUid: string | null) => { (etesync: CredentialsData, journalUid: string, newEntries: EteSync.Entry[], prevUid: string | null) => {
return { journal: journalUid, entries: newEntries, prevUid }; return { journal: journalUid, entries: newEntries, prevUid };
} },
] ],
}); });
export const { fetchUserInfo } = createActions({ export const { fetchUserInfo } = createActions({
FETCH_USER_INFO: (etesync: CredentialsData, owner: string) => { FETCH_USER_INFO: (etesync: CredentialsData, owner: string) => {
const creds = etesync.credentials; const creds = etesync.credentials;
const apiBase = etesync.serviceApiUrl; const apiBase = etesync.serviceApiUrl;
let userInfoManager = new EteSync.UserInfoManager(creds, apiBase); const userInfoManager = new EteSync.UserInfoManager(creds, apiBase);
return userInfoManager.fetch(owner); return userInfoManager.fetch(owner);
}, },
@ -138,13 +138,13 @@ export const createUserInfo = createAction(
(etesync: CredentialsData, userInfo: UserInfo) => { (etesync: CredentialsData, userInfo: UserInfo) => {
const creds = etesync.credentials; const creds = etesync.credentials;
const apiBase = etesync.serviceApiUrl; const apiBase = etesync.serviceApiUrl;
let userInfoManager = new EteSync.UserInfoManager(creds, apiBase); const userInfoManager = new EteSync.UserInfoManager(creds, apiBase);
return userInfoManager.create(userInfo); return userInfoManager.create(userInfo);
}, },
(etesync: CredentialsData, userInfo: UserInfo) => { (etesync: CredentialsData, userInfo: UserInfo) => {
return { userInfo }; return { userInfo };
}, }
); );
export function fetchAll(etesync: CredentialsData, currentEntries: EntriesType) { export function fetchAll(etesync: CredentialsData, currentEntries: EntriesType) {
@ -176,5 +176,5 @@ export const setSettings = createAction(
'SET_SETTINGS', 'SET_SETTINGS',
(settings: SettingsType) => { (settings: SettingsType) => {
return {...settings}; return {...settings};
}, }
); );

@ -77,7 +77,7 @@ const entriesDeserialize = (state: EteSync.EntryJson[]): FetchType<EntriesData>
} }
return new EntriesFetchRecord({value: List(state.map((x: any) => { return new EntriesFetchRecord({value: List(state.map((x: any) => {
let ret = new EteSync.Entry(); const ret = new EteSync.Entry();
ret.deserialize(x); ret.deserialize(x);
return ret; return ret;
}))}); }))});
@ -96,14 +96,14 @@ const userInfoDeserialize = (state: EteSync.UserInfoJson) => {
return null; return null;
} }
let ret = new EteSync.UserInfo(state.owner!, state.version); const ret = new EteSync.UserInfo(state.owner!, state.version);
ret.deserialize(state); ret.deserialize(state);
return ret; return ret;
}; };
const cacheSerialize = (state: any, key: string) => { const cacheSerialize = (state: any, key: string) => {
if (key === 'entries') { if (key === 'entries') {
let ret = {}; const ret = {};
state.forEach((value: FetchType<EntriesData>, mapKey: string) => { state.forEach((value: FetchType<EntriesData>, mapKey: string) => {
ret[mapKey] = entriesSerialize(value); ret[mapKey] = entriesSerialize(value);
}); });
@ -119,7 +119,7 @@ const cacheSerialize = (state: any, key: string) => {
const cacheDeserialize = (state: any, key: string) => { const cacheDeserialize = (state: any, key: string) => {
if (key === 'entries') { if (key === 'entries') {
let ret = {}; const ret = {};
Object.keys(state).forEach((mapKey) => { Object.keys(state).forEach((mapKey) => {
ret[mapKey] = entriesDeserialize(state[mapKey]); ret[mapKey] = entriesDeserialize(state[mapKey]);
}); });
@ -137,7 +137,7 @@ const cacheMigrations = {
0: (state: any) => { 0: (state: any) => {
return { return {
...state, ...state,
journals: undefined journals: undefined,
}; };
}, },
}; };

@ -9,13 +9,13 @@ it('Entries reducer', () => {
const jId = '24324324324'; const jId = '24324324324';
let state = Map({}) as EntriesTypeImmutable; let state = Map({}) as EntriesTypeImmutable;
let entry = new EteSync.Entry(); const entry = new EteSync.Entry();
entry.deserialize({ entry.deserialize({
content: 'someContent', content: 'someContent',
uid: '6355209e2a2c26a6c1e6e967c2032737d538f602cf912474da83a2902f8a0a83' uid: '6355209e2a2c26a6c1e6e967c2032737d538f602cf912474da83a2902f8a0a83',
}); });
let action = { const action = {
type: fetchEntries.toString(), type: fetchEntries.toString(),
meta: {journal: jId, prevUid: null as string | null}, meta: {journal: jId, prevUid: null as string | null},
payload: [entry], payload: [entry],

@ -11,7 +11,7 @@ import reducers from './construct';
export * from './reducers'; export * from './reducers';
export * from './construct'; export * from './construct';
let middleware = [ const middleware = [
thunkMiddleware, thunkMiddleware,
promiseMiddleware, promiseMiddleware,
]; ];

@ -208,7 +208,7 @@ export const journals = handleActions(
{ {
...mapReducerActionsMapCreator<JournalsTypeImmutable, EteSync.Journal>('Journal'), ...mapReducerActionsMapCreator<JournalsTypeImmutable, EteSync.Journal>('Journal'),
}, },
new JournalsFetchRecord(), new JournalsFetchRecord()
); );
export const userInfo = handleAction( export const userInfo = handleAction(
@ -233,7 +233,7 @@ export const userInfo = handleAction(
return state.set('value', payload); return state.set('value', payload);
} }
}, },
new UserInfoFetchRecord(), new UserInfoFetchRecord()
); );
const fetchActions = [ const fetchActions = [
@ -252,7 +252,7 @@ for (const func in actions) {
// Indicates network activity, not just fetch // Indicates network activity, not just fetch
export const fetchCount = handleAction( export const fetchCount = handleAction(
combineActions( combineActions(
...fetchActions, ...fetchActions
), ),
(state: number, action: any) => { (state: number, action: any) => {
if (action.payload === undefined) { if (action.payload === undefined) {
@ -261,13 +261,13 @@ export const fetchCount = handleAction(
return state - 1; return state - 1;
} }
}, },
0, 0
); );
// FIXME Move all the below (potentially the fetchCount ones too) to their own file // FIXME Move all the below (potentially the fetchCount ones too) to their own file
export interface SettingsType { export interface SettingsType {
locale: string; locale: string;
}; }
export const settingsReducer = handleActions( export const settingsReducer = handleActions(
{ {

@ -1,114 +1,112 @@
declare module 'ical.js' { declare module 'ical.js' {
function parse(input: string): Array<any>; function parse(input: string): any[];
class Component { class Component {
name: string; static public fromString(str: string): Component;
static fromString(str: string): Component; public name: string;
constructor(jCal: Array<any> | string, parent?: Component); constructor(jCal: any[] | string, parent?: Component);
toJSON(): Array<any>; public toJSON(): any[];
getFirstSubcomponent(name?: string): Component | null; public getFirstSubcomponent(name?: string): Component | null;
getFirstPropertyValue(name?: string): any; public getFirstPropertyValue(name?: string): any;
getFirstProperty(name?: string): Property; public getFirstProperty(name?: string): Property;
getAllProperties(name?: string): Array<Property>; public getAllProperties(name?: string): Property[];
addProperty(property: Property): Property; public addProperty(property: Property): Property;
addPropertyWithValue(name: string, value: string | number | object): Property; public addPropertyWithValue(name: string, value: string | number | object): Property;
updatePropertyWithValue(name: string, value: string | number | object): Property; public updatePropertyWithValue(name: string, value: string | number | object): Property;
removeAllProperties(name?: string): boolean; public removeAllProperties(name?: string): boolean;
addSubcomponent(component: Component): Component; public addSubcomponent(component: Component): Component;
} }
class Event { class Event {
uid: string; public uid: string;
summary: string; public summary: string;
startDate: Time; public startDate: Time;
endDate: Time; public endDate: Time;
description: string; public description: string;
location: string; public location: string;
attendees: Array<Property>; public attendees: Property[];
component: Component; public component: Component;
isRecurring(): boolean; public constructor(component?: Component | null, options?: {strictExceptions: boolean, exepctions: Array<Component | Event>});
iterator(startTime?: Time): RecurExpansion;
constructor(component?: Component | null, public isRecurring(): boolean;
options?: {strictExceptions: boolean, exepctions: Array<Component|Event>}); public iterator(startTime?: Time): RecurExpansion;
} }
class Property { class Property {
name: string; public name: string;
type: string; public type: string;
constructor(jCal: Array<any> | string, parent?: Component); constructor(jCal: any[] | string, parent?: Component);
getFirstValue(): any; public getFirstValue(): any;
getValues(): Array<any>; public getValues(): any[];
setParameter(name: string, value: string | Array<string>): void; public setParameter(name: string, value: string | string[]): void;
setValue(value: string | object): void; public setValue(value: string | object): void;
toJSON(): any; public toJSON(): any;
} }
type TimeJsonData = { interface TimeJsonData {
year?: number, year?: number;
month?: number, month?: number;
day?: number, day?: number;
hour?: number, hour?: number;
minute?: number, minute?: number;
second?: number, second?: number;
isDate?: boolean isDate?: boolean;
}; }
class Time { class Time {
isDate: boolean; static public fromString(str: string): Time;
timezone: string; static public fromJSDate(aDate: Date | null, useUTC: boolean): Time;
zone: Timezone; static public fromData(aData: TimeJsonData): Time;
static fromString(str: string): Time; static public now(): Time;
static fromJSDate(aDate: Date | null, useUTC: boolean): Time;
static fromData(aData: TimeJsonData): Time;
static now(): Time; public isDate: boolean;
public timezone: string;
public zone: Timezone;
constructor(data?: TimeJsonData); constructor(data?: TimeJsonData);
public compare(aOther: Time): number;
compare(aOther: Time): number; public clone(): Time;
clone(): Time;
adjust( public adjust(
aExtraDays: number, aExtraHours: number, aExtraMinutes: number, aExtraSeconds: number, aTimeopt?: Time): void; aExtraDays: number, aExtraHours: number, aExtraMinutes: number, aExtraSeconds: number, aTimeopt?: Time): void;
addDuration(aDuration: Duration): void; public addDuration(aDuration: Duration): void;
subtractDateTz(aDate: Time): Duration; public subtractDateTz(aDate: Time): Duration;
toJSDate(): Date; public toJSDate(): Date;
toJSON(): TimeJsonData; public toJSON(): TimeJsonData;
} }
class Duration { class Duration {
days: number; public days: number;
} }
class RecurExpansion { class RecurExpansion {
complete: boolean; public complete: boolean;
next(): Time; public next(): Time;
} }
class Timezone { class Timezone {
static localTimezone: Timezone; static public localTimezone: Timezone;
static convert_time(tt: Time, from_zone: Timezone, to_zone: Timezone): Time; static public convert_time(tt: Time, fromZone: Timezone, toZone: Timezone): Time;
tzid: string; public tzid: string;
} }
} }

@ -5,28 +5,20 @@ import Datetime from 'react-datetime';
import 'react-datetime/css/react-datetime.css'; import 'react-datetime/css/react-datetime.css';
class DateTimePicker extends React.PureComponent { interface PropsType {
props: { placeholder: string;
placeholder: string, value?: Date;
value?: Date, dateOnly?: boolean;
dateOnly?: boolean,
onChange: (date?: Date) => void; onChange: (date?: Date) => void;
}; }
class DateTimePicker extends React.PureComponent<PropsType> {
constructor(props: any) { constructor(props: any) {
super(props); super(props);
this.handleInputChange = this.handleInputChange.bind(this); this.handleInputChange = this.handleInputChange.bind(this);
} }
handleInputChange(newDate: string | moment.Moment) { public render() {
if (moment.isMoment(newDate)) {
this.props.onChange(newDate.toDate());
} else {
this.props.onChange(undefined);
}
}
render() {
const inputProps = { const inputProps = {
placeholder: this.props.placeholder, placeholder: this.props.placeholder,
readOnly: true, readOnly: true,
@ -40,6 +32,14 @@ class DateTimePicker extends React.PureComponent {
/> />
); );
} }
private handleInputChange(newDate: string | moment.Moment) {
if (moment.isMoment(newDate)) {
this.props.onChange(newDate.toDate());
} else {
this.props.onChange(undefined);
}
}
} }
export default DateTimePicker; export default DateTimePicker;

@ -1,99 +1,38 @@
{ {
"extends": ["tslint-react"], "extends": ["tslint:recommended", "tslint-react"],
"rules": { "rules": {
"align": [
true,
"parameters",
"arguments",
"statements"
],
"ban": false,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": false,
"forin": true,
"indent": [ true, "spaces" ],
"interface-name": [true, "never-prefix"], "interface-name": [true, "never-prefix"],
"jsdoc-format": true, "ordered-imports": false,
"jsx-no-lambda": false, "jsx-curly-spacing": [true, "never"],
"jsx-no-bind": [true, "allowArrowFunctions"],
"jsx-no-lambda": [false],
"jsx-no-multiline-js": false, "jsx-no-multiline-js": false,
"label-position": true, "max-classes-per-file": [false, 0],
"max-line-length": [ true, 120 ], "max-line-length": false,
"member-ordering": [ "no-consecutive-blank-lines": false,
true, "no-conditional-assignment": false,
"public-before-private", "object-literal-sort-keys": false,
"static-before-instance", "quotemark": [true, "single", "jsx-double", "avoid-escape", "avoid-template"],
"variables-before-functions" "semicolon": [true, "always", "ignore-bound-class-methods"],
], "variable-name": [true, "ban-keywords", "check-format", "allow-pascal-case", "allow-leading-underscore"],
"no-any": false, "trailing-comma": [
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"log",
"error",
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-consecutive-blank-lines": true,
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-eval": true,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": false,
"no-unused-expression": true,
"no-use-before-declare": true,
"one-line": [
true,
"check-catch",
"check-else",
"check-open-brace",
"check-whitespace"
],
"quotemark": [true, "single", "jsx-double"],
"radix": true,
"semicolon": [true, "always"],
"switch-default": true,
"trailing-comma": false,
"triple-equals": [ true, "allow-null-check" ],
"typedef": [
true,
"parameter",
"property-declaration"
],
"typedef-whitespace": [
true, true,
{ {
"call-signature": "nospace", "multiline": {
"index-signature": "nospace", "objects": "always",
"parameter": "nospace", "arrays": "always",
"property-declaration": "nospace", "functions": "never",
"variable-declaration": "nospace" "typeLiterals": "ignore"
},
"esSpecCompliant": true
} }
], ],
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"], "whitespace": [true,"check-branch", "check-decl", "check-operator", "check-module", "check-separator", "check-rest-spread", "check-type", "check-typecast", "check-type-operator", "check-preblock"]
"whitespace": [ },
true, "linterOptions": {
"check-branch", "exclude": [
"check-decl", "config/**/*.js",
"check-module", "node_modules/**/*.ts"
"check-operator",
"check-separator",
"check-type",
"check-typecast"
] ]
} }
} }

@ -2151,6 +2151,11 @@ buffer@^4.3.0:
ieee754 "^1.1.4" ieee754 "^1.1.4"
isarray "^1.0.0" isarray "^1.0.0"
builtin-modules@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=
builtin-status-codes@^3.0.0: builtin-status-codes@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
@ -2280,7 +2285,7 @@ ccount@^1.0.3:
resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.0.3.tgz#f1cec43f332e2ea5a569fd46f9f5bde4e6102aff" resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.0.3.tgz#f1cec43f332e2ea5a569fd46f9f5bde4e6102aff"
integrity sha512-Jt9tIBkRc9POUof7QA/VwWd+58fKkEEfI+/t1/eOlxKM7ZhrczNzMFefge7Ai+39y1pR/pP6cI19guHy3FSLmw== integrity sha512-Jt9tIBkRc9POUof7QA/VwWd+58fKkEEfI+/t1/eOlxKM7ZhrczNzMFefge7Ai+39y1pR/pP6cI19guHy3FSLmw==
chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2: chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2:
version "2.4.2" version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
@ -2527,7 +2532,7 @@ commander@2.17.x, commander@~2.17.1:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg== integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==
commander@^2.11.0: commander@^2.11.0, commander@^2.12.1:
version "2.19.0" version "2.19.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg== integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==
@ -9936,11 +9941,43 @@ ts-pnp@^1.0.0:
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.0.0.tgz#44a3a9e8c13fcb711bcda75d7b576c21af120c9d" resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.0.0.tgz#44a3a9e8c13fcb711bcda75d7b576c21af120c9d"
integrity sha512-qgwM7eBrxFvZSXLtSvjf3c2mXwJOOGD49VlE+KocUGX95DuMdLc/psZHBnPpZL5b2NU7VtQGHRCWF3cNfe5kxQ== integrity sha512-qgwM7eBrxFvZSXLtSvjf3c2mXwJOOGD49VlE+KocUGX95DuMdLc/psZHBnPpZL5b2NU7VtQGHRCWF3cNfe5kxQ==
tslib@^1.9.0: tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
version "1.9.3" version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
tslint-react@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/tslint-react/-/tslint-react-3.6.0.tgz#7f462c95c4a0afaae82507f06517ff02942196a1"
integrity sha512-AIv1QcsSnj7e9pFir6cJ6vIncTqxfqeFF3Lzh8SuuBljueYzEAtByuB6zMaD27BL0xhMEqsZ9s5eHuCONydjBw==
dependencies:
tsutils "^2.13.1"
tslint@^5.12.1:
version "5.12.1"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.12.1.tgz#8cec9d454cf8a1de9b0a26d7bdbad6de362e52c1"
integrity sha512-sfodBHOucFg6egff8d1BvuofoOQ/nOeYNfbp7LDlKBcLNrL3lmS5zoiDGyOMdT7YsEXAwWpTdAHwOGOc8eRZAw==
dependencies:
babel-code-frame "^6.22.0"
builtin-modules "^1.1.1"
chalk "^2.3.0"
commander "^2.12.1"
diff "^3.2.0"
glob "^7.1.1"
js-yaml "^3.7.0"
minimatch "^3.0.4"
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.8.0"
tsutils "^2.27.2"
tsutils@^2.13.1, tsutils@^2.27.2:
version "2.29.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99"
integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==
dependencies:
tslib "^1.8.1"
tty-browserify@0.0.0: tty-browserify@0.0.0:
version "0.0.0" version "0.0.0"
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"

Loading…
Cancel
Save