Skip to content

Commit

Permalink
Merge branch 'develop' into deployments/staging/makerdao
Browse files Browse the repository at this point in the history
  • Loading branch information
froid1911 committed Aug 14, 2024
2 parents 151fc74 + 00dc9db commit 9e16b82
Show file tree
Hide file tree
Showing 21 changed files with 436 additions and 98 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/staging/makerdao/switchboard/
VITE_BASE_HREF=/
ASSET_URL=/

VITE_APP_REQUIRES_HARD_REFRESH=true

######## RENOWN CONFIG ########
# Renown instance to use for login
# VITE_RENOWN_URL=http://localhost:3000
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-arbitrum-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
--build-arg VITE_DISABLE_DELETE_CLOUD_DRIVES=true
--build-arg VITE_DISABLE_DELETE_LOCAL_DRIVES=true
--build-arg VITE_LOCAL_DRIVES_ENABLED=false
--build-arg VITE_SEARCH_BAR_ENABLED=false
--build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/arbitrum/switchboard/d/arbitrum
--build-arg VITE_RENOWN_CHAIN_ID=42161
--build-arg VITE_HIDE_DOCUMENT_MODEL_SELECTION_SETTINGS=true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-arbitrum-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
--build-arg VITE_LOCAL_DRIVES_ENABLED=false
--build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/staging/arbitrum/switchboard/d/arbitrum
--build-arg VITE_RENOWN_CHAIN_ID=42161
--build-arg VITE_SEARCH_BAR_ENABLED=false
--build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }}
--build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }}
--build-arg VITE_ARBITRUM_ALLOW_LIST=${{secrets.VITE_ARBITRUM_ALLOW_LIST}}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-makerdao-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
--build-arg VITE_ROUTER_BASENAME=/makerdao/connect
--build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }}
--build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }}
--build-arg VITE_SEARCH_BAR_ENABLED=false
--build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/makerdao/switchboard/d/b443d823-3e4d-4e60-ae44-45edafd5f632
--build-arg VITE_RWA_ALLOW_LIST=${{secrets.VITE_RWA_ALLOW_LIST}}
process_type: web
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-makerdao-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
--build-arg VITE_ROUTER_BASENAME=/staging/makerdao/connect
--build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }}
--build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }}
--build-arg VITE_SEARCH_BAR_ENABLED=false
--build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/staging/makerdao/switchboard/d/280dd289-ec51-40f0-adad-c154967fc2b2
--build-arg VITE_RWA_ALLOW_LIST=${{secrets.VITE_RWA_ALLOW_LIST}}
process_type: web
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-powerhouse-develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ jobs:
--build-arg VITE_BASE_HREF=/develop/powerhouse/connect/
--build-arg VITE_ROUTER_BASENAME=/develop/powerhouse/connect
--build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/develop/powerhouse/switchboard/d/core-dev
--build-arg VITE_SEARCH_BAR_ENABLED=false
process_type: web
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-powerhouse-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ jobs:
--build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }}
--build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }}
--build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/powerhouse/switchboard/d/powerhouse
--build-arg VITE_SEARCH_BAR_ENABLED=false
process_type: web
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-powerhouse-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ jobs:
--build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }}
--build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }}
--build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/staging/powerhouse/switchboard/d/powerhouse
--build-arg VITE_SEARCH_BAR_ENABLED=false
process_type: web
6 changes: 0 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

### Features

