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,
|
||||
GatewaySendPayload,
|
||||
GatewayTypingStartDispatchData,
|
||||
GatewayUserUpdateDispatchData,
|
||||
PresenceUpdateStatus,
|
||||
Snowflake,
|
||||
} 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.TypingStart, this.onTypingStart);
|
||||
|
||||
this.dispatchHandlers.set(GatewayDispatchEvents.UserUpdate, this.onUserUpdate);
|
||||
}
|
||||
|
||||
private onopen = () => {
|
||||
@ -721,4 +724,8 @@ export default class GatewayConnectionStore {
|
||||
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 useLogger from "../hooks/useLogger";
|
||||
import AppStore from "./AppStore";
|
||||
@ -22,6 +27,11 @@ export default class UserStore {
|
||||
users.forEach((user) => this.add(user));
|
||||
}
|
||||
|
||||
@action
|
||||
update(user: APIUser | GatewayUserUpdateDispatchData) {
|
||||
this.users.get(user.id)?.update(user);
|
||||
}
|
||||
|
||||
@action
|
||||
get(id: string) {
|
||||
return this.users.get(id);
|
||||
|
@ -1,7 +1,7 @@
|
||||
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 { makeObservable, observable } from "mobx";
|
||||
import { action, makeObservable, observable } from "mobx";
|
||||
import REST from "../../utils/REST";
|
||||
|
||||
export default class User {
|
||||
@ -48,6 +48,11 @@ export default class User {
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
@action
|
||||
update(member: APIUser | GatewayUserUpdateDispatchData) {
|
||||
Object.assign(this, member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the users default avatar url
|
||||
* @returns The URL to the user's default avatar.
|
||||
|
Loading…
Reference in New Issue
Block a user