chatrooms | This README would normally document whatever steps | Application Framework library
kandi X-RAY | chatrooms Summary
kandi X-RAY | chatrooms Summary
This README would normally document whatever steps are necessary to get the application up and running.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Returns the authenticated user .
chatrooms Key Features
chatrooms Examples and Code Snippets
Community Discussions
Trending Discussions on chatrooms
QUESTION
I want to limit the access to detailView of a chatroom to the owner and participants of the room(joiners)
model:
...ANSWER
Answered 2021-Jun-14 at 23:44Because you have an "OR" clause that will both return a record, you need to make sure you return "distinct" records
QUESTION
I am trying to solve this but I can't, I pass the state from a parent to child component like this:
Main.js
...ANSWER
Answered 2021-Jun-14 at 01:01From what I can parse though in your code it seems like currentRoom
should be an entire room object, but in the select's onChange handler you are updating it to be a room id value.
I think you need to pass the entire room object as the option's value.
QUESTION
Im creating an app with react native and face the problem that I create multiple firebase listeners troughout the app, listeners on different screens to be precise and also listeners that listen to the firebase-database
and others listening to the firestore
.
What I want to accomplish is to kill all those listeners with one call or if necessary with multiple lines but as compact as possible - and also from an entire different screen where the listeners arent even running, this is important.
I know that there is the possibility to use Firebase.goOffline()
but this only disconnects me from the Firebase - it doesnt stop the listeners. As soon as I goOnline()
again, the listeners are all back.
I didnt find any solution yet for this problem from google etc thats why I try to ask here now, I would appriciate if anybody would have an idea how maybe an approach how to handle this type of behavior.
The following code samples provide you with listeners I included inside my app, they are located in in the same screen but I have nearly identical ones in other screens.
Database listener:
...ANSWER
Answered 2021-May-25 at 04:59All of the subscribe functions return the unsubscribe function
QUESTION
Im having a bunch of documents in a collection in firestore. What I want to archieve is to search the documents by a "timestamp" property, after that I want to delete exactly this document.
My code looks right now like this:
...ANSWER
Answered 2021-May-19 at 11:55I can't see .delete()
in your code. Also you cannot combine .delete()
and .where()
. You need the document IDs or the references to them. You can try this:
QUESTION
Im new to React-Native and currently building a chat-function into my app. To visualize the chat Im using a FlatList (before I used Scrollview but with FlatList I have better performance with multiple items), netherless I have two big problems.
- As I write more chatmessages more and more messages are getting appended to my chatmessages hook. One message is not a problem, but after 2 or 3 the whole FlatList starts to blink and reload. This gets worse if I append even more messages.
- When I send more then 3 Messages to the Database, and they get downloaded by the firestore listener to my FlatList, those items arent even properly rendered into my FlatList. I use concat to add them at the end of my chatmessages state but FlatList displays them at the beginning of the whole chat! After that it blinks, and the new message drops one item lower, it blinks again and it drops lower, and this happens so long until the new message finally dropped to the end of the whole chat where it should be. It doesnt make sense at all because I use concat, so the new chatmessages are at the end of my whole chatmessages array, why is FlatList(and also Scrollview) adding them at the beginning and rerendering as much as they need to drop it to the bottom??
My Code looks like this:
...ANSWER
Answered 2021-May-07 at 16:03A key issue here is with your useEffect(() => loadnewmessages())
. This is causing you a major performance overhead.
useEffect
is a hook that has 2 parameters:
- a "callback" - a function that will be run whenever the conditions (see #2)are met
- dependency condition - one of 3 values:
null
(or omitted entirely) - the callback is run EVERY TIME the component renders[]
(the empty array) - the callback is run only once when the component is first "mounted"[var1, var2, .....]
- the callback is run if, each time the component is renders, any of the vars in the array has a different value than the last time the component rendered
In your case, you are fetching data from Firestore EVERY SINGLE TIME that the component renders.
Worse - each time your component renders you are using an onSnapshot()
call meaning that you are creating a NEW realtime listener for data changes from that query every single time your component renders. After 1 render, you'll have a single listener. After you component renders a second time, you'll have 2 realtime listeners - each running the exact same Firestore query and listening for changes coming from Firestore. After 3 renders, you have 3 realtime listeners ...
Worse again - your realtime listener(s) get data from Firestore and update state. Updating state causes your component to re-render. See previous paragraph(!!!)
I recommend you look at how React's useEffect should be used in conjunction with Firestore realtime listeners. In particular, how to subscribe & unsubscribe to the listeners. Look for the word "unsubscribe" in this article for an example of useEffect()
with Firestore (the section entitled "Streaming data in real time from Firestore as a side effect")
QUESTION
I have a little problem regarding googles firestorage. I have data in my firestore sorted following way:
...ANSWER
Answered 2021-Mar-31 at 07:15As mentioned by @Aside in the comments, change how you log the output and use doc.data().value
:
QUESTION
My data in firestore is arranged like this:
What I want to archieve is basicly get all "values" out of each doc which I have 3 of this now in the one collection I show in the secound picture. I want to download it only once. The structure is the following:
chatrooms --> ChatId(1) --> ChatId(2) --> chatmessage
or simpler to understand:
collection --> doc --> collection --> doc
I want to loop through all chattmessages in "ChatId(2)" and get all "value"s out of each "chatmessage" and store them in an array.
I face the difficulty trying to handle such difficult (at least for me) nested calls to firebase and wanted to search for help here. Im working in react-native so Javascript is my language Im using here.
...ANSWER
Answered 2021-Apr-29 at 17:39Got it working on my own, my code looks like this incase you want to replicate it:
QUESTION
I run into a little problem regarding firebase and probably something regarding async functions, Im still new to react-native and js, so I fail to resolve this error on my own.
I have following code snipped:
...ANSWER
Answered 2021-Mar-30 at 19:07The Array.forEach
method doesn't expect a return value from the closure.
You're probably looking for Array.map
:
QUESTION
I want to use my firestore time for my chat app. I coded below code but there is a problem about firestore Field Value.
I send my message to firestore like:
...ANSWER
Answered 2021-Mar-24 at 14:21This is due to what Firebase calls "latency compensation":
Local writes in your app will invoke snapshot listeners immediately. This is because of an important feature called "latency compensation." When you perform a write, your listeners will be notified with the new data before the data is sent to the backend.
Your snapshot is triggered before leaving your app, and the field for the timestamp will be null
, then it will be triggered again after reaching the backend with the timestamp set.
To differentiate between the two, use the field metadata.hasPendingWrites
as described in the documentation.
QUESTION
I've got a Collection message
which contains both a document (representing the chat room) and a nested collection which contains all the messages of that conversation.
Now I'd like to request all the documents (chat rooms) in which my user is involved. So if one of the id1
or id2
fields in the users
map is equal to my user id, I collect that document.
I've noticed that I can't use array queries as I'm using maps and not arrays.
So I don't know what would be the best approach to proceed to that query.
...ANSWER
Answered 2021-Mar-19 at 14:52See Frank's comment below: The best solution is to "use an array of user IDs (userIDs: ["ABCDEF", "GHIJKL"]
) and an array-contains
condition. In this use-case it seems that would save on the number of needed indexes (and thus on the cost of storage)".
If you really need to keep the map for other reasons, you can very well have the two fields in the doc. It's not a problem to duplicate the data.
If the value you assign to each userId in the map does not have to be meaningful, you can assign a Boolean value of true
and then query as follows:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install chatrooms
On a UNIX-like operating system, using your system’s package manager is easiest. However, the packaged Ruby version may not be the newest one. There is also an installer for Windows. Managers help you to switch between multiple Ruby versions on your system. Installers can be used to install a specific or multiple Ruby versions. Please refer ruby-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page