Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
- Loading branch information
Showing
31 changed files
with
831 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
client/react-native/common/graphql/subscriptions/ConversationRead.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import EventStream from './EventStream' | ||
|
||
export default context => ({ | ||
...EventStream(context), | ||
subscribe: ({ updater }) => | ||
EventStream(context).subscribe({ | ||
updater: | ||
updater && | ||
(async (store, data) => { | ||
if (data.EventStream.kind === 303) { | ||
await context.queries.Conversation.fetch({ | ||
id: data.EventStream.conversationId, | ||
}) | ||
await context.queries.EventList.fetch({ | ||
filter: { | ||
conversationId: data.EventStream.conversationId, | ||
kind: 302, | ||
}, | ||
}) | ||
} | ||
}), | ||
}), | ||
}) |
39 changes: 39 additions & 0 deletions
39
client/react-native/common/graphql/subscriptions/EventSeen.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { parseEmbedded } from '../../helpers/json' | ||
import EventStream from './EventStream' | ||
|
||
export default context => ({ | ||
...EventStream(context), | ||
subscribe: ({ updater }) => | ||
EventStream(context).subscribe({ | ||
updater: | ||
updater && | ||
(async (store, data) => { | ||
if (data.EventStream.kind === 104) { | ||
const attributes = parseEmbedded(data.EventStream.attributes) | ||
|
||
// update all messages | ||
const events = [] | ||
attributes.ids && | ||
attributes.ids.forEach(async id => { | ||
try { | ||
events.push(await context.queries.Event.fetch({ id })) | ||
} catch (err) { | ||
console.warn(err) | ||
} | ||
}) | ||
|
||
// update all conversations | ||
events.reduce((conversations, event) => { | ||
if (conversations[event.conversationId]) { | ||
return conversations | ||
} | ||
const promise = context.queries.Conversation.fetch({ | ||
id: data.EventStream.conversationId, | ||
}) | ||
conversations[event.conversationId] = promise | ||
return conversations | ||
}, {}) | ||
} | ||
}), | ||
}), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
client/react-native/common/graphql/subscriptions/NewMessage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import EventStream from './EventStream' | ||
|
||
export default context => ({ | ||
...EventStream(context), | ||
subscribe: ({ updater }) => | ||
EventStream(context).subscribe({ | ||
updater: | ||
updater && | ||
(async (store, data) => { | ||
if (data.EventStream.kind === 302) { | ||
updater(store, data.EventStream) | ||
} | ||
}), | ||
}), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
export eventStream from './EventStream' | ||
export eventSeen from './EventSeen' | ||
export contactRequest from './ContactRequest' | ||
export contactRequestAccepted from './ContactRequestAccepted' | ||
export conversationInvite from './ConversationInvite' | ||
export conversationNewMessage from './ConversationNewMessage' | ||
export conversationRead from './ConversationRead' | ||
export newMessage from './NewMessage' | ||
export monitorPeers from './MonitorPeers' | ||
export logStream from './LogStream' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.