mirror of
https://github.com/spacebarchat/client.git
synced 2024-11-22 02:12:38 +01:00
user update event
This commit is contained in:
parent
3c098ea441
commit
f7fee83cce
@ -32,6 +32,7 @@ import {
|
|||||||
GatewayReceivePayload,
|
GatewayReceivePayload,
|
||||||
GatewaySendPayload,
|
GatewaySendPayload,
|
||||||
GatewayTypingStartDispatchData,
|
GatewayTypingStartDispatchData,
|
||||||
|
GatewayUserUpdateDispatchData,
|
||||||
PresenceUpdateStatus,
|
PresenceUpdateStatus,
|
||||||
Snowflake,
|
Snowflake,
|
||||||
} from "@spacebarchat/spacebar-api-types/v9";
|
} from "@spacebarchat/spacebar-api-types/v9";
|
||||||
@ -151,6 +152,8 @@ export default class GatewayConnectionStore {
|
|||||||
this.dispatchHandlers.set(GatewayDispatchEvents.PresenceUpdate, this.onPresenceUpdate);
|
this.dispatchHandlers.set(GatewayDispatchEvents.PresenceUpdate, this.onPresenceUpdate);
|
||||||
|
|
||||||
this.dispatchHandlers.set(GatewayDispatchEvents.TypingStart, this.onTypingStart);
|
this.dispatchHandlers.set(GatewayDispatchEvents.TypingStart, this.onTypingStart);
|
||||||
|
|
||||||
|
this.dispatchHandlers.set(GatewayDispatchEvents.UserUpdate, this.onUserUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onopen = () => {
|
private onopen = () => {
|
||||||
@ -721,4 +724,8 @@ export default class GatewayConnectionStore {
|
|||||||
channel.typingIds.get(data.user_id)?.();
|
channel.typingIds.get(data.user_id)?.();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onUserUpdate = (data: GatewayUserUpdateDispatchData) => {
|
||||||
|
this.app.users.update(data);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
import { Routes, type APIUser, type Snowflake } from "@spacebarchat/spacebar-api-types/v9";
|
import {
|
||||||
|
GatewayUserUpdateDispatchData,
|
||||||
|
Routes,
|
||||||
|
type APIUser,
|
||||||
|
type Snowflake,
|
||||||
|
} from "@spacebarchat/spacebar-api-types/v9";
|
||||||
import { ObservableMap, action, computed, observable } from "mobx";
|
import { ObservableMap, action, computed, observable } from "mobx";
|
||||||
import useLogger from "../hooks/useLogger";
|
import useLogger from "../hooks/useLogger";
|
||||||
import AppStore from "./AppStore";
|
import AppStore from "./AppStore";
|
||||||
@ -22,6 +27,11 @@ export default class UserStore {
|
|||||||
users.forEach((user) => this.add(user));
|
users.forEach((user) => this.add(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
update(user: APIUser | GatewayUserUpdateDispatchData) {
|
||||||
|
this.users.get(user.id)?.update(user);
|
||||||
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
get(id: string) {
|
get(id: string) {
|
||||||
return this.users.get(id);
|
return this.users.get(id);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Snowflake } from "@spacebarchat/spacebar-api-types/globals";
|
import { Snowflake } from "@spacebarchat/spacebar-api-types/globals";
|
||||||
import type { APIUser, PublicUser } from "@spacebarchat/spacebar-api-types/v9";
|
import type { APIUser, GatewayUserUpdateDispatchData, PublicUser } from "@spacebarchat/spacebar-api-types/v9";
|
||||||
import { CDNRoutes, DefaultUserAvatarAssets, ImageFormat } from "@spacebarchat/spacebar-api-types/v9";
|
import { CDNRoutes, DefaultUserAvatarAssets, ImageFormat } from "@spacebarchat/spacebar-api-types/v9";
|
||||||
import { makeObservable, observable } from "mobx";
|
import { action, makeObservable, observable } from "mobx";
|
||||||
import REST from "../../utils/REST";
|
import REST from "../../utils/REST";
|
||||||
|
|
||||||
export default class User {
|
export default class User {
|
||||||
@ -48,6 +48,11 @@ export default class User {
|
|||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
update(member: APIUser | GatewayUserUpdateDispatchData) {
|
||||||
|
Object.assign(this, member);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the users default avatar url
|
* Gets the users default avatar url
|
||||||
* @returns The URL to the user's default avatar.
|
* @returns The URL to the user's default avatar.
|
||||||
|
Loading…
Reference in New Issue
Block a user