This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from 'react'; | |
import PropTypes from 'prop-types'; | |
import { | |
compose, | |
unless, | |
prop, | |
isNil, | |
merge, | |
propOr, | |
tryCatch, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef, useReducer } from 'react'; | |
import { merge, forEach, reject, append } from 'ramda'; | |
export const useIsMounted = () => { | |
const ref = useRef(null); | |
useEffect(() => { | |
ref.current = true; | |
return () => { | |
ref.current = false; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import transaction | |
from .models import Project as ProjectModel | |
from .errors import RevisionError, check_user_organisation | |
from . import project_file_services | |
def to_model(project): | |
return ProjectModel( | |
id=project.id, | |
revision=project.revision, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from psycopg2 import connect | |
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT | |
if __name__ == "__main__": | |
con = connect( | |
host=os.environ["DJANGO_DB_HOST"], | |
port=os.environ["DJANGO_DB_PORT"], | |
user=os.environ["DJANGO_DB_USER"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const saveTask = useTask(function*() { | |
yield timeout(1000); | |
yield doSaveTask.perform(); | |
}, 'RESTARTABLE'); | |
const doSaveTask = useTask(function*() { | |
// Ensure that we ALWAYS have the most recent project state | |
const currentState = yield getMostRecentProjectState(); | |
const { revision } = yield updateProject(authHeaders, currentState); | |
yield _setProjectState(assoc('revision', revision)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Task = (func, args) => { | |
const taskState = { | |
isRunning: false, | |
isCancelled: false, | |
isFinished: false, | |
isError: false, | |
result: null, | |
error: null | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let resolve = null; | |
let reject = null; | |
const promise = new Promise((resolve, reject) => { | |
resolve = resolve; | |
reject = reject; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext } from 'react'; | |
import TestRenderer from 'react-test-renderer'; | |
import { AuthProvider, AuthContext } from './AuthContext'; | |
const token = expiry => '.' + btoa(JSON.stringify({ exp: expiry / 1000 })); | |
describe('AuthProvider', () => { | |
let providerContext = null; | |
let mount = null; | |
let unmount = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function AuthProvider({ | |
loadToken, | |
saveToken, | |
requestToken, | |
refreshToken, | |
children | |
}) { | |
const [loadingState, dispatchLoading] = useLoadingReducer({ | |
isLoading: true | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public prepForXml(): IXmlableObject | undefined { | |
if (this.sections.length === 1) { | |
this.root.push(this.sections.pop() as SectionProperties); | |
} | |
return super.prepForXml(); | |
} |