@@ -119,17 +119,18 @@ export const decodeHashComponent = (string: string): string => {
119
119
} ;
120
120
121
121
/**
122
- * Parse the operand of a `stream` operator, returning a stream name.
122
+ * Parse the operand of a `stream` operator, returning a stream ID and name.
123
123
*
124
124
* Return null if the operand doesn't match any known stream.
125
125
*/
126
- const parseStreamOperand = ( operand , streamsById , streamsByName ) : null | string => {
126
+ const parseStreamOperand = ( operand , streamsById , streamsByName ) : null | [ string , number ] = > {
127
127
// "New" (2018) format: ${stream_id}-${stream_name} .
128
128
const match = / ^ ( [ \d ] + ) (?: - .* ) ? $ / . exec ( operand ) ;
129
129
if ( match ) {
130
- const stream = streamsById . get ( parseInt ( match [ 1 ] , 10 ) ) ;
130
+ const streamId = parseInt ( match [ 1 ] , 10 ) ;
131
+ const stream = streamsById . get ( streamId ) ;
131
132
if ( stream ) {
132
- return stream . name ;
133
+ return [ stream . name , streamId ] ;
133
134
}
134
135
}
135
136
@@ -138,7 +139,7 @@ const parseStreamOperand = (operand, streamsById, streamsByName): null | string
138
139
const streamName = decodeHashComponent ( operand ) ;
139
140
const stream = streamsByName . get ( streamName ) ;
140
141
if ( stream ) {
141
- return streamName ;
142
+ return [ streamName , stream . stream_id ] ;
142
143
}
143
144
144
145
return null ;
@@ -181,12 +182,12 @@ export const getNarrowFromLink = (
181
182
return pmNarrowFromRecipients ( pmKeyRecipientsFromIds ( ids , ownUserId ) ) ;
182
183
}
183
184
case 'topic' : {
184
- const streamName = parseStreamOperand ( paths [ 1 ] , streamsById , streamsByName ) ;
185
- return streamName == null ? null : topicNarrow ( streamName , parseTopicOperand ( paths [ 3 ] ) ) ;
185
+ const streamNameAndId = parseStreamOperand ( paths [ 1 ] , streamsById , streamsByName ) ;
186
+ return streamNameAndId && topicNarrow ( streamNameAndId [ 0 ] , parseTopicOperand ( paths [ 3 ] ) ) ;
186
187
}
187
188
case 'stream' : {
188
- const streamName = parseStreamOperand ( paths [ 1 ] , streamsById , streamsByName ) ;
189
- return streamName == null ? null : streamNarrow ( streamName ) ;
189
+ const streamNameAndId = parseStreamOperand ( paths [ 1 ] , streamsById , streamsByName ) ;
190
+ return streamNameAndId && streamNarrow ( streamNameAndId [ 0 ] ) ;
190
191
}
191
192
case 'special' :
192
193
try {
0 commit comments