Skip to content
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

Merged
merged 56 commits into from
Jan 15, 2017

Conversation

zerobias
Copy link
Contributor

@zerobias zerobias commented Jan 9, 2017

  • 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

* 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';
Copy link
Owner

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'),
Copy link
Owner

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';
Copy link
Owner

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?

Copy link
Contributor Author

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', {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addNewIds(state, users),
}, []);

// const byId =
Copy link
Owner

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
@goodmind goodmind added this to the 0.1 milestone Jan 12, 2017
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
Copy link
Owner

@goodmind goodmind left a 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';

Copy link
Owner

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) =>
Copy link
Owner

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({
Copy link
Owner

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({
Copy link
Owner

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;
Copy link
Owner

@goodmind goodmind Jan 14, 2017

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);
Copy link
Owner

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 => {
Copy link
Owner

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';
Copy link
Owner

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?

@zerobias zerobias force-pushed the develop branch 2 times, most recently from 75b862a to eba5738 Compare January 15, 2017 11:10
zerobias and others added 8 commits January 15, 2017 14:13
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)
* refactor(PeerPhoto): get cached photo
* refactor(Telegram/Files): uncomment getCachedFile method
@goodmind
Copy link
Owner

goodmind commented Jan 15, 2017

Roadmap Updates

@goodmind goodmind merged commit 5a23982 into goodmind:development Jan 15, 2017
@zerobias
Copy link
Contributor Author

R.T and R.F are already implemented at d4e7315

goodmind pushed a commit that referenced this pull request Mar 7, 2017
goodmind added a commit that referenced this pull request Feb 18, 2018
Implement chat messages, mtproto typings and so on
goodmind added a commit that referenced this pull request Feb 18, 2018
Implement chat messages, mtproto typings and so on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants