-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement chat messages, mtproto typings and so on #8
Conversation
* Implemented mesage slice loading. Use method api/chats loadSliceRange. It can load various slices ov history, helpful for continious history loading. * Implemented redux fields chats (possibly should named as dialogs) and users * *chats*. Main dialogs cache, reacts to slice loading, store every dialog messages in normalized form * *users*. Draft realisation. Automatically updates if loaded slice contains unknown users. * Implemented chat message component. "Dumb" message component also created in Chat folder, because it seems to me that in the future Chat component will become container, and its was better to debug when all child components was located in the same folder. * Added Mtproto typings. Its really necessary when anybody will add typings to api actions, because almost all api actions begins with server response invoking. * Moved complex thunk actions out from redux/modules. This dir contains sub-reducers composed to redux state. Possibly it should named as redux/state or redux/reducers with current reducers.ts as index.ts file. * Css styling helper classes in helpers/classes * DC_SERVER env trim
@@ -1,9 +1,10 @@ | |||
import { trim } from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change path to lodash/trim
@@ -95,8 +97,8 @@ export function generateDialogIndex(date) { | |||
export function getDataCenters() { | |||
const tl = TypeLanguage; | |||
const promises = Promise.all([ | |||
invoke('help.getConfig'), | |||
invoke('help.getNearestDc'), | |||
invoke<IMtpHelpGetConfig>('help.getConfig'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like this? https://goo.gl/JmBEwO
@@ -0,0 +1,86 @@ | |||
import { invoke, APP_HASH, APP_ID, makePasswordHash } from 'helpers/Telegram'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this in api/auth
folder? Why just don't leave it in modules/auth
but rename to actions.ts
or something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api folder is going to be huge, really bigger than modules folder itself. I don`t know where is should be, but now modules folder seems to be pure store implemenation directory
dispatch(MESSAGES.INIT(peer)); | ||
invoke('messages.getHistory', { | ||
invoke<IMtpMessagesSlice>('messages.getHistory', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again https://goo.gl/JmBEwO
addNewIds(state, users), | ||
}, []); | ||
|
||
// const byId = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is users?
Tree walk filter going to help to sanitize response from server (after invoke). Remove any function or name with _ excepts _typeName
Fixed bug, when function recives array as main object, its return Array-like object
Switch to pure function component
* dialogs * peers - map id: chat | user | channel * Loadings - united field for loadings flags * Selected - united field for selection flags
Chats store field renmed as histories New chats field works as dictionary for chat data
Separate containers and views. Make view components pure functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not ok
@@ -2,7 +2,7 @@ import * as React from 'react'; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not in Components/Chat/Message
|
||
type ITransformer = <F, G>(payload: G) => Array<[number, F]>; | ||
|
||
export const changeReducer = <G>(transformer: ITransformer) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird helper...
|
||
const byIdOnDialogsDone = getReduce(getDialogs, addChanged); | ||
|
||
const byId = createReducer({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createReducer
have type param which represents state
[GET_DIALOGS.DONE]: byIdOnDialogsDone, | ||
}, {}); | ||
|
||
const reducer = combineReducers({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also generic type param
chatList: boolean; | ||
}; | ||
|
||
const setTrue = () => true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent with modules/auth
, also ramda
has R.T
and R.F
export const loadSliceRange = (dispatch: IDispatch) => | ||
(id: number, peer: IMtpPeer, offset: number = 0, limit: number = 10) => { | ||
const adapter = (slice: IMtpMessagesSlice) => { | ||
const pure = rejectDashAndFuncs(slice); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this isn't in invoke
?
return message.from_id; | ||
}; | ||
|
||
const saveConversation = (c, m) => dialog => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
miss
@@ -1,14 +1,13 @@ | |||
import { CHATS } from 'actions'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why api/histories
mixed with api/dialogs
?
75b862a
to
eba5738
Compare
Merge pull request from goodmind * feat(FileManager): port from webogram * feat(WebpManager): mocked * feat(Telegram/Files): downloading small files * feat(PeerPhoto): download peer photo * refactor(Message): change img to PeerPhoto
(cherry picked from commit 5e67441)
(cherry picked from commit 260498b)
(cherry picked from commit b6a106b)
* refactor(PeerPhoto): get cached photo * refactor(Telegram/Files): uncomment getCachedFile method
Roadmap Updates
|
R.T and R.F are already implemented at d4e7315 |
Implement chat messages, mtproto typings and so on
Implement chat messages, mtproto typings and so on
Implemented mesage slice loading.
Use method api/chats loadSliceRange. It can load various slices ov history, helpful for continious history loading.
Implemented redux fields chats (possibly should named as dialogs) and users
Implemented chat message component. "Dumb" message component also created in Chat folder, because it seems to me that in the future Chat component will become container, and its was better to debug when all child components was located in the same folder.
Added Mtproto typings. Its really necessary when anybody will add typings to api actions, because almost all api actions begins with server response invoking.
Moved complex thunk actions out from redux/modules. This dir contains sub-reducers composed to redux state. Possibly it should named
as redux/state or redux/reducers with current reducers.ts as index.ts file.
Css styling helper classes in helpers/classes
DC_SERVER env trim