mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 18:43:41 -05:00
Remove redundant get_account_data
This commit is contained in:
parent
6f177e0524
commit
f802108944
2 changed files with 5 additions and 25 deletions
|
@ -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"`
|
||||
|
|
|
@ -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
|
||||
const data = client.store.accountData.get("m.ignored_user_list")
|
||||
if (data) {
|
||||
setIgnoredUsers(data as IgnoredUsersType)
|
||||
}
|
||||
setIgnoredUsers(parsedData)
|
||||
}).catch((e) => {
|
||||
console.error("Failed to get ignored users", e)
|
||||
})
|
||||
})
|
||||
}, [client.store.accountData])
|
||||
|
||||
const isIgnored = ignoredUsers?.ignored_users[userID]
|
||||
const ignoreUser = () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue