Skip to content

Commit

Permalink
84769cc
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 16, 2024
1 parent 82e6698 commit 9c59d91
Show file tree
Hide file tree
Showing 58 changed files with 1,105 additions and 754 deletions.
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Changelog for Weavy

## v19.1.0

<time>2024-01-16</time>

* Fixed issue with searching for unread conversations.
* Fixed error where Webhook delivery listing did not include all deliveries.
* Fixed an issue with the data not being updated properly in uikit-web when focusing the window or getting online.
* Fixed some styling issues with avatars.
* Fixed some issues with events in uikit-web. The incorrect Messenger events `reaction_added`, `reaction_removed` and `app_updated` was removed while `app_created` and `member_added` was added.

## v19.0.6

<time>2024-01-05</time>

* uikit-react compatibility now includes ES5, Webpack 4 and react-scripts v4.
* Fixed avatar alignment in uikit-web.

## v19.0.5

Expand Down
468 changes: 255 additions & 213 deletions package-lock.json

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@weavy/uikit-web",
"version": "19.0.6",
"version": "19.1.0",
"author": "Weavy",
"description": "Web components UI-kit for Weavy",
"homepage": "https://github.com/weavy/weavy-uikit-web",
Expand Down Expand Up @@ -36,53 +36,53 @@
"weavy": "./cli/weavy-cli.mjs"
},
"dependencies": {
"@codemirror/autocomplete": "^6.11.1",
"@codemirror/commands": "^6.3.2",
"@codemirror/lang-markdown": "^6.2.3",
"@codemirror/language": "^6.9.3",
"@codemirror/autocomplete": "^6.12.0",
"@codemirror/commands": "^6.3.3",
"@codemirror/lang-markdown": "^6.2.4",
"@codemirror/language": "^6.10.0",
"@codemirror/language-data": "^6.3.1",
"@codemirror/state": "^6.3.3",
"@codemirror/view": "^6.22.2",
"@codemirror/state": "^6.4.0",
"@codemirror/view": "^6.23.0",
"@lit/context": "^1.1.0",
"@lit/localize": "^0.12.1",
"@material/material-color-utilities": "^0.2.7",
"@mdi/js": "^7.3.67",
"@mdi/js": "^7.4.47",
"@microsoft/signalr": "^7.0.14",
"@popperjs/core": "^2.11.8",
"@tanstack/query-core": "^5.13.4",
"@tanstack/query-persist-client-core": "^5.13.4",
"@tanstack/query-sync-storage-persister": "^5.13.4",
"lit": "^3.1.0",
"@tanstack/query-core": "^5.17.10",
"@tanstack/query-persist-client-core": "^5.17.11",
"@tanstack/query-sync-storage-persister": "^5.17.11",
"lit": "^3.1.1",
"lit-modal-portal": "^0.4.1",
"lodash.throttle": "^4.1.1",
"pdfjs-dist": "^3.11.174"
},
"devDependencies": {
"@lit/localize-tools": "^0.7.1",
"@open-wc/testing": "^4.0.0",
"@tanstack/eslint-plugin-query": "^5.12.1",
"@tanstack/query-devtools": "^5.13.5",
"@tanstack/eslint-plugin-query": "^5.17.7",
"@tanstack/query-devtools": "^5.17.7",
"@types/lodash.throttle": "^4.1.9",
"@types/mocha": "^10.0.6",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"@web/dev-server-esbuild": "^1.0.1",
"@web/test-runner": "^0.18.0",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"esbuild": "^0.19.9",
"esbuild-sass-plugin": "^2.16.0",
"esbuild": "^0.19.11",
"esbuild-sass-plugin": "^2.16.1",
"esbuild-server": "^0.3.0",
"eslint": "^8.56.0",
"eslint-plugin-lit": "^1.11.0",
"eslint-plugin-lit-a11y": "^4.1.1",
"eslint-plugin-wc": "^2.0.4",
"express": "^4.18.2",
"lit-analyzer": "^2.0.2",
"lit-analyzer": "^2.0.3",
"node-fetch": "^3.3.2",
"npm-run-all": "^4.1.5",
"rimraf": "^5.0.5",
"ts-lit-plugin": "^2.0.1",
"ts-lit-plugin": "^2.0.2",
"typescript": "^5.3.3",
"web-component-analyzer": "^2.0.0"
}
Expand Down
84 changes: 52 additions & 32 deletions src/client/weavy-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { assign } from "../utils/objects";
import { defaultFetchSettings } from "../utils/data";
import { WyContextProvider as ContextProvider } from "../utils/context-provider";
import { globalContextProvider, weavyContextDefinition } from "./context-definition";
import { defer } from "../utils/dom";
import { defer, observeConnected } from "../utils/dom";
import { chrome } from "../utils/browser";
import { RealtimeDataType, RealtimeEventType } from "../types/realtime.types";
import { ConnectionState, NetworkState, NetworkStatus } from "../types/server.types";
Expand Down Expand Up @@ -217,7 +217,7 @@ export class WeavyContext implements WeavyOptions {
storage: window.sessionStorage,
throttleTime: this.staleTime,
});

