Skip to content

Commit

Permalink
Merge pull request #14 from ecency/nt/wave-tags
Browse files Browse the repository at this point in the history
Nt/wave tags
  • Loading branch information
feruzm authored Oct 30, 2024
2 parents c0b8935 + 4c10807 commit 21e9e73
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 21 deletions.
23 changes: 16 additions & 7 deletions android/app/src/main/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
parentPermlink,
permlink,
comment,
tags,
postingKey,
token,
authKey
Expand All @@ -223,6 +224,20 @@
// .toLowerCase();
// permlink2 = `re-${username}-${permlink2}`;
// console.log(permlink2);



// // Regex pattern for hashtags
// const pattern = /#(\w+)/g;
// // Find all hashtags and discard the # character
// const hashtags = [];
// let match;

// while ((match = pattern.exec(description)) !== null) {
// hashtags.push(match[1]); // match[1] contains the hashtag without the #
// }


let op = [
"comment",
{
Expand All @@ -233,13 +248,7 @@
title: "",
body: description,
json_metadata: JSON.stringify({
tags: [
"hive-125125",
"waves",
"ecency",
"mobile",
"thread"
],
tags:JSON.parse(tags),
app: "ecency-waves",
format: "markdown+html",
}),
Expand Down
3 changes: 2 additions & 1 deletion android/app/src/main/kotlin/com/ecency/waves/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class MainActivity: FlutterActivity() {
val weight = call.argument<Int?>("weight")
val pollId = call.argument<String?>("pollId")
val choices = call.argument<IntArray?>("choices")
val tags = call.argument<StringArray?>("tags")

if (id == null) {
result.error(
Expand Down Expand Up @@ -91,7 +92,7 @@ class MainActivity: FlutterActivity() {
&& parentPermlink != null && permlink != null && comment != null && postingKey != null && token != null
&& authKey != null ) {
webView?.evaluateJavascript(
"commentOnContent('$id','$username', '$author', '$parentPermlink', '$permlink', '$comment', '$postingKey', '$token', '$authKey');",
"commentOnContent('$id','$username', '$author', '$parentPermlink', '$permlink', '$comment', '$tags', '$postingKey', '$token', '$authKey');",
null
)
} else if (call.method == "voteContent" && username != null && author != null
Expand Down
4 changes: 3 additions & 1 deletion ios/Runner/AppBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,18 @@ class AppBridge: NSObject {
let parentPermlink = arguments ["parentPermlink"] as? String,
let permlink = arguments ["permlink"] as? String,
let comment = arguments ["comment"] as? String,
let tags = arguments ["tags"] as? [String],
let postingKey = arguments ["postingKey"] as? String,
let token = arguments ["token"] as? String,
let authKey = arguments ["authKey"] as? String

else {
debugPrint("username, author, parentPermlink, permlink, comment, postingKey, token, authKey - are note set")
return result(FlutterMethodNotImplemented)
}
webVC.runThisJS(
id: id,
jsCode: "commentOnContent('\(id)','\(username)', '\(author)', '\(parentPermlink)', '\(permlink)', '\(comment)', '\(postingKey)', '\(token)', '\(authKey)');"
jsCode: "commentOnContent('\(id)','\(username)', '\(author)', '\(parentPermlink)', '\(permlink)', '\(comment)', '\(tags)', '\(postingKey)', '\(token)', '\(authKey)');"
) { text in result(text) }
case "voteContent":
guard
Expand Down
12 changes: 4 additions & 8 deletions ios/Runner/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
parentPermlink,
permlink,
comment,
tags,
postingKey,
token,
authKey
Expand All @@ -201,7 +202,8 @@
// .replace(/[^a-zA-Z0-9]+/g, "")
// .toLowerCase();
// permlink2 = `re-${username}-${permlink2}`;
// console.log(permlink2);
// console.log(permlink2)

let op = [
"comment",
{
Expand All @@ -212,13 +214,7 @@
title: "",
body: description,
json_metadata: JSON.stringify({
tags: [
"hive-125125",
"waves",
"ecency",
"mobile",
"thread"
],
tags: JSON.parase(tags),
app: "ecency-waves",
format: "markdown+html",
}),
Expand Down
3 changes: 2 additions & 1 deletion lib/core/services/data_service/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,14 @@ class ApiService {
String parentPermlink,
String permlink,
String comment,
List<String> tags,
String? postingKey,
String? authKey,
String? token,
) async {
try {
String jsonString = await commentOnContentFromPlatform(username, author,
parentPermlink, permlink, comment, postingKey, authKey, token);
parentPermlink, permlink, comment, tags, postingKey, authKey, token);
ActionSingleDataResponse<String> response =
ActionSingleDataResponse.fromJsonString(jsonString, null,
ignoreFromJson: true);
Expand Down
2 changes: 2 additions & 0 deletions lib/core/services/data_service/mobile_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Future<String> commentOnContentFromPlatform(
String parentPermlink,
String permlink,
String comment,
List<String> tags,
String? postingKey,
String? authKey,
String? token,
Expand All @@ -66,6 +67,7 @@ Future<String> commentOnContentFromPlatform(
'parentPermlink': parentPermlink,
'permlink': permlink,
'comment': base64.encode(utf8.encode(comment)),
'tags': tags,
'postingKey': postingKey ?? '',
'token': token ?? '',
'authKey': authKey ?? '',
Expand Down
1 change: 1 addition & 0 deletions lib/core/services/data_service/service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Future<String> commentOnContentFromPlatform(
String parentPermlink,
String permlink,
String comment,
List<String> tags,
String? postingKey,
String? authKey,
String? token,
Expand Down
1 change: 1 addition & 0 deletions lib/core/services/data_service/web_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Future<String> commentOnContentFromPlatform(
String parentPermlink,
String permlink,
String comment,
List<String> tags,
String? postingKey,
String? authKey,
String? token,
Expand Down
23 changes: 23 additions & 0 deletions lib/core/utilities/act.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,29 @@ class Act {
return data?.text;
}

static List<String> compileTags(String comment) {
// Regex pattern for hashtags
RegExp pattern = RegExp(r'#(\w+)');

// Find all hashtags and discard the # character
List<String> hashtags = [];
Iterable<RegExpMatch> matches = pattern.allMatches(comment);

for (var match in matches) {
hashtags
.add(match.group(1)!); // group(1) contains the hashtag without the #
}

return [
"hive-125125",
"waves",
"ecency",
"mobile",
"thread",
...hashtags
];
}

static String generatePermlink(String username) {
final t = DateTime.now();
final timeFormat = '${t.year}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class ThreadJsonMetadata {
'vote_change':voteChange,
'hide_votes':hideVotes,
'ui_hide_res_until_voted':uiHideResUntilVoted,
'preferred_interpretation':preferredInterpretation!.value
'preferred_interpretation':preferredInterpretation?.value
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,14 @@ class SignTransactionHiveController extends HiveTransactionController {
switch (transactionType) {
case SignTransactionType.comment:
_generatedPermlink = Act.generatePermlink(authData.accountName);
List<String> tags = Act.compileTags(comment!);
return _threadRepository.commentOnContent(
authData.accountName,
author,
permlink!, //parentPermlink
_generatedPermlink!,
Act.commentWithImages(comment!, imageLinks!),
tags,
null,
authData.auth.authKey,
authData.auth.token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ class SignTransactionPostingKeyController {
}) async {
String generatedPermlink = Act.generatePermlink(authData.accountName);
String commentWithImages = Act.commentWithImages(comment, imageLinks);
List<String> tags = Act.compileTags(comment);
ActionSingleDataResponse<String> commentResponse =
await _threadRepository.commentOnContent(
authData.accountName,
author,
parentPermlink,
generatedPermlink,
commentWithImages,
tags,
authData.auth.postingKey,
null,
null);
Expand Down
3 changes: 2 additions & 1 deletion lib/features/threads/repository/thread_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ class ThreadRepository {
String parentPermlink,
String permlink,
String comment,
List<String> tags,
String? postingKey,
String? authKey,
String? token,
) async {
return await _apiService.commentOnContent(username, author, parentPermlink,
permlink, comment, postingKey, authKey, token);
permlink, comment, tags, postingKey, authKey, token);
}

Future<ActionSingleDataResponse<String>> votecontent(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+23
version: 1.0.0+24

environment:
sdk: '>=3.3.2 <4.0.0'
Expand Down

0 comments on commit 21e9e73

Please sign in to comment.