Skip to content

Commit

Permalink
current stand
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Sep 26, 2023
1 parent b38b59c commit 23b49d3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/utils/nostr_fetcher/NostrSocket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:async';
import 'package:flutter_logs/flutter_logs.dart';
import 'package:locus/constants/values.dart';
import 'package:locus/services/location_point_service.dart';
import 'package:locus/services/task_service/index.dart';
import 'package:locus/services/task_service/mixins.dart';
import 'package:locus/utils/nostr_fetcher/BasicNostrFetchSocket.dart';
import 'package:locus/utils/nostr_fetcher/Socket.dart';
Expand Down Expand Up @@ -121,10 +120,12 @@ class NostrSocket extends BasicNostrFetchSocket {
final int? limit,
final DateTime? from,
final DateTime? until,
final List<String>? authors,
}) =>
Filter(
kinds: kinds,
limit: limit,
authors: authors ?? [],
since:
from == null ? null : (from.millisecondsSinceEpoch / 1000).floor(),
until: until == null
Expand Down
6 changes: 6 additions & 0 deletions lib/utils/nostr_fetcher/Socket.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:flutter_logs/flutter_logs.dart';
Expand Down Expand Up @@ -75,6 +76,11 @@ abstract class Socket {
return;
}

// Prettify event.content
print(
jsonDecode(event)[2],
);

_resetTimer();

onEvent(event);
Expand Down
27 changes: 27 additions & 0 deletions lib/widgets/RelaySelectSheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_logs/flutter_logs.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:latlong2/latlong.dart';
import 'package:locus/constants/spacing.dart';
import 'package:locus/constants/values.dart';
import 'package:locus/services/location_point_service.dart';
import 'package:locus/utils/load_status.dart';
import 'package:locus/utils/nostr_fetcher/NostrSocket.dart';
import 'package:locus/utils/theme.dart';
import 'package:locus/widgets/BottomSheetFilterBuilder.dart';
import 'package:locus/widgets/ModalSheet.dart';
import 'package:nostr/nostr.dart';

import '../api/nostr-relays.dart';
import '../utils/cache.dart';
Expand Down Expand Up @@ -135,6 +139,29 @@ class _RelaySelectSheetState extends State<RelaySelectSheet> {
_closeSheet();
}
});

final socket = NostrSocket(
relay: "wss://history.nostr.watch",
decryptMessage: (_) async {
return LocationPointService.dummyFromLatLng(LatLng(0, 0));
},
);
socket.connect().then((_) {
socket.addData(
Request(
generate64RandomHexChars(),
[
NostrSocket.createNostrRequestData(
kinds: [30304],
limit: 10,
authors: [
"b3b0d247f66bf40c4c9f4ce721abfe1fd3b7529fbc1ea5e64d5f0f8df3a4b6e6"
],
),
],
).serialize(),
);
});
}

_closeSheet() {
Expand Down

0 comments on commit 23b49d3

Please sign in to comment.