Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into log_id
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7B5 committed Jun 1, 2024
2 parents a123527 + bd4f6cc commit f1d7928
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 182 deletions.
14 changes: 7 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module.exports = {
},
rules: {
'camelcase': 0,
'class-methods-use-this': 'warn',
'default-case': 'warn',
'class-methods-use-this': 0,
'default-case': 'error',
'import/prefer-default-export': 0,
'import/no-named-as-default': 0,
'react/destructuring-assignment': 0,
Expand All @@ -28,15 +28,15 @@ module.exports = {
'react/require-default-props': 0,
'react/sort-comp': 0,
'max-len': 0,
'no-await-in-loop': 'warn',
'no-case-declarations': 'warn',
'no-await-in-loop': 'error',
'no-case-declarations': 'error',
'no-console': 0,
'no-else-return': 0,
'no-empty': 'warn',
'no-empty': 'error',
'no-multi-spaces': ['error', {
ignoreEOLComments: true,
}],
'no-nested-ternary': 'warn',
'no-nested-ternary': 0,
'no-plusplus': [
'error',
{
Expand All @@ -49,7 +49,7 @@ module.exports = {
'no-unused-vars': ['error', {
args: 'none',
}],
'no-use-before-define': 'warn',
'no-use-before-define': 'error',
'object-curly-newline': [
'error',
{
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
.env.development.local
.env.test.local
.env.production.local
settings.json

npm-debug.log*
yarn-debug.log*
Expand Down
54 changes: 27 additions & 27 deletions src/actions/cached.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ async function getCacheDB() {
});
}

async function expireCacheItems(store) {
const db = await getCacheDB();
if (!db) {
return;
}

const transaction = db.transaction([store], 'readwrite');
const objStore = transaction.objectStore(store);

const idx = IDBKeyRange.upperBound(Math.floor(Date.now() / 1000));
const req = objStore.index('expiry').openCursor(idx);
req.onsuccess = (ev) => {
const cursor = ev.target.result;
if (cursor) {
objStore.delete(cursor.primaryKey);
cursor.continue();
}
};
}

async function getCacheItem(store, key, version = undefined) {
if (!hasExpired) {
setTimeout(() => expireCacheItems(store), 5000); // TODO: better expire time
Expand Down Expand Up @@ -125,26 +145,6 @@ async function setCacheItem(store, key, expiry, data, version = undefined) {
});
}

async function expireCacheItems(store) {
const db = await getCacheDB();
if (!db) {
return;
}

const transaction = db.transaction([store], 'readwrite');
const objStore = transaction.objectStore(store);

const idx = IDBKeyRange.upperBound(Math.floor(Date.now() / 1000));
const req = objStore.index('expiry').openCursor(idx);
req.onsuccess = (ev) => {
const cursor = ev.target.result;
if (cursor) {
objStore.delete(cursor.primaryKey);
cursor.continue();
}
};
}

function parseEvents(route, driveEvents) {
// sort events
driveEvents.sort((a, b) => {
Expand Down Expand Up @@ -342,13 +342,6 @@ export function fetchEvents(route) {
};
}

export function fetchLocations(route) {
return (dispatch, getState) => {
dispatch(fetchCoord(route, [route.start_lng, route.start_lat], 'startLocation'));
dispatch(fetchCoord(route, [route.end_lng, route.end_lat], 'endLocation'));
};
}

export function fetchCoord(route, coord, locationKey) {
return async (dispatch, getState) => {
const state = getState();
Expand Down Expand Up @@ -415,6 +408,13 @@ export function fetchCoord(route, coord, locationKey) {
};
}

export function fetchLocations(route) {
return (dispatch, getState) => {
dispatch(fetchCoord(route, [route.start_lng, route.start_lat], 'startLocation'));
dispatch(fetchCoord(route, [route.end_lng, route.end_lat], 'endLocation'));
};
}

export function fetchDriveCoords(route) {
return async (dispatch, getState) => {
const state = getState();
Expand Down
1 change: 1 addition & 0 deletions src/actions/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export function doUpload(dongleId, fileNames, paths, urls) {
params: [paths[i], urls[i], { 'x-ms-blob-type': 'BlockBlob' }],
expiry: Math.floor(Date.now() / 1000) + (86400 * 7),
};
// eslint-disable-next-line no-await-in-loop
const resp = await athenaCall(dongleId, payload, 'files_actions_athena_upload');
if (!resp || resp.error) {
const uploading = {};
Expand Down
Loading

0 comments on commit f1d7928

Please sign in to comment.