// TODO: Move to "modern" persistQueryClient?
const persistQueryClientOptions = {
queryClient: this.#queryClient,
Expand All @@ -235,11 +235,10 @@ export class WeavyContext implements WeavyOptions {

await persistQueryClientRestore(persistQueryClientOptions);
this.#unsubscribeQueryClient = persistQueryClientSubscribe(persistQueryClientOptions);
} catch(e) {
} catch (e) {
console.warn("Query cache persister not available.");
}


//console.log("Query cache restored from session", this.#queryClient.getMutationCache())
}

Expand All @@ -253,7 +252,8 @@ export class WeavyContext implements WeavyOptions {
// RTM CONNECTION

#connection?: HubConnection;
#groups: string[] = [];
#connectionEventListeners: Array<{ name: string; callback: Function }> = [];

private signalRAccessTokenRefresh = false;

#whenConnectionStartedResolve?: (value: unknown) => void;
Expand Down Expand Up @@ -330,8 +330,8 @@ export class WeavyContext implements WeavyOptions {
console.info("SignalR reconnected.");
this.connectionState = "connected";
this.networkStateIsPending = false;
for (let i = 0; i < this.#groups.length; i++) {
this.#connection?.invoke("Subscribe", this.#groups[i]);
for (let i = 0; i < this.#connectionEventListeners.length; i++) {
this.#connection?.invoke("Subscribe", this.#connectionEventListeners[i].name);
}
});
this.connect();
Expand Down Expand Up @@ -402,54 +402,61 @@ export class WeavyContext implements WeavyOptions {
}
}

