diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f6455690..c0de5bc6c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,6 +30,17 @@ jobs: run: | brew install libsodium openssl rustup target add wasm32-unknown-unknown + - name: Build Holochain + env: + SQLCIPHER_STATIC: 1 + LDFLAGS: "-L/usr/local/opt/openssl/lib" + CPPFLAGS: "-I/usr/local/opt/openssl/include" + PKG_CONFIG_PATH: "/usr/local/opt/openssl/lib/pkgconfig" + run: | + cargo install lair_keystore --git https://github.com/holochain/lair --rev bd92b76ad9cc18bc0c0db215e4bea9767c9003cf + cargo install holochain --git https://github.com/holochain/holochain --rev af7de6eca55d8dd3d22bbfccee738fd11f2a2e12 + cargo install holochain_cli --git https://github.com/holochain/holochain --rev af7de6eca55d8dd3d22bbfccee738fd11f2a2e12 + ./scripts/copy-hc.sh - name: Cache cargo registry uses: actions/cache@v1 with: @@ -45,17 +56,6 @@ jobs: with: path: ~/.cargo/bin key: ${{ runner.os }}-cargo-bin-${{ hashFiles('**/Cargo.lock') }} - - name: Build Holochain - env: - SQLCIPHER_STATIC: 1 - LDFLAGS: "-L/usr/local/opt/openssl/lib" - CPPFLAGS: "-I/usr/local/opt/openssl/include" - PKG_CONFIG_PATH: "/usr/local/opt/openssl/lib/pkgconfig" - run: | - cargo install lair_keystore --git https://github.com/holochain/lair --rev bd92b76ad9cc18bc0c0db215e4bea9767c9003cf - cargo install holochain --git https://github.com/holochain/holochain --rev af7de6eca55d8dd3d22bbfccee738fd11f2a2e12 - cargo install holochain_cli --git https://github.com/holochain/holochain --rev af7de6eca55d8dd3d22bbfccee738fd11f2a2e12 - ./scripts/copy-hc.sh - name: Install Node.js, NPM & Yarn uses: actions/setup-node@v2 with: @@ -78,8 +78,8 @@ jobs: - name: Cache macOS release (x64) uses: actions/upload-artifact@v1 with: - name: Junto-${{steps.ref.outputs.version}}.dmg - path: ./dist_electron/Junto-${{steps.ref.outputs.version}}.dmg + name: Flux-${{steps.ref.outputs.version}}.dmg + path: ./dist_electron/Flux-${{steps.ref.outputs.version}}.dmg - name: Cache latest-mac.yml uses: actions/upload-artifact@v1 with: @@ -124,8 +124,8 @@ jobs: # - name: Cache nsis release # uses: actions/upload-artifact@v1 # with: - # name: Junto Setup ${{steps.ref.outputs.version}}.exe - # path: ./dist_electron/Junto Setup ${{steps.ref.outputs.version}}.exe + # name: Flux Setup ${{steps.ref.outputs.version}}.exe + # path: ./dist_electron/Flux Setup ${{steps.ref.outputs.version}}.exe # - name: Cache latest-windows.yml # uses: actions/upload-artifact@v1 # with: @@ -150,6 +150,14 @@ jobs: sudo apt-get update sudo apt-get install -y build-essential libssl-dev libsqlcipher-dev rustup target add wasm32-unknown-unknown + - name: Build Holochain + env: + SQLCIPHER_STATIC: 1 + run: | + cargo install lair_keystore --git https://github.com/holochain/lair --rev bd92b76ad9cc18bc0c0db215e4bea9767c9003cf + cargo install holochain --git https://github.com/holochain/holochain --rev af7de6eca55d8dd3d22bbfccee738fd11f2a2e12 + cargo install holochain_cli --git https://github.com/holochain/holochain --rev af7de6eca55d8dd3d22bbfccee738fd11f2a2e12 + ./scripts/copy-hc.sh - name: Cache cargo registry uses: actions/cache@v1 with: @@ -165,14 +173,6 @@ jobs: with: path: ~/.cargo/bin key: ${{ runner.os }}-cargo-bin-${{ hashFiles('**/Cargo.lock') }} - - name: Build Holochain - env: - SQLCIPHER_STATIC: 1 - run: | - cargo install lair_keystore --git https://github.com/holochain/lair --rev bd92b76ad9cc18bc0c0db215e4bea9767c9003cf - cargo install holochain --git https://github.com/holochain/holochain --rev af7de6eca55d8dd3d22bbfccee738fd11f2a2e12 - cargo install holochain_cli --git https://github.com/holochain/holochain --rev af7de6eca55d8dd3d22bbfccee738fd11f2a2e12 - ./scripts/copy-hc.sh - name: Install Node.js, NPM & Yarn uses: actions/setup-node@v2 with: @@ -193,13 +193,13 @@ jobs: - name: Cache AppImage uses: actions/upload-artifact@v1 with: - name: Junto-${{steps.ref.outputs.version}}.AppImage - path: ./dist_electron/Junto-${{steps.ref.outputs.version}}.AppImage + name: Flux-${{steps.ref.outputs.version}}.AppImage + path: ./dist_electron/Flux-${{steps.ref.outputs.version}}.AppImage - name: Cache .deb release (x64) uses: actions/upload-artifact@v1 with: - name: junto_${{steps.ref.outputs.version}}_amd64.deb - path: ./dist_electron/junto_${{steps.ref.outputs.version}}_amd64.deb + name: flux_${{steps.ref.outputs.version}}_amd64.deb + path: ./dist_electron/flux_${{steps.ref.outputs.version}}_amd64.deb - name: Cache latest-linux.yml uses: actions/upload-artifact@v1 with: @@ -225,22 +225,22 @@ jobs: - name: Download AppImage uses: actions/download-artifact@v1 with: - name: Junto-${{steps.ref.outputs.version}}.AppImage + name: Flux-${{steps.ref.outputs.version}}.AppImage path: . - name: Download deb uses: actions/download-artifact@v1 with: - name: junto_${{steps.ref.outputs.version}}_amd64.deb + name: flux_${{steps.ref.outputs.version}}_amd64.deb path: . - name: Download macOS image uses: actions/download-artifact@v1 with: - name: Junto-${{steps.ref.outputs.version}}.dmg + name: Flux-${{steps.ref.outputs.version}}.dmg path: . # - name: Download Windows Exe # uses: actions/download-artifact@v1 # with: - # name: Junto Setup ${{steps.ref.outputs.version}}.exe + # name: Flux Setup ${{steps.ref.outputs.version}}.exe # path: . # - name: Download latest-windows.yml # uses: actions/download-artifact@v1 @@ -259,9 +259,9 @@ jobs: path: . - name: Generate SHA256 checksums run: | - sha256sum "junto_${{steps.ref.outputs.version}}_amd64.deb" >> "SHA256SUMS.txt" - sha256sum "Junto-${{steps.ref.outputs.version}}.AppImage" >> "SHA256SUMS.txt" - sha256sum "Junto-${{steps.ref.outputs.version}}.dmg" >> "SHA256SUMS.txt" + sha256sum "flux_${{steps.ref.outputs.version}}_amd64.deb" >> "SHA256SUMS.txt" + sha256sum "Flux-${{steps.ref.outputs.version}}.AppImage" >> "SHA256SUMS.txt" + sha256sum "Flux-${{steps.ref.outputs.version}}.dmg" >> "SHA256SUMS.txt" sha256sum "latest-linux.yml" >> "SHA256SUMS.txt" sha256sum "latest-mac.yml" >> "SHA256SUMS.txt" - name: Verify checksums @@ -282,8 +282,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.github_token }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./junto_${{steps.ref.outputs.version}}_amd64.deb - asset_name: junto_${{steps.ref.outputs.version}}_amd64.deb + asset_path: ./flux_${{steps.ref.outputs.version}}_amd64.deb + asset_name: flux_${{steps.ref.outputs.version}}_amd64.deb asset_content_type: application/octet-stream - name: Upload AppImage binary (arm64) uses: actions/upload-release-asset@v1.0.1 @@ -291,8 +291,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.github_token }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Junto-${{steps.ref.outputs.version}}.AppImage - asset_name: Junto-${{steps.ref.outputs.version}}.AppImage + asset_path: ./Flux-${{steps.ref.outputs.version}}.AppImage + asset_name: Flux-${{steps.ref.outputs.version}}.AppImage asset_content_type: application/octet-stream - name: Upload macOS image uses: actions/upload-release-asset@v1.0.1 @@ -300,8 +300,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Junto-${{steps.ref.outputs.version}}.dmg - asset_name: Junto-${{steps.ref.outputs.version}}.dmg + asset_path: ./Flux-${{steps.ref.outputs.version}}.dmg + asset_name: Flux-${{steps.ref.outputs.version}}.dmg asset_content_type: application/octet-stream # - name: Upload Windows exe # uses: actions/upload-release-asset@v1.0.1 @@ -309,8 +309,8 @@ jobs: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # with: # upload_url: ${{ steps.create_release.outputs.upload_url }} - # asset_path: ./Junto Setup ${{steps.ref.outputs.version}}.exe - # asset_name: Junto Setup ${{steps.ref.outputs.version}}.exe + # asset_path: ./Flux Setup ${{steps.ref.outputs.version}}.exe + # asset_name: Flux Setup ${{steps.ref.outputs.version}}.exe # asset_content_type: application/octet-stream - name: Upload latest-linux.yml uses: actions/upload-release-asset@v1.0.1 diff --git a/.gitignore b/.gitignore index b33cb6367..b515241a2 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,6 @@ pnpm-debug.log* #Electron-builder output /dist_electron -coverage \ No newline at end of file +coverage + +cachedb \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a7c0342f0..b893d58db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,38 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project *loosely* adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). More specifically: +## [0.2.8] - 15/10/2021 + +### Added + - Added button to copy log file to desktop when global error is shown + - Members on community now also added by signals + +### Changed + - New Flux logo's! + - Renamed application name from Junto -> Flux where applicable + - Loading screen now uses flux wordmark + - Cache service now uses levelDB + - Store now only saves array of did's for user instead of entire profile data to save bloating the store + - Logo's and animations now use flux design + +### Deprecated + +### Removed + - Old files & images + - Member & group expression workers removed and replaced with single gql call on community route change + - Logout option + +### Fixed + - Global variables now used for all places where worker polling happens and poll delay used + - MessageView now only tries to load unique did profiles for expression messages and not duplicate agents + - Now correctly using thumbnail for rendering profile images on messages + - Added id to expression worker loops to avoid duplicate getExpression calls when resolving signals / links + - Home channel now shows correct name in Channel header information + +### Security + +--- + ## [0.2.7] - 11/10/2021 ### Added diff --git a/build/icon.png b/build/icon.png index 950f0902d..211495903 100644 Binary files a/build/icon.png and b/build/icon.png differ diff --git a/dna-rollup.js b/dna-rollup.js deleted file mode 100644 index 8b7c91445..000000000 --- a/dna-rollup.js +++ /dev/null @@ -1,13 +0,0 @@ -import fs from "fs"; - -export default function dna() { - return { - name: "dna", - load: function load(id) { - if (!id.endsWith(".dna")) return null; - var base64 = fs.readFileSync(id, "base64").replace(/[\r\n]+/gm, ""); - var code = `var dna = "${base64}"; \nexport default dna;`; - return code.trim(); - }, - }; -} diff --git a/index.html b/index.html deleted file mode 100644 index 3276e5d47..000000000 --- a/index.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Hello World! - - - -

