Skip to content

Commit

Permalink
Changed away from any. Minor fixes from PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilnormann committed Dec 18, 2023
1 parent 3b242d3 commit 1d68a0c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 17 deletions.
16 changes: 8 additions & 8 deletions __tests__/integrationsTests/groupHandler.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('GroupHandler', () => {

function callbackTest() : boolean{
function checkIfUserInGroup(){
GunDB.gun.user(userPub).get("groupId").once((id: any) => {
GunDB.gun.user(userPub).get("groupId").once((id: string) => {
expect(id).toBeDefined() //The logged in user should now have a groupId
testData.groupId = id
checkIfGroupExists(GunDB.gun.get("groups").get("groupId").get(id))
Expand All @@ -129,13 +129,13 @@ describe('GroupHandler', () => {
checkIfGroupHasMember(context)
}
function checkIfGroupHasMember(context : any){
context.get("members").map().once((memberId : any) => {
context.get("members").map().once((memberId : string) => {
expect(memberId).toBe(userPub) //The group should have the current user listed as a member
checkIfGroupHasName(context)
})
}
function checkIfGroupHasName(context : any){
context.get("name").once((name : any) => {
context.get("name").once((name : string) => {
expect(name).toBe(expectedGroupName) //The group should have the given name
testData.groupName = expectedGroupName
done()
Expand All @@ -160,7 +160,7 @@ describe('GroupHandler', () => {
function test(){
function callbackTest(bool : boolean) : void{
function checkIfUserInGroup(){
GunDB.gun.user(userPub).get("groupId").once((id: any) => {
GunDB.gun.user(userPub).get("groupId").once((id: string) => {
expect(id).toBeDefined() //The logged in user should now have a groupId
expect(id).toBe(groupIdToJoin) //The id should be the same as the group we wanted to join
checkIfGroupHasMember(GunDB.gun.get("groups").get("groupId").get(id))
Expand Down Expand Up @@ -194,14 +194,14 @@ describe('GroupHandler', () => {
function test(){
function callbackTest(bool : boolean) : void{
function checkIfUserInGroup(){
GunDB.gun.user(userPub).get("groupId").once((id: any) => {
GunDB.gun.user(userPub).get("groupId").once((id: string) => {
expect(id).toBeUndefined() //The logged in user should now have a groupId
checkIfGroupExistsInGun()
})
}
function checkIfGroupExistsInGun(){
const context = GunDB.gun.get("groups").get("groupId").get(groupIdToJoin)
context.once((data : any) => {
context.once((data : string) => {
expect(data).toBeUndefined() //The group id should still not exist
done()
})
Expand Down Expand Up @@ -314,7 +314,7 @@ describe('GroupHandler', () => {

function callbackTest() : boolean{
function checkIfUserInGroup(){
GunDB.gun.user(userPub).get("groupId").once((id: any) => {
GunDB.gun.user(userPub).get("groupId").once((id: string) => {
expect(id).toBeDefined() //The logged in user should now have a groupId
checkIfGroupExists(GunDB.gun.get("groups").get("groupId").get(id))
})
Expand Down Expand Up @@ -350,7 +350,7 @@ describe('GroupHandler', () => {
}

function checkIfGroupHasName(context : any){
context.get("name").once((name : any) => {
context.get("name").once((name : string) => {
expect(name).toBe(expectedGroupName) //The group should have the given name
GunDB.gun.get("groups").get("groupId").get(testData.groupId).get("name").once((oldName : any) => {
expect(oldName).toBe(expectedGroupName)
Expand Down
2 changes: 1 addition & 1 deletion app/(tabs)/shoppingList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function ToBeBoughtScreen() {
}
)

gun.user(userPub).get('fullName').open((data: any) => {
gun.user(userPub).get('fullName').once((data: string) => {
setUsername(data);
});

Expand Down
2 changes: 1 addition & 1 deletion constants/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ AsyncStorage.clear()
//rad asyncstorage adapter, on Android asyncstorage has 6mb limit by default
const asyncStore = asyncsStore({AsyncStorage});
let gun = Gun({
peers: ['http://130.225.39.205:8080/gun'],
// peers: ['http://130.225.39.205:8080/gun'],
store: asyncStore,
radisk: true,
localStorage: false,
Expand Down
6 changes: 3 additions & 3 deletions handlers/group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { Expense } from '../helpers/calculateExpenses';
import { v4 as uuid } from 'uuid'

interface IGroup {
create(groupName: string, callback : () => void): void;
join(uuid: string, callback : (ack: Boolean) => void): void;
Expand All @@ -24,7 +24,7 @@ class GroupHandle implements IGroup {
context.get("members").set(userPub)
context.get("name").put(groupName)
user.get("groupId").put(groupId)
user.get('fullName').once((data: any) => {
user.get('fullName').once((data: string) => {
if (data != undefined){
this.gun.get('groups').get("groupId").get(groupId).get('expenses').set(new Expense(data, 0, JSON.stringify([data])));
}
Expand All @@ -41,7 +41,7 @@ class GroupHandle implements IGroup {
let user = this.gun.user(userPub)
context.get("members").set(userPub)
user.get("groupId").put(uuid)
user.get('fullName').once((data: any) => {
user.get('fullName').once((data: string) => {
if (data != undefined){
this.gun.get('groups').get("groupId").get(uuid).get('expenses').set(new Expense(data, 0, JSON.stringify([data])));
}
Expand Down
4 changes: 2 additions & 2 deletions handlers/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class ShoppingListHandler implements IShoppingList {

constructor(gun: Gun) {
this.gun = gun;
gun.user(userPub).get("groupId").on((id : any) => {
gun.user(userPub).get("groupId").on((id : string) => {
this.groupId = id
})
gun.user(userPub).get("fullName").on((data: any) => {
gun.user(userPub).get("fullName").on((data: string) => {
this.userName = data
})
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/meal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MealPlanHandle implements IMealPlan {

constructor(private gun: Gun) {
this.user = this.gun.user(userPub);
this.user.get("groupId").once((data: any) => {
this.user.get("groupId").once((data: string) => {
this.groupId = data
});
}
Expand Down
27 changes: 26 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1d68a0c

Please sign in to comment.