async subscribe<T extends (RealtimeEventType | RealtimeDataType)>(
async subscribe<T extends RealtimeEventType | RealtimeDataType>(
group: string | null,
event: string,
callback: (realTimeEvent: T) => void
) {
await this.whenConnectionStarted();

try {
if (!this.#connection) {
throw new Error("Connection not created");
}

const name = group ? group + ":" + event : event;

if (this.#connectionEventListeners.some((el) => el.name === name && el.callback === callback)) {
throw new Error("Duplicate subscribe: " + name);
}

this.#connectionEventListeners.push({ name, callback });
this.#connection.on(name, callback);

//console.log("Subscribing", name);
await this.whenConnectionStarted();
await this.#connection.invoke("Subscribe", name);
this.#groups.push(name);
this.#connection.on(name, callback);
} catch (err: unknown) {
console.warn("Error in Subscribe:", err);
console.error("Error in Subscribe:", err);
}
}

async unsubscribe<T extends (RealtimeEventType | RealtimeDataType)>(
async unsubscribe<T extends RealtimeEventType | RealtimeDataType>(
group: string | null,
event: string,
callback: (realTimeEvent: T) => void
) {
await this.whenConnectionStarted();
const name = group ? group + ":" + event : event;
try {
if (!this.#connection) {
throw new Error("Connection not created");
}

const name = group ? group + ":" + event : event;

// get first occurrence of group name and remove it
const index = this.#connectionEventListeners.findIndex((el) => el.name === name && el.callback === callback);
if (index !== -1) {
this.#connectionEventListeners.splice(index, 1);

this.#connection?.off(name, callback);

// get first occurrence of group name and remove it
const index = this.#groups.findIndex((e) => e === name);
if (index !== -1) {
this.#groups.splice(index, 1);
try {
if (!this.#connection) {
throw new Error("Connection not created");
}
// if no more groups, remove from server
if (!this.#groups.find((e) => e === name)) {
if (!this.#connectionEventListeners.some((el) => el.name === name)) {
await this.whenConnectionStarted();
await this.#connection.invoke("Unsubscribe", name);
}
} catch (err: unknown) {
console.warn("Error in Unsubscribe:", err);
}
} catch (err: unknown) {
console.warn("Error in Unsubscribe:", err);
}

this.#connection?.off(name, callback);
}

// NETWORK
Expand Down Expand Up @@ -612,9 +619,9 @@ export class WeavyContext implements WeavyOptions {
this.createQueryClient();

this.whenUrlAndTokenFactory().then(() => {
console.log("Weavy url and tokenFactory configured.")
console.log("Weavy url and tokenFactory configured.");
this.createConnection();
})
});

// Root node for modal portal

Expand All @@ -625,7 +632,20 @@ export class WeavyContext implements WeavyOptions {
globalContextProvider.setValue(this);
}

adoptGlobalStyles([colorModes])
if (this.host.isConnected) {
this.#queryClient.mount();
}

observeConnected(this.host, (isConnected) => {
if (isConnected) {
console.log("Query client mounted");
this.#queryClient.mount();
} else {
this.#queryClient.unmount();
}
});

adoptGlobalStyles([colorModes]);

defer(() => {
if (document) {
Expand Down
26 changes: 7 additions & 19 deletions src/components/wy-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,18 @@ export default class WyBadge extends LitElement {
badgeQuery = new QueryController<BadgeType>(this);

private handleBadgeRefresh = () => {
setTimeout(() => this.badgeQuery.result.refetch(), 500);
setTimeout(() => {
if (!this.badgeQuery.result.isRefetching) {
this.badgeQuery.result.refetch();
}
}, 500);
};

/**
* Event: New message created.
* @event wy:message_created
*/
realtimeMessageCreatedEvent = (realtimeEvent: RealtimeMessageEventType) =>
new CustomEvent("wy:message_created", { bubbles: true, composed: false, detail: realtimeEvent });

/**
* Event: Message seen-by status updated.
* @event wy:conversation_marked
*/
realtimeConversationMarkedEvent = (realtimeEvent: RealtimeConversationMarkedEventType) =>
new CustomEvent("wy:conversation_marked", { bubbles: true, composed: false, detail: realtimeEvent });

handleRealtimeMessage = (realtimeEvent: RealtimeMessageEventType) => {
handleRealtimeMessage = (_realtimeEvent: RealtimeMessageEventType) => {
this.handleBadgeRefresh();
this.dispatchEvent(this.realtimeMessageCreatedEvent(realtimeEvent));
};
handleRealtimeSeenBy = (realtimeEvent: RealtimeConversationMarkedEventType) => {
handleRealtimeSeenBy = (_realtimeEvent: RealtimeConversationMarkedEventType) => {
this.handleBadgeRefresh();
this.dispatchEvent(this.realtimeConversationMarkedEvent(realtimeEvent));
};

override async updated(changedProperties: PropertyValues<this & WeavyContextProps>) {
Expand Down
10 changes: 7 additions & 3 deletions src/components/wy-conversation-list-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "./wy-button";
import "./wy-dropdown";
import { RealtimeConversationMarkedEventType, RealtimeMessageEventType } from "../types/realtime.types";
import { WeavyContextProps } from "../types/weavy.types";
import { clickOnEnterAndConsumeOnSpace, clickOnSpace } from "src/utils/keyboard";

@customElement("wy-conversation-list-item")
@localized()
Expand Down Expand Up @@ -74,11 +75,11 @@ export default class WyConversationListItem extends LitElement {
this.dispatchRefetch();
};

private handleConversationUpdated = () => {
private handleConversationUpdated = () => {
this.dispatchRefetch();
};

private handleConversationMarked = (realtimeEvent: RealtimeConversationMarkedEventType) => {
private handleConversationMarked = (realtimeEvent: RealtimeConversationMarkedEventType) => {
if (realtimeEvent.actor.id === this.user!.id) {
this.dispatchRefetch();
}
Expand Down Expand Up @@ -132,7 +133,7 @@ export default class WyConversationListItem extends LitElement {
override willUpdate(changedProperties: PropertyValues<this & WeavyContextProps>) {
if (changedProperties.has("weavyContext") && this.weavyContext) {
this.deliveredConversationMutation = getDeliveredConversationMutation(this.weavyContext);

// realtime
this.weavyContext.subscribe(`a${this.conversationId}`, "app_updated", this.handleConversationUpdated);
this.weavyContext.subscribe(`a${this.conversationId}`, "member_added", this.handleConversationUpdated);
Expand Down Expand Up @@ -169,7 +170,10 @@ export default class WyConversationListItem extends LitElement {
"wy-unread": this.unread,
"wy-active": this.selected,
})}
tabindex="0"
@click=${(e: Event) => this.dispatchSelected(e, this.conversationId)}
@keydown=${clickOnEnterAndConsumeOnSpace}
@keyup=${clickOnSpace}
>
${this.room && this.user
? html`
Expand Down
2 changes: 1 addition & 1 deletion src/components/wy-conversation-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export default class WeavyConversationList extends LitElement {
<div ${ref(this.pagerRef)} class="wy-pager"></div>
</div>
`
: html`<wy-empty><wy-spinner overlay></wy-spinner></wy-empty>`}
: html`<wy-empty class="wy-pane"><wy-spinner overlay></wy-spinner></wy-empty>`}
`;
}

Expand Down
Loading

0 comments on commit 9c59d91

Please sign in to comment.