From f802108944d200626b564b53be5b8c77dd388764 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Sun, 19 Jan 2025 22:31:08 +0000 Subject: [PATCH] Remove redundant get_account_data --- pkg/hicli/json-commands.go | 14 -------------- web/src/ui/rightpanel/UserModeration.tsx | 16 +++++----------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/pkg/hicli/json-commands.go b/pkg/hicli/json-commands.go index 1fa09a7..dca1ea7 100644 --- a/pkg/hicli/json-commands.go +++ b/pkg/hicli/json-commands.go @@ -66,15 +66,6 @@ func (h *HiClient) handleJSONCommand(ctx context.Context, req *JSONCommand) (any return unmarshalAndCall(req.Data, func(params *sendStateEventParams) (id.EventID, error) { return h.SetState(ctx, params.RoomID, params.EventType, params.StateKey, params.Content) }) - case "get_account_data": - return unmarshalAndCall(req.Data, func(params *getAccountDataParams) (*map[string]any, error) { - var result map[string]any - if params.RoomID != "" { - return &result, h.Client.GetRoomAccountData(ctx, params.RoomID, params.Type, &result) - } else { - return &result, h.Client.GetAccountData(ctx, params.Type, &result) - } - }) case "set_account_data": return unmarshalAndCall(req.Data, func(params *setAccountDataParams) (bool, error) { if params.RoomID != "" { @@ -271,11 +262,6 @@ type sendStateEventParams struct { Content json.RawMessage `json:"content"` } -type getAccountDataParams struct { - RoomID id.RoomID `json:"room_id,omitempty"` - Type string `json:"type"` -} - type setAccountDataParams struct { RoomID id.RoomID `json:"room_id,omitempty"` Type string `json:"type"` diff --git a/web/src/ui/rightpanel/UserModeration.tsx b/web/src/ui/rightpanel/UserModeration.tsx index 5ff9d05..cc48681 100644 --- a/web/src/ui/rightpanel/UserModeration.tsx +++ b/web/src/ui/rightpanel/UserModeration.tsx @@ -40,17 +40,11 @@ interface IgnoredUsersType { const UserIgnoreButton = ({ userID, client }: { userID: string; client: Client }) => { const [ignoredUsers, setIgnoredUsers] = useState(null) useEffect(() => { - // Get blocked user list - client.rpc.getAccountData("m.ignored_user_list").then((data) => { - const parsedData = data as IgnoredUsersType - if (data !== ignoredUsers || !("ignored_users" in parsedData)) { - return - } - setIgnoredUsers(parsedData) - }).catch((e) => { - console.error("Failed to get ignored users", e) - }) - }) + const data = client.store.accountData.get("m.ignored_user_list") + if (data) { + setIgnoredUsers(data as IgnoredUsersType) + } + }, [client.store.accountData]) const isIgnored = ignoredUsers?.ignored_users[userID] const ignoreUser = () => {