Skip to content

Commit 48ee5f8

Browse files
committed
compose: Implement mention, for mention syntax
1 parent 6913bba commit 48ee5f8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/model/compose.dart

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:math';
22

3+
import '../api/model/model.dart';
34
import '../api/model/narrow.dart';
45
import 'narrow.dart';
56
import 'store.dart';
@@ -175,3 +176,9 @@ Uri narrowLink(PerAccountStore store, Narrow narrow, {int? nearMessageId}) {
175176

176177
return store.account.realmUrl.replace(fragment: fragment.toString());
177178
}
179+
180+
// TODO like web, use just the name, no ID, when that wouldn't be ambiguous.
181+
// It looks nicer while the user's still composing and looking at the source.
182+
String mention(User user, {bool silent = false}) {
183+
return '@${silent ? '_' : ''}**${user.fullName}|${user.userId}**';
184+
}

test/model/compose_test.dart

+6
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,10 @@ hello
300300
// TODO other Narrow subclasses as we add them:
301301
// starred, mentioned; searches; arbitrary
302302
});
303+
304+
test('mention', () {
305+
final user = eg.user(userId: 123, fullName: 'Full Name');
306+
check(mention(user, silent: false)).equals('@**Full Name|123**');
307+
check(mention(user, silent: true)).equals('@_**Full Name|123**');
308+
});
303309
}

0 commit comments

Comments
 (0)