Upgrade prettier

This commit is contained in:
Tom Moor
2017-11-10 14:14:30 -08:00
parent c737b613e4
commit ab13f51d5d
79 changed files with 780 additions and 533 deletions

View File

@@ -16,11 +16,13 @@ class AuthStore {
/* Computed */
@computed get authenticated(): boolean {
@computed
get authenticated(): boolean {
return !!this.token;
}
@computed get asJson(): string {
@computed
get asJson(): string {
return JSON.stringify({
user: this.user,
team: this.team,
@@ -31,19 +33,24 @@ class AuthStore {
/* Actions */
@action logout = () => {
@action
logout = () => {
this.user = null;
this.token = null;
Cookie.remove('loggedIn', { path: '/' });
};
@action getOauthState = () => {
const state = Math.random().toString(36).substring(7);
@action
getOauthState = () => {
const state = Math.random()
.toString(36)
.substring(7);
this.oauthState = state;
return this.oauthState;
};
@action authWithSlack = async (code: string, state: string) => {
@action
authWithSlack = async (code: string, state: string) => {
if (state !== this.oauthState) {
return {
success: false,

View File

@@ -43,20 +43,23 @@ class CollectionsStore {
cache: CacheStore;
ui: UiStore;
@computed get active(): ?Collection {
@computed
get active(): ?Collection {
return this.ui.activeCollectionId
? this.getById(this.ui.activeCollectionId)
: undefined;
}
@computed get orderedData(): Collection[] {
@computed
get orderedData(): Collection[] {
return _.sortBy(this.data, 'name');
}
/**
* List of paths to each of the documents, where paths are composed of id and title/name pairs
*/
@computed get pathsToDocuments(): Array<DocumentPath> {
@computed
get pathsToDocuments(): Array<DocumentPath> {
let results = [];
const travelDocuments = (documentList, path) =>
documentList.forEach(document => {
@@ -95,7 +98,8 @@ class CollectionsStore {
/* Actions */
@action fetchAll = async (): Promise<*> => {
@action
fetchAll = async (): Promise<*> => {
try {
const res = await this.client.post('/collections.list', {
id: this.teamId,
@@ -111,7 +115,8 @@ class CollectionsStore {
}
};
@action fetchById = async (id: string): Promise<?Collection> => {
@action
fetchById = async (id: string): Promise<?Collection> => {
let collection = this.getById(id);
if (!collection) {
try {
@@ -133,11 +138,13 @@ class CollectionsStore {
return collection;
};
@action add = (collection: Collection): void => {
@action
add = (collection: Collection): void => {
this.data.push(collection);
};
@action remove = (id: string): void => {
@action
remove = (id: string): void => {
this.data.splice(this.data.indexOf(id), 1);
};

View File

@@ -37,7 +37,8 @@ class DocumentsStore extends BaseStore {
/* Computed */
@computed get recentlyViewed(): Array<Document> {
@computed
get recentlyViewed(): Array<Document> {
return _.take(
_.filter(this.data.values(), ({ id }) =>
this.recentlyViewedIds.includes(id)
@@ -46,15 +47,18 @@ class DocumentsStore extends BaseStore {
);
}
@computed get recentlyEdited(): Array<Document> {
@computed
get recentlyEdited(): Array<Document> {
return _.take(_.orderBy(this.data.values(), 'updatedAt', 'desc'), 5);
}
@computed get starred(): Array<Document> {
@computed
get starred(): Array<Document> {
return _.filter(this.data.values(), 'starred');
}
@computed get active(): ?Document {
@computed
get active(): ?Document {
return this.ui.activeDocumentId
? this.getById(this.ui.activeDocumentId)
: undefined;
@@ -62,10 +66,8 @@ class DocumentsStore extends BaseStore {
/* Actions */
@action fetchAll = async (
request: string = 'list',
options: ?Object
): Promise<*> => {
@action
fetchAll = async (request: string = 'list', options: ?Object): Promise<*> => {
this.isFetching = true;
try {
@@ -86,11 +88,13 @@ class DocumentsStore extends BaseStore {
}
};
@action fetchRecentlyModified = async (options: ?Object): Promise<*> => {
@action
fetchRecentlyModified = async (options: ?Object): Promise<*> => {
return await this.fetchAll('list', options);
};
@action fetchRecentlyViewed = async (options: ?Object): Promise<*> => {
@action
fetchRecentlyViewed = async (options: ?Object): Promise<*> => {
const data = await this.fetchAll('viewed', options);
runInAction('DocumentsStore#fetchRecentlyViewed', () => {
@@ -99,11 +103,13 @@ class DocumentsStore extends BaseStore {
return data;
};
@action fetchStarred = async (): Promise<*> => {
@action
fetchStarred = async (): Promise<*> => {
await this.fetchAll('starred');
};
@action search = async (query: string): Promise<*> => {
@action
search = async (query: string): Promise<*> => {
const res = await client.get('/documents.search', { query });
invariant(res && res.data, 'res or res.data missing');
const { data } = res;
@@ -111,11 +117,13 @@ class DocumentsStore extends BaseStore {
return data.map(documentData => documentData.id);
};
@action prefetchDocument = async (id: string) => {
@action
prefetchDocument = async (id: string) => {
if (!this.getById(id)) this.fetch(id, true);
};
@action fetch = async (id: string, prefetch?: boolean): Promise<*> => {
@action
fetch = async (id: string, prefetch?: boolean): Promise<*> => {
if (!prefetch) this.isFetching = true;
try {
@@ -137,11 +145,13 @@ class DocumentsStore extends BaseStore {
}
};
@action add = (document: Document): void => {
@action
add = (document: Document): void => {
this.data.set(document.id, document);
};
@action remove = (id: string): void => {
@action
remove = (id: string): void => {
this.data.delete(id);
};

View File

@@ -6,11 +6,13 @@ class ErrorsStore {
/* Actions */
@action add = (message: string): void => {
@action
add = (message: string): void => {
this.data.push(message);
};
@action remove = (index: number): void => {
@action
remove = (index: number): void => {
this.data.splice(index, 1);
};
}

View File

@@ -11,39 +11,47 @@ class UiStore {
@observable editMode: boolean = false;
/* Actions */
@action setActiveModal = (name: string, props: ?Object): void => {
@action
setActiveModal = (name: string, props: ?Object): void => {
this.activeModalName = name;
this.activeModalProps = props;
};
@action clearActiveModal = (): void => {
@action
clearActiveModal = (): void => {
this.activeModalName = undefined;
this.activeModalProps = undefined;
};
@action setActiveDocument = (document: Document): void => {
@action
setActiveDocument = (document: Document): void => {
this.activeDocumentId = document.id;
this.activeCollectionId = document.collection.id;
};
@action clearActiveDocument = (): void => {
@action
clearActiveDocument = (): void => {
this.activeDocumentId = undefined;
this.activeCollectionId = undefined;
};
@action enableEditMode() {
@action
enableEditMode() {
this.editMode = true;
}
@action disableEditMode() {
@action
disableEditMode() {
this.editMode = false;
}
@action enableProgressBar() {
@action
enableProgressBar() {
this.progressBarVisible = true;
}
@action disableProgressBar() {
@action
disableProgressBar() {
this.progressBarVisible = false;
}
}