Hello World!

-

- We are using node , - Chrome , - and Electron . -

- - \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index 6a02856b8..f8fab562f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,10 +4,7 @@ const { pathsToModuleNameMapper } = require("ts-jest/utils"); const { compilerOptions } = require("./tsconfig"); const esModules = [ - // "@junto-foundation/junto-elements", "runtime-dom", - "register-service-worker", - // "vue-advanced-cropper", "vue3-observe-visibility2", "vue3-virtual-scroller", ].join("|"); diff --git a/package.json b/package.json index 483224850..4f1ebe4c2 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { - "name": "junto", - "version": "0.2.7", + "name": "flux", + "version": "0.2.8", "private": true, - "description": "Junto ad4m chat application leveraging distributed & decentralized technologies", + "description": "A social web3 tool kit for communities", "author": "josh@junto.foundation", "repository": { "type": "git", - "url": "https://github.com/juntofoundation/communities.git" + "url": "https://github.com/juntofoundation/flux.git" }, "scripts": { "lint": "vue-cli-service lint", @@ -29,16 +29,15 @@ "@perspect3vism/ad4m": "0.1.18", "@perspect3vism/ad4m-executor": "0.1.18", "@tiptap/vue-3": "^2.0.0-beta.45", - "@vue/apollo-util": "^4.0.0-alpha.11", "core-js": "^3.15.2", "date-fns": "^2.22.1", "datocms-structured-text-utils": "^1.2.0", "electron-updater": "^4.3.9", "graphql": "^15.5.0", + "idb": "^6.1.4", + "level": "^7.0.1", "patch-package": "^6.4.7", "pinia": "^2.0.0-rc.4", - "register-service-worker": "^1.7.1", - "subscriptions-transport-ws": "^0.9.19", "uuid": "^8.3.2", "vue": "^3.0.0", "vue-advanced-cropper": "^2.3.1", @@ -53,6 +52,7 @@ "@testing-library/vue": "^6.4.2", "@types/electron-devtools-installer": "^2.2.0", "@types/jest": "^26.0.20", + "@types/level": "^6.0.0", "@types/mocha": "^8.2.1", "@types/object-hash": "^2.1.1", "@types/uuid": "^8.3.0", @@ -73,6 +73,7 @@ "babel-jest": "^26.0.0", "babel-plugin-parameter-decorator": "^1.0.16", "babel-plugin-transform-typescript-metadata": "^0.3.2", + "canvas": "^2.8.0", "easygraphql-tester": "^6.0.1", "electron": "15.1.1", "electron-devtools-installer": "^3.1.0", @@ -97,6 +98,7 @@ "webpack-node-externals": "^2.5.2" }, "contributors": [ - "eric@junto.foundation" + "eric@junto.foundation", + "kaichaosuna@gmail.com" ] } diff --git a/public/img/icons/favicon-128x128@5x.png b/public/img/icons/favicon-128x128@5x.png deleted file mode 100644 index fae245e19..000000000 Binary files a/public/img/icons/favicon-128x128@5x.png and /dev/null differ diff --git a/public/img/icons/favicon-16x16.png b/public/img/icons/favicon-16x16.png deleted file mode 100644 index 30ce3fe1b..000000000 Binary files a/public/img/icons/favicon-16x16.png and /dev/null differ diff --git a/public/img/icons/favicon-32x32.png b/public/img/icons/favicon-32x32.png index 49a80bee6..73cd0e115 100644 Binary files a/public/img/icons/favicon-32x32.png and b/public/img/icons/favicon-32x32.png differ diff --git a/public/img/icons/favicon-white-16x16.png b/public/img/icons/favicon-white-16x16.png deleted file mode 100644 index 6d9b0eaf7..000000000 Binary files a/public/img/icons/favicon-white-16x16.png and /dev/null differ diff --git a/public/img/icons/favicon-white-32x32@2x.png b/public/img/icons/favicon-white-32x32@2x.png deleted file mode 100644 index 461dbe720..000000000 Binary files a/public/img/icons/favicon-white-32x32@2x.png and /dev/null differ diff --git a/public/img/icons/icon.png b/public/img/icons/icon.png new file mode 100644 index 000000000..87e68db2d Binary files /dev/null and b/public/img/icons/icon.png differ diff --git a/public/img/icons/junto-white.png b/public/img/icons/junto-white.png deleted file mode 100644 index 65d8d58c4..000000000 Binary files a/public/img/icons/junto-white.png and /dev/null differ diff --git a/public/img/icons/junto_web_logo--rainbow.png b/public/img/icons/junto_web_logo--rainbow.png deleted file mode 100644 index ba90e6afa..000000000 Binary files a/public/img/icons/junto_web_logo--rainbow.png and /dev/null differ diff --git a/public/img/icons/logo.svg b/public/img/icons/logo.svg new file mode 100644 index 000000000..2d089692e --- /dev/null +++ b/public/img/icons/logo.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/public/img/icons/safari-pinned-tab.svg b/public/img/icons/safari-pinned-tab.svg deleted file mode 100644 index e44c0d5b0..000000000 --- a/public/img/icons/safari-pinned-tab.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/public/loading.html b/public/loading.html index 986924e16..4985c34ae 100644 --- a/public/loading.html +++ b/public/loading.html @@ -5,7 +5,7 @@ - Communities + Flux
- - Junto + + + + + +
diff --git a/scripts/clean-state.command b/scripts/clean-state.command index ceda93a47..dc602b801 100755 --- a/scripts/clean-state.command +++ b/scripts/clean-state.command @@ -1,9 +1,9 @@ #!/bin/bash if [[ "$OSTYPE" == "linux-gnu"* ]]; then - path="$HOME/.config/junto" + path="$HOME/.config/flux" elif [[ "$OSTYPE" == "darwin"* ]]; then - path="$HOME/Library/Application Support/junto" + path="$HOME/Library/Application Support/flux" fi echo "Will delete path: $path" diff --git a/scripts/clean-state.js b/scripts/clean-state.js index 6e3438ea7..ab798e59a 100644 --- a/scripts/clean-state.js +++ b/scripts/clean-state.js @@ -30,16 +30,16 @@ async function main() { process.env.HOME, "Library", "Application Support", - "junto" + "flux" ); break; } case "win32": { - configPath = path.join(process.env.APPDATA, "junto"); + configPath = path.join(process.env.APPDATA, "flux"); break; } case "linux": { - configPath = path.join(process.env.HOME, ".config", "junto"); + configPath = path.join(process.env.HOME, ".config", "flux"); break; } } diff --git a/src/App.vue b/src/App.vue index fe715965f..bb47fc847 100644 --- a/src/App.vue +++ b/src/App.vue @@ -30,6 +30,11 @@
{{ globalError.message }}
+ + If you have also been asked to include a log file with your report, + click the button below to copy a log file to your desktop: + + Copy @@ -40,8 +45,7 @@ import { useRoute, useRouter } from "vue-router"; import { gql } from "@apollo/client/core"; import { defineComponent, computed, watch } from "vue"; import { onError } from "@apollo/client/link/error"; -import { logErrorMessages } from "@vue/apollo-util"; -import { expressionGetDelayMs, expressionGetRetries } from "@/core/juntoTypes"; +import { expressionGetDelayMs, expressionGetRetries } from "@/constants/config"; import { GET_EXPRESSION } from "@/core/graphql_queries"; import { ApplicationState, @@ -56,8 +60,9 @@ import { useUserStore } from "./store/user"; import { useAppStore } from "./store/app"; import { useDataStore } from "./store/data"; import { addTrustedAgents } from "@/core/mutations/addTrustedAgents"; -import { JUNTO_AGENT, AD4M_AGENT } from "@/ad4m-globals"; +import { JUNTO_AGENT, AD4M_AGENT } from "@/constants/agents"; import { ad4mClient } from "./app"; +import { MEMBER } from "./constants/neighbourhoodMeta"; declare global { interface Window { @@ -77,9 +82,6 @@ export default defineComponent({ onError((error) => { console.log("Got global graphql error, logging with error", error); if (process.env.NODE_ENV !== "production") { - // can use error.operation.operationName to single out a query type. - logErrorMessages(error); - appStore.showDangerToast({ message: JSON.stringify(error), }); @@ -109,6 +111,7 @@ export default defineComponent({ const expressionWorker = new Worker("pollingWorker.js"); expressionWorker.postMessage({ + id: link.data!.target!, retry: expressionGetRetries, interval: expressionGetDelayMs, query: print(GET_EXPRESSION), @@ -147,6 +150,15 @@ export default defineComponent({ value: true, }); }); + } else if (link.data!.predicate! === MEMBER) { + const did = link.data!.target!.split("://")[1]; + console.log("Got new member in signal! Parsed out did: ", did); + if (did) { + dataStore.setNeighbourhoodMember({ + member: did, + perspectiveUuid: perspective, + }); + } } }; @@ -275,6 +287,15 @@ export default defineComponent({ this.userStore.updateAgentStatus(status); }); }, + methods: { + copyLogFile() { + window.api.send("copyLogs"); + this.appStore.showSuccessToast({ + message: + "Log file called debug.log been copied to your desktop, please upload to Junto Discord, thanks <3", + }); + }, + }, }); diff --git a/src/__tests__/graphql.ts b/src/__tests__/graphql.ts index f96fccd7b..f1ffef46f 100644 --- a/src/__tests__/graphql.ts +++ b/src/__tests__/graphql.ts @@ -33,7 +33,7 @@ import { } from "../core/graphql_queries"; import EasyGraphQLTester from "easygraphql-tester"; import { DocumentNode } from "graphql"; -import { SOCIAL_CONTEXT_OFFICIAL } from "@/ad4m-globals"; +import { SOCIAL_CONTEXT_OFFICIAL } from "@/constants/languages"; const tester = new EasyGraphQLTester(typeDefsString); diff --git a/src/__tests__/store/data/actions/createCommunity.ts b/src/__tests__/store/data/actions/createCommunity.ts index 1ca4f1e53..893d1b4dc 100644 --- a/src/__tests__/store/data/actions/createCommunity.ts +++ b/src/__tests__/store/data/actions/createCommunity.ts @@ -1,4 +1,3 @@ -import community from "../../../fixtures/community.json"; import createCommunityPerspective from "../../../fixtures/createCommunityPerspective.json"; import createCommunityUniqueHolochainLanguage from "../../../fixtures/createCommunityUniqueHolochainLanguage.json"; import createCommunityLinkType from "../../../fixtures/createCommunityLinkType.json"; @@ -19,7 +18,11 @@ import * as createChannel from "@/core/methods/createChannel"; import * as getLanguage from "@/core/queries/getLanguage"; import { createPinia, Pinia, setActivePinia } from "pinia"; import { useDataStore } from "@/store/data"; -import { GROUP_EXPRESSION_OFFICIAL, SHORTFORM_EXPRESSION_OFFICIAL, SOCIAL_CONTEXT_OFFICIAL } from "@/ad4m-globals"; +import { + GROUP_EXPRESSION_OFFICIAL, + SHORTFORM_EXPRESSION_OFFICIAL, + SOCIAL_CONTEXT_OFFICIAL, +} from "@/constants/languages"; describe("Create Community", () => { let store: Pinia; diff --git a/src/__tests__/store/data/actions/showMessageNotifications.ts b/src/__tests__/store/data/actions/showMessageNotifications.ts index eb9a095e8..3a6e0b56c 100644 --- a/src/__tests__/store/data/actions/showMessageNotifications.ts +++ b/src/__tests__/store/data/actions/showMessageNotifications.ts @@ -5,26 +5,47 @@ import getProfileFixture from "../../../fixtures/getProfile.json"; import * as agentUnlock from "../../../../core/mutations/agentUnlock"; import lockAgentFixture from "../../../fixtures/lockAgent.json"; import { AgentStatus, Expression } from "@perspect3vism/ad4m"; -import { TimeoutCache } from "@/utils/timeoutCache"; -import { ExpressionTypes } from "@/store/types"; +import { ExpressionTypes, ProfileExpression } from "@/store/types"; import * as getExpressionNoCache from "@/core/queries/getExpression"; import { createPinia, Pinia, setActivePinia } from "pinia"; import { useUserStore } from "@/store/user"; import { useDataStore } from "@/store/data"; +const testProfile = { + did: initAgentFixture.did, + data: JSON.parse(getProfileFixture.data!) +} as ProfileExpression; + + +jest.mock('@/utils/timeoutCache', () => { + return { + TimeoutCache: jest.fn().mockImplementation(() => { + return { + set: jest.fn(), + get: (link: string) => { + if (link.includes('101')) { + return undefined + } else { + return testProfile; + } + }, + remove: jest.fn(), + }; + }) + }; +}); + describe("Show Message Notification", () => { let store: Pinia; let profileLangAddress: string; let did: string; let profileLink: string; - beforeAll(() => { + beforeAll(async () => { Object.defineProperty(global, "Notification", { value: jest.fn(), }); - const cache = new TimeoutCache(10); - profileLangAddress = community.neighbourhood.typedExpressionLanguages.find( (t: any) => t.expressionType === ExpressionTypes.ProfileExpression )!.languageAddress!; @@ -32,8 +53,6 @@ describe("Show Message Notification", () => { did = initAgentFixture.did; profileLink = `${profileLangAddress}://${did}`; - - cache.remove(profileLink); }); beforeEach(() => { diff --git a/src/__tests__/utils/profileHelpers.ts b/src/__tests__/utils/profileHelpers.ts index d082935af..a58a6f16a 100644 --- a/src/__tests__/utils/profileHelpers.ts +++ b/src/__tests__/utils/profileHelpers.ts @@ -1,18 +1,44 @@ -import { ExpressionTypes } from "@/store/types"; -import { getProfile } from "@/utils/profileHelpers"; -import { TimeoutCache } from "@/utils/timeoutCache"; +import { ExpressionTypes, ProfileExpression } from "@/store/types"; +import { getProfile, parseProfile } from "@/utils/profileHelpers"; +import {TimeoutCache} from "@/utils/timeoutCache"; import community from "../fixtures/community.json"; import initAgentFixture from "../fixtures/initAgent.json"; import getProfileFixture from "../fixtures/getProfile.json"; import * as getExpressionNoCache from "@/core/queries/getExpression"; import { Expression } from "@perspect3vism/ad4m"; +import { mocked } from 'ts-jest/utils'; + +const testProfile = { + did: initAgentFixture.did, + data: JSON.parse(getProfileFixture.data!) +} as ProfileExpression; + +jest.mock('@/utils/timeoutCache', () => { + return { + TimeoutCache: jest.fn().mockImplementation(() => { + return { + set: jest.fn(), + get: (link: string) => { + if (link.includes('101')) { + return undefined + } else { + return testProfile; + } + }, + remove: jest.fn(), + }; + }) + }; +}); describe("ProfileHelpers", () => { + const MockedSoundPlayer = mocked(TimeoutCache, true); + let profileLangAddress: string; let did: string; let profileLink: string; - beforeAll(() => { + beforeAll(async () => { const cache = new TimeoutCache(10); profileLangAddress = community.neighbourhood.typedExpressionLanguages.find( @@ -23,11 +49,12 @@ describe("ProfileHelpers", () => { profileLink = `${profileLangAddress}://${did}`; - cache.remove(profileLink); + await cache.remove(profileLink); }); beforeEach(() => { - // @ts-ignore + MockedSoundPlayer.mockClear(); + jest .spyOn(getExpressionNoCache, "getExpressionNoCache") .mockImplementation(async (url) => { @@ -41,59 +68,20 @@ describe("ProfileHelpers", () => { }); test("Test fetch profile with wrong did", async () => { - const cache = new TimeoutCache(10); - - expect(cache.get(profileLink)).toBeUndefined(); - - const testProfile = { - author: getProfileFixture.author!, - data: JSON.parse(getProfileFixture.data!), - timestamp: getProfileFixture.timestamp!, - proof: getProfileFixture.proof!, - }; - const profile = await getProfile(profileLangAddress, `${did}101`); expect(profile).toStrictEqual(null); - expect(cache.get(profileLink)).toBeUndefined(); }); test("Test fetch the correct profile", async () => { - const cache = new TimeoutCache(10); - - expect(cache.get(profileLink)).toBeUndefined(); - - const testProfile = { - author: getProfileFixture.author!, - data: JSON.parse(getProfileFixture.data!), - timestamp: getProfileFixture.timestamp!, - proof: getProfileFixture.proof!, + const newTestProfile = { + did: testProfile.did, + ...parseProfile(testProfile.data.profile) }; const profile = await getProfile(profileLangAddress, did); - expect(profile).toStrictEqual(testProfile); - expect(cache.get(profileLink)).not.toBeUndefined(); - expect(cache.get(profileLink)).toStrictEqual(testProfile); - }); - - test("Test fetch the correct profile from cache", async () => { - const cache = new TimeoutCache(10); - - const testProfile = { - author: getProfileFixture.author!, - data: JSON.parse(getProfileFixture.data!), - timestamp: getProfileFixture.timestamp!, - proof: getProfileFixture.proof!, - }; - - expect(cache.get(profileLink)).not.toBeUndefined(); - expect(cache.get(profileLink)).toStrictEqual(testProfile); - - const profile = await getProfile(profileLangAddress, did); - expect(profile).toStrictEqual(testProfile); - expect(cache.get(profileLink)).not.toBeUndefined(); - expect(cache.get(profileLink)).toStrictEqual(testProfile); + expect(profile).toStrictEqual(newTestProfile); }); }); diff --git a/src/__tests__/utils/timeoutCache.ts b/src/__tests__/utils/timeoutCache.ts index 6076bfd11..ac7a1df2c 100644 --- a/src/__tests__/utils/timeoutCache.ts +++ b/src/__tests__/utils/timeoutCache.ts @@ -1,38 +1,59 @@ import sleep from "@/utils/sleep"; import { TimeoutCache } from "@/utils/timeoutCache"; +import { mocked } from "ts-jest/utils"; + +jest.mock('@/utils/timeoutCache', () => { + return { + TimeoutCache: jest.fn().mockImplementation(() => { + return { + set: jest.fn(), + get: (key: string) => { + if (key === 'test') { + return undefined + } else { + return 'test'; + } + }, + remove: jest.fn(), + }; + }) + }; +}); describe("Timeoutcache", () => { - beforeEach(() => { + mocked(TimeoutCache, true); + + beforeEach(async () => { const cache = new TimeoutCache(10); - cache.remove("test"); + await cache.remove("test"); }); test("timeout cache is empty", async () => { const cache = new TimeoutCache(10); - expect(cache.get("test")).toBe(undefined); + expect(await cache.get("test")).toBe(undefined); }); test("timeout cache is not empty", async () => { const cache = new TimeoutCache(10); - expect(cache.get("test")).toBe(undefined); + expect(await cache.get("test")).toBe(undefined); - cache.set("test", "test"); + await cache.set("test1", "test"); - expect(cache.get("test")).toBe("test"); + expect(await cache.get("test1")).toBe("test"); }); test("timeout cache is empty after 10 ms", async () => { const cache = new TimeoutCache(10); - expect(cache.get("test")).toBe(undefined); + expect(await cache.get("test")).toBe(undefined); - cache.set("test", "test"); + await cache.set("test", "test"); await sleep(20); - expect(cache.get("test")).toBe(undefined); + expect(await cache.get("test")).toBe(undefined); }); }); diff --git a/src/app.ts b/src/app.ts index a03f47cf2..adc86e4c9 100644 --- a/src/app.ts +++ b/src/app.ts @@ -10,6 +10,8 @@ import { createPinia } from "pinia"; import { ApolloClient, InMemoryCache } from "@apollo/client"; import { WebSocketLink } from "@apollo/client/link/ws"; import { Ad4mClient } from "@perspect3vism/ad4m"; +import { TimeoutCache } from "./utils/timeoutCache"; +import { ProfileExpression } from "./store/types"; export const apolloClient = new ApolloClient({ link: new WebSocketLink({ @@ -29,6 +31,7 @@ export const apolloClient = new ApolloClient({ }, }); +export const profileCache = new TimeoutCache(1000 * 60 * 5); export const ad4mClient = new Ad4mClient(apolloClient); const pinia = createPinia(); diff --git a/src/assets/images/app-secure.png b/src/assets/images/app-secure.png deleted file mode 100644 index adaa5d113..000000000 Binary files a/src/assets/images/app-secure.png and /dev/null differ diff --git a/src/assets/images/junto_app_icon.png b/src/assets/images/junto_app_icon.png deleted file mode 100644 index 8d9d22a4b..000000000 Binary files a/src/assets/images/junto_app_icon.png and /dev/null differ diff --git a/src/assets/images/junto_web_logo--rainbow.png b/src/assets/images/junto_web_logo--rainbow.png deleted file mode 100644 index ba90e6afa..000000000 Binary files a/src/assets/images/junto_web_logo--rainbow.png and /dev/null differ diff --git a/src/assets/images/junto_web_rainbow.png b/src/assets/images/junto_web_rainbow.png deleted file mode 100644 index 198797bcc..000000000 Binary files a/src/assets/images/junto_web_rainbow.png and /dev/null differ diff --git a/src/assets/images/logo.svg b/src/assets/images/logo.svg new file mode 100644 index 000000000..2d089692e --- /dev/null +++ b/src/assets/images/logo.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/components/avatar-group/AvatarGroup.vue b/src/components/avatar-group/AvatarGroup.vue index 1112a7db4..1d01dd816 100644 --- a/src/components/avatar-group/AvatarGroup.vue +++ b/src/components/avatar-group/AvatarGroup.vue @@ -5,17 +5,11 @@ +{{ users.length - 3 }} @@ -26,14 +20,35 @@ diff --git a/src/views/channel-view/ChannelMessages.vue b/src/views/channel-view/ChannelMessages.vue index 526f9b572..9b8e9529a 100644 --- a/src/views/channel-view/ChannelMessages.vue +++ b/src/views/channel-view/ChannelMessages.vue @@ -51,7 +51,7 @@ :message="item.expression.data.body" :timestamp="item.expression.timestamp" :username="users[item.expression.author]?.username" - :profileImg="users[item.expression.author]?.profilePicture" + :profileImg="users[item.expression.author]?.thumbnailPicture" @profileClick="(did) => $emit('profileClick', did)" @mentionClick="(dataset) => $emit('mentionClick', dataset)" /> @@ -64,7 +64,7 @@