Remove redundant get_account_data

This commit is contained in:
nexy7574 2025-01-19 22:31:08 +00:00
parent 6f177e0524
commit f802108944
No known key found for this signature in database
2 changed files with 5 additions and 25 deletions

View file

@ -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"`

View file

@ -40,17 +40,11 @@ interface IgnoredUsersType {
const UserIgnoreButton = ({ userID, client }: { userID: string; client: Client }) => {
const [ignoredUsers, setIgnoredUsers] = useState<IgnoredUsersType | null>(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 = () => {