Skip to content

Commit bea6fab

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

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/model/compose.dart

+5
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,7 @@ Uri narrowLink(PerAccountStore store, Narrow narrow, {int? nearMessageId}) {
175176

176177
return store.account.realmUrl.replace(fragment: fragment.toString());
177178
}
179+
180+
String mention(User user, {bool silent = false}) {
181+
return '@${silent ? '_' : ''}**${user.fullName}|${user.userId}**';
182+
}

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)