Skip to content

Commit 27ef1d9

Browse files
gnpricechrisbobbe
authored andcommitted
topic [nfc]: Fix internal references to "subject"
The bulk of the places we mention "subject" are direct references to either the property of that name on `Message` or somewhere else in the server API. Most of those, and in particular `Message#subject`, are still that way in the current API. Those will be an annoying giant conversion, so I have no desire to be in a rush to do them. In particular, for any given piece of API, I won't want to make a conversion before we've at least settled on the API change so that we can convert to what we know is the future API. However, there are a handful of places where we say "subject" to mean "topic" and it's entirely internal to the mobile app. So here we go ahead and fix those.
1 parent 3e0254f commit 27ef1d9

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/chat/ChatScreen.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,15 @@ export default function ChatScreen(props: Props): Node {
152152
(message: string, destinationNarrow: Narrow) => {
153153
if (editMessage) {
154154
const content = editMessage.content !== message ? message : undefined;
155-
const subject = caseNarrowDefault(
155+
const topic = caseNarrowDefault(
156156
destinationNarrow,
157+
// eslint-disable-next-line no-shadow
157158
{ topic: (streamId, topic) => (topic !== editMessage.topic ? topic : undefined) },
158159
() => undefined,
159160
);
160161

161-
if (
162-
(content !== undefined && content !== '')
163-
|| (subject !== undefined && subject !== '')
164-
) {
165-
api.updateMessage(auth, { content, subject }, editMessage.id).catch(error => {
162+
if ((content !== undefined && content !== '') || (topic !== undefined && topic !== '')) {
163+
api.updateMessage(auth, { content, subject: topic }, editMessage.id).catch(error => {
166164
showErrorAlert(_('Failed to edit message'), error.message);
167165
});
168166
}

src/message/__tests__/messagesReducer-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ describe('messagesReducer', () => {
321321
test('when event contains a new subject but no new content only subject is updated', () => {
322322
const message1Old = eg.streamMessage({
323323
content: 'Old content',
324-
subject: 'Old subject',
324+
subject: 'Old topic',
325325
last_edit_timestamp: 123,
326326
edit_history: [],
327327
});
@@ -344,11 +344,11 @@ describe('messagesReducer', () => {
344344
test('when event contains a new subject and a new content, update both', () => {
345345
const message1Old = eg.streamMessage({
346346
content: '<p>Old content</p>',
347-
subject: 'Old subject',
347+
subject: 'Old topic',
348348
last_edit_timestamp: 123,
349349
edit_history: [
350350
{
351-
prev_subject: 'Old subject',
351+
prev_subject: 'Old topic',
352352
timestamp: 123,
353353
user_id: eg.otherUser.user_id,
354354
},

src/webview/html/header.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from '../../utils/recipient';
2121
import { base64Utf8Encode } from '../../utils/encoding';
2222

23-
const renderSubject = message =>
23+
const renderTopic = message =>
2424
// TODO: pin down if '' happens, and what its proper semantics are.
2525
message.match_subject !== undefined && message.match_subject !== ''
2626
? message.match_subject
@@ -40,7 +40,7 @@ export default (
4040
if (message.type === 'stream') {
4141
const streamName = streamNameOfStreamMessage(message);
4242
const topicNarrowStr = keyFromNarrow(topicNarrow(message.stream_id, message.subject));
43-
const topicHtml = renderSubject(message);
43+
const topicHtml = renderTopic(message);
4444

4545
if (headerStyle === 'topic+date') {
4646
return template`\

0 commit comments

Comments
 (0)