<<<<<<< HEAD
* add animated loader for editors ([0ef0cc5](https://github.com/powerhouse-inc/document-model-electron/commit/0ef0cc587bb04d3fa65a4fd133c4c42f5998c92c))
* add comments ([a5e81b2](https://github.com/powerhouse-inc/document-model-electron/commit/a5e81b22b1d634548a6323ef5b4a5efa2b0a87ec))
* add file icon logic ([3ba0aae](https://github.com/powerhouse-inc/document-model-electron/commit/3ba0aae6d692a2368b19e1defeb655d582c5c220))
Expand Down Expand Up @@ -119,11 +118,6 @@
* renown env var ([0b6bb86](https://github.com/powerhouse-inc/document-model-electron/commit/0b6bb86c10a525462f45db82a1cd5607b16a88be))

# [1.0.0-next.4](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-next.3...v1.0.0-next.4) (2024-07-01)
=======
* updated document model deps ([efc3814](https://github.com/powerhouse-inc/document-model-electron/commit/efc38147792002975a87e433d2cf7f4091534b5e))

# [1.0.0-dev.55](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-dev.54...v1.0.0-dev.55) (2024-08-02)
>>>>>>> develop


### Features
Expand Down
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ ENV VITE_RENOWN_NETWORK_ID=${VITE_RENOWN_NETWORK_ID}
ARG VITE_RENOWN_CHAIN_ID=1
ENV VITE_RENOWN_CHAIN_ID=${VITE_RENOWN_CHAIN_ID}

ARG VITE_RENOWN_URL="https://renown.id"
ENV VITE_RENOWN_URL=${VITE_RENOWN_URL}

ARG VITE_SENTRY_DSN=""
ENV VITE_SENTRY_DSN=${VITE_SENTRY_DSN}

Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@
"xvfb-maybe": "^0.2.1"
},
"dependencies": {
"@powerhousedao/design-system": "1.0.0-alpha.159",
"@powerhousedao/design-system": "1.0.0-alpha.160",
"@sentry/react": "^7.109.0",
"@tanstack/react-virtual": "^3.8.1",
"did-key-creator": "^1.2.0",
"document-drive": "^1.0.0-alpha.88",
"document-model": "1.7.0",
"document-model-libs": "^1.82.0",
"document-model-libs": "^1.83.0",
"electron-is-dev": "^3.0.1",
"electron-squirrel-startup": "^1.0.0",
"electron-store": "^8.1.0",
Expand Down
55 changes: 55 additions & 0 deletions public/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const VERSION_CACHE = 'version-cache';
const VERSION_KEY = 'app-version';

self.addEventListener('install', event => {
self.skipWaiting();
});

self.addEventListener('activate', event => {
event.waitUntil(self.clients.claim());
});


self.addEventListener('message', async event => {
if (event.data && event.data.type === 'SET_APP_VERSION') {
const cache = await caches.open(VERSION_CACHE);
await cache.put(VERSION_KEY, new Response(event.data.version));
}
});

async function checkForUpdates() {
try {
const response = await fetch('/version.json', { cache: 'no-store' });
const newVersion = await response.json();
const cache = await caches.open(VERSION_CACHE);
const cachedResponse = await cache.match(VERSION_KEY);

let currentVersion = '';

if (cachedResponse) {
currentVersion = await cachedResponse.text();
}

if (currentVersion === '') {
// Initial cache
await cache.put(VERSION_KEY, new Response(newVersion.version));
} else if (currentVersion !== newVersion.version) {
// New version detected
console.log('Current version:', currentVersion);
console.log('New version:', newVersion.version);

const clients = await self.clients.matchAll();
clients.forEach(client => {
client.postMessage({ type: 'NEW_VERSION_AVAILABLE', requiresHardRefresh: newVersion.requiresHardRefresh });
});

// Update the stored version
await cache.put(VERSION_KEY, new Response(newVersion.version));
}
} catch (error) {
console.error('Error checking version:', error);
}
}

// Check for updates every minute
setInterval(checkForUpdates, 60 * 1000); // 60 seconds
72 changes: 6 additions & 66 deletions src/components/editors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ import { FILE, RevisionHistory } from '@powerhousedao/design-system';
import {
Action,
ActionErrorCallback,
ActionSigner,
BaseAction,
Document,
EditorContext,
Operation,
OperationSignatureContext,
Reducer,
User,
actions,
utils,
} from 'document-model/document';
import { useAtomValue } from 'jotai';
import { Suspense, useEffect, useMemo, useState } from 'react';
Expand All @@ -28,6 +23,7 @@ import {
DocumentDispatchCallback,
useDocumentDispatch,
} from 'src/utils/document-model';
import { addActionContext, signOperation } from 'src/utils/signature';
import Button from './button';
import { EditorLoader } from './editor-loader';

Expand All @@ -43,43 +39,6 @@ export type EditorProps<
onChange?: (document: Document<T, A, LocalState>) => void;
};

const signOperation = async (
operation: Operation,
sign: (data: Uint8Array) => Promise<Uint8Array>,
documentId: string,
document: Document<unknown, Action>,
reducer?: Reducer<unknown, Action, unknown>,
user?: User,
) => {
if (!user) return operation;
if (!operation.context) return operation;
if (!operation.context.signer) return operation;
if (!reducer) {
logger.error(
`Document model '${document.documentType}' does not have a reducer`,
);
return operation;
}

const context: Omit<
OperationSignatureContext,
'operation' | 'previousStateHash'
> = {
documentId,
signer: operation.context.signer,
};

const signedOperation = await utils.buildSignedOperation(
operation,
reducer,
document,
context,
sign,
);

return signedOperation;
};

export function DocumentEditor(props: EditorProps) {
const {
selectedNode,
Expand Down Expand Up @@ -118,29 +77,6 @@ export function DocumentEditor(props: EditorProps) {
const canRedo = !!document?.clipboard.length;
useUndoRedoShortcuts({ undo, redo, canUndo, canRedo });

function addActionContext(action: Action): Action {
if (!user) return action;
const signer: ActionSigner = {
app: {
name: 'Connect',
key: connectDid || '',
},
user: {
address: user.address,
networkId: user.networkId,
chainId: user.chainId,
},
signatures: [],
};

return {
...action,
context: {
signer,
},
};
}

function dispatch(
action: BaseAction | Action,
onErrorCallback?: ActionErrorCallback,
Expand Down Expand Up @@ -168,7 +104,11 @@ export function DocumentEditor(props: EditorProps) {
.catch(logger.error);
};

_dispatch(addActionContext(action), callback, onErrorCallback);
_dispatch(
addActionContext(action, connectDid, user),
callback,
onErrorCallback,
);
}

useEffect(() => {
Expand Down
Loading

0 comments on commit 9e16b82

Please sign in to comment.