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 unmarshalAndCall(req.Data, func(params *sendStateEventParams) (id.EventID, error) {
|
||||||
return h.SetState(ctx, params.RoomID, params.EventType, params.StateKey, params.Content)
|
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":
|
case "set_account_data":
|
||||||
return unmarshalAndCall(req.Data, func(params *setAccountDataParams) (bool, error) {
|
return unmarshalAndCall(req.Data, func(params *setAccountDataParams) (bool, error) {
|
||||||
if params.RoomID != "" {
|
if params.RoomID != "" {
|
||||||
|
@ -271,11 +262,6 @@ type sendStateEventParams struct {
|
||||||
Content json.RawMessage `json:"content"`
|
Content json.RawMessage `json:"content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type getAccountDataParams struct {
|
|
||||||
RoomID id.RoomID `json:"room_id,omitempty"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type setAccountDataParams struct {
|
type setAccountDataParams struct {
|
||||||
RoomID id.RoomID `json:"room_id,omitempty"`
|
RoomID id.RoomID `json:"room_id,omitempty"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
|
|
@ -40,17 +40,11 @@ interface IgnoredUsersType {
|
||||||
const UserIgnoreButton = ({ userID, client }: { userID: string; client: Client }) => {
|
const UserIgnoreButton = ({ userID, client }: { userID: string; client: Client }) => {
|
||||||
const [ignoredUsers, setIgnoredUsers] = useState<IgnoredUsersType | null>(null)
|
const [ignoredUsers, setIgnoredUsers] = useState<IgnoredUsersType | null>(null)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Get blocked user list
|
const data = client.store.accountData.get("m.ignored_user_list")
|
||||||
client.rpc.getAccountData("m.ignored_user_list").then((data) => {
|
if (data) {
|
||||||
const parsedData = data as IgnoredUsersType
|
setIgnoredUsers(data as IgnoredUsersType)
|
||||||
if (data !== ignoredUsers || !("ignored_users" in parsedData)) {
|
}
|
||||||
return
|
}, [client.store.accountData])
|
||||||
}
|
|
||||||
setIgnoredUsers(parsedData)
|
|
||||||
}).catch((e) => {
|
|
||||||
console.error("Failed to get ignored users", e)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
const isIgnored = ignoredUsers?.ignored_users[userID]
|
const isIgnored = ignoredUsers?.ignored_users[userID]
|
||||||
const ignoreUser = () => {
|
const ignoreUser = () => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue