Page MenuHomePhabricator

[keyserver/lib] Set up responders, endpoints, and related functions to fetch all pinned messages
ClosedPublic

Authored by rohan on Mar 20 2023, 7:02 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 2:55 AM
Unknown Object (File)
Sun, Nov 24, 2:42 AM
Unknown Object (File)
Sun, Nov 24, 1:58 AM
Unknown Object (File)
Sun, Nov 24, 1:51 AM
Unknown Object (File)
Sun, Nov 24, 1:41 AM
Unknown Object (File)
Sun, Nov 24, 1:40 AM
Unknown Object (File)
Sun, Nov 24, 1:37 AM
Unknown Object (File)
Sun, Nov 10, 9:05 PM
Subscribers

Details

Summary

Following D7110, this diff handles introducing the necessary endpoint and responders to call the query.

Depends on D7110

Linear: https://linear.app/comm/issue/ENG-3189/set-up-responders-endpoints-and-related-functions-to-fetch-all-pinned

Test Plan

Ran the following code to test, and confirmed output in my console (only including the relevant testing code).

import { fetchPinnedMessages } from 'lib/actions/message-actions.js';

const callFetchPinnedMessages = useServerCall(fetchPinnedMessages);

React.useEffect(() => {
  const getPins = async () => {
    const pins = await callFetchPinnedMessages({ threadID });
    console.log(pins);
  };
  getPins();
}, [...]);

Screenshot 2023-03-20 at 9.37.57 PM.png (1×1 px, 186 KB)

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

rohan requested review of this revision.Mar 20 2023, 7:18 PM
tomek requested changes to this revision.Mar 23 2023, 2:58 AM
tomek added inline comments.
lib/actions/message-actions.js
253 ↗(On Diff #23908)

Why it is optional? We're always returning a new object from this function.
On the other hand, server declares a response as optional, but here we're accessing a property pinnedMessages of the response without checking if it was returned. Have you tested if this function works correctly when there are no pins?

A better approach would be to make the response mandatory and return e.g. an empty array if there are no pins.

This revision now requires changes to proceed.Mar 23 2023, 2:58 AM

Make response FetchPinnedMessagesResult mandatory

This revision is now accepted and ready to land.Mar 24 2023, 8:20 AM