Skip to content

Commit

Permalink
Merge pull request #69 from juntofoundation/dev
Browse files Browse the repository at this point in the history
Release 0.1.7
  • Loading branch information
jdeepee authored Jun 28, 2021
2 parents 3cd1f07 + c04d4a3 commit 7f2fc29
Show file tree
Hide file tree
Showing 18 changed files with 229 additions and 60 deletions.
69 changes: 69 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,75 @@
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.1.6] - 24/06/2021

### Added

### Changed

### Deprecated

### Removed

### Fixed
- Holochain connection in ad4m being started in async meaning connection would not always occur before trying to call conductor in subsequent init languages calls

### Security

---

## [0.1.5] - 24/06/2021

### Added
- Push notifications on message received if app not in view!
- Black theme
- Border around modals on 90s theme

### Changed
- Optimised all polling code to use web workers to avoid polluting the main render thread

### Deprecated

### Removed

### Fixed
- Various fixes on channel notification icons
- Update to new ad4m version to fix concurrent language installation in new holochain version

### Security

---

## [0.1.4] - 22/06/2021

### Added
- Script to fetch languages on build vs building from src
- Cyberpunk theme!
- Global error popup if ad4m or holochain cannot start
- channel notification icon when live message received during sessions
- use vue virtual scroll again for our scrolling
- New messages arriving in channel will prompt UI to give notification to scroll to bottom of view
- Holochain now needs to be built manually for each dev install with nix vs built in repo binaries
- 5 channel views are now kept alive at once to allow for fast rendering/switching between them

### Changed
- Holochain now at latest version @ commit: 8600350687dd80bbc7a5620e8fe71ad55c97eed2
- Global error now has proper styling
- Use key/value store vs array for channels/communities/messages in vuex store

### Deprecated

### Removed

### Fixed
- Bug where old loading/error dialogues would remain in state after app restart
- Pressing enter would make a new line in the editor
- Sending a message will now always correctly move to bottom of channel

### Security

---

## [0.1.3] - 19/06/2021

### Added
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "junto",
"version": "0.1.6",
"version": "0.1.7",
"private": true,
"description": "Junto ad4m chat application leveraging distributed & decentralized technologies",
"author": "josh@junto.foundation",
Expand All @@ -27,7 +27,7 @@
"@apollo/client": "^3.3.14",
"@junto-foundation/junto-elements": "0.0.13",
"@perspect3vism/ad4m": "0.0.6",
"@perspect3vism/ad4m-executor": "0.0.16",
"@perspect3vism/ad4m-executor": "0.0.17",
"@types/jest": "^26.0.20",
"@types/mocha": "^8.2.1",
"@vue/apollo-composable": "^4.0.0-alpha.12",
Expand Down
18 changes: 18 additions & 0 deletions scripts/clean-state.command
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
path="$HOME/.config/junto"
elif [[ "$OSTYPE" == "darwin"* ]]; then
path="$HOME/Library/Application Support/junto"
fi

echo "Will delete path: $path"
# read -p "IS THIS CORRECT? (y/n) " answer

# if [[ $answer =~ ^[Yy]$ ]] ;
# then
# echo "Accepted, deleting directory"
rm -rf $path
# else
# echo "Not deleting"
# fi
8 changes: 4 additions & 4 deletions src/containers/EditProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<j-input
size="lg"
label="Username"
@keydown.enter="updateUser"
@keydown.enter="updateProfile"
:value="userProfile?.username"
@input="(e) => (username = e.target.value)"
></j-input>
<div>
<j-button size="lg" @click="$emit('cancel')"> Cancel </j-button>
<j-button size="lg" variant="primary" @click="updateUser">
<j-button size="lg" variant="primary" @click="updateProfile">
Save
</j-button>
</div>
Expand Down Expand Up @@ -56,10 +56,10 @@ export default defineComponent({
},
},
methods: {
updateUser() {
updateProfile() {
this.isUpdatingProfile = true;
this.$store
.dispatch("updateUser", {
.dispatch("updateProfile", {
username: this.username,
profilePicture: this.profilePicture,
})
Expand Down
10 changes: 10 additions & 0 deletions src/core/graphql_queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ export const LANGUAGES = gql`
languages(filter: $filter) {
name
address
constructorIcon {
code
}
iconFor {
code
}
settings
settingsIcon {
code
}
}
}
`;
Expand Down
1 change: 1 addition & 0 deletions src/core/methods/getTypedExpressionLangs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export async function getTypedExpressionLanguages<S>(
languageAddress: lang!,
createIcon: languageRes.constructorIcon!.code!,
viewIcon: languageRes.iconFor!.code!,
name: languageRes.name!,
};
store!.commit({
type: "addExpressionUI",
Expand Down
18 changes: 18 additions & 0 deletions src/core/queries/getLanguages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { apolloClient } from "@/main";
import { LANGUAGES } from "../graphql_queries";
import ad4m from "@perspect3vism/ad4m-executor";

export async function getLanguages(): Promise<ad4m.Language[]> {
return new Promise((resolve, reject) => {
apolloClient
.query<{ languages: ad4m.Language[] }>({
query: LANGUAGES,
})
.then((result) => {
resolve(result.data!.languages);
})
.catch((error) => {
reject(error);
});
});
}
1 change: 1 addition & 0 deletions src/store/actions/createCommunity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export default async (
languageAddress: lang,
createIcon: languageRes.constructorIcon!.code!,
viewIcon: languageRes.iconFor!.code!,
name: languageRes.name!,
};
commit("addExpressionUI", uiData);
await sleep(40);
Expand Down
4 changes: 4 additions & 0 deletions src/store/actions/getCommunityMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getLinks } from "@/core/queries/getLinks";
import { Commit } from "vuex";
import { ExpressionTypes, State } from "..";
import type Expression from "@perspect3vism/ad4m/Expression";
import { TimeoutCache } from "../../utils/timeoutCache";

export interface Context {
commit: Commit;
Expand All @@ -18,6 +19,7 @@ export default async function (
{ communityId }: Payload
): Promise<void> {
const profiles: { [x: string]: Expression } = {};
const cache = new TimeoutCache<Expression>(1000 * 60 * 5);

try {
const communities = state.communities;
Expand All @@ -39,13 +41,15 @@ export default async function (
const did = `${profileLang.languageAddress}://${profileLink.author!
.did!}`;

//TODO: we should store the whole profile in the store but just the did and then resolve the profile via cache/network
const profile = await getProfile(
profileLang.languageAddress,
profileLink.author!.did!
);

if (profile) {
profiles[did] = Object.assign({}, profile);
cache.set(did, profile);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/store/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import logIn from "./logIn";
import getPerspectiveChannelsAndMetadata from "./getPerspectiveChannelsAndMetadata";
import loadExpressionLanguages from "./loadExpressionLanguages";
import updateCommunity from "./updateCommunity";
import updateUser from "./updateUser";
import updateProfile from "./updateProfile";
import getCommunityMembers from "./getCommunityMembers";
import loadExpressions from "./loadExpressions";
import createExpression from "./createExpression";
Expand All @@ -20,7 +20,7 @@ export default {
getPerspectiveChannelsAndMetadata,
loadExpressionLanguages,
updateCommunity,
updateUser,
updateProfile,
getCommunityMembers,
loadExpressions,
createExpression,
Expand Down
26 changes: 13 additions & 13 deletions src/store/actions/loadExpressionLanguages.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Commit } from "vuex";

import { ExpressionUIIcons } from "@/store";
import { getLanguage } from "@/core/queries/getLanguage";
import { getLanguages } from "@/core/queries/getLanguages";

export interface Context {
commit: Commit;
Expand All @@ -14,18 +14,18 @@ export interface Payload {

export default async ({ commit, getters }: Context): Promise<void> => {
try {
const expressionLangs = getters.getAllExpressionLanguagesNotLoaded;
// console.log({ expressionLangs });
for (const [, lang] of expressionLangs.entries()) {
const language = await getLanguage(lang);
console.log("Got language", language);
if (language !== null) {
const uiData: ExpressionUIIcons = {
languageAddress: language!.address!,
createIcon: language!.constructorIcon!.code!,
viewIcon: language!.iconFor!.code!,
};
commit("addExpressionUI", uiData);
const languages = await getLanguages();
for (const language of languages) {
if (language.iconFor) {
if (!getters.getLanguageUI(language.address!)) {
const uiData: ExpressionUIIcons = {
languageAddress: language!.address!,
createIcon: language!.constructorIcon!.code!,
viewIcon: language!.iconFor!.code!,
name: language!.name!,
};
commit("addExpressionUI", uiData);
}
}
}
} catch (e) {
Expand Down
77 changes: 77 additions & 0 deletions src/store/actions/updateProfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { createProfile } from "@/core/methods/createProfile";
import { Commit } from "vuex";
import { ExpressionTypes, State, Profile } from "..";
import { TimeoutCache } from "../../utils/timeoutCache";
import type Expression from "@perspect3vism/ad4m/Expression";
import { getExpression } from "@/core/queries/getExpression";

export interface Context {
commit: Commit;
state: State;
}

export interface Payload {
username: string;
profilePicture: string;
thumbnail: string;
}

export default async (
{ commit, state }: Context,
payload: Payload
): Promise<any> => {
commit("setUserProfile", payload);

try {
const user: Profile | null = state.userProfile;

const communities = Object.values(state.communities);
const cache = new TimeoutCache<Expression>(1000 * 60 * 5);

for (const community of communities) {
const profileExpression = community.typedExpressionLanguages.find(
(t) => t.expressionType == ExpressionTypes.ProfileExpression
);
const didExpression = `${
profileExpression!.languageAddress
}://${state.userDid!}`;

console.log("profileExpression: ", profileExpression);

if (profileExpression) {
const exp = await createProfile(
profileExpression.languageAddress,
payload.username,
user!.email,
user!.givenName,
user!.familyName,
payload.profilePicture,
payload.thumbnail
);

console.log("Created new profileExpression: ", exp);

const expressionGql = await getExpression(exp);
const profileExp = {
author: expressionGql.author!,
data: JSON.parse(expressionGql.data!),
timestamp: expressionGql.timestamp!,
proof: expressionGql.proof!,
} as Expression;
cache.set(didExpression, profileExp);
} else {
const errorMessage =
"Expected to find profile expression language for this community";
commit("showDangerToast", {
message: errorMessage,
});
throw Error(errorMessage);
}
}
} catch (e) {
commit("showDangerToast", {
message: e.message,
});
throw new Error(e);
}
};
14 changes: 0 additions & 14 deletions src/store/actions/updateUser.ts

This file was deleted.

Loading

0 comments on commit 7f2fc29

Please sign in to comment.