React-native-calendars: Agenda can't order by agenda start time.

Created on 12 Apr 2018  Â·  4Comments  Â·  Source: wix/react-native-calendars

when I load agendaItem I want agendaItem is ordered by agenda start time.
On simulator the result is ok,but on devices agendaItems is not ordered by start time.
image
image
image

Bug report

Most helpful comment

Could you provide a clean source code example that I could just copy paste and run in order to reproduce the problem?

All 4 comments

can you provide source code snipped to reproduce the problem in plaintext?

componentDidMount() { this._loadAgendaItems(); }

selected={moment().format('YYYY-MM-DD')}
renderItem={this.renderItem}
renderEmptyDate={this.renderEmptyDate}
renderEmptyData={this._renderEmptyData}
rowHasChanged={this.rowHasChanged}
onDayPress={(day) => {
console.log('selected day', day)
this.setState({
selectedDay: day.dateString
});
}}
onDayChange={(day)=> {
// console.log('day changed')
}}
/>

=========================================
` _loadAgendaItems = async()=> {
try {
this.stoAgendaItems = await Utility.loadStorage('stoAgendaItems');
this.stoAgendaItems[this.state.selectedDay].sort((a, b)=> {
return a.dateTimeStart > b.dateTimeStart
});

        this.setState({
            agendaItems: this.stoAgendaItems
        })
    } catch (e) {

    }}`

=========================================

`
renderItem = (item)=> {

    return (
        <View style={[styles.item]}>
            <TouchableOpacity onLongPress={()=> {
                this._agendaActions(item);
            }} style={{flex: 1}}>
                <Text style={{color: 'orange'}}>{moment(item.dateTimeStart).format('HH:mm')}</Text>
                <Text style={{paddingLeft: 15, marginTop: 10}}>{item.title}</Text>
            </TouchableOpacity>
        </View>
    );
}`

rowHasChanged = (r1, r2)=> { return r1.agendaId !== r2.agendaId; }

` _addAgenda = async(obj)=> {

    let agendaday = moment(obj.dateTimeStart).format('YYYY-MM-DD');

    try {
        this.stoAgendaItems = await Utility.loadStorage('stoAgendaItems');

    } catch (e) {
        console.log('e')
    }


    if (!this.stoAgendaItems[agendaday]) {
        this.stoAgendaItems[agendaday] = [];
    }

    obj.agendaId = moment().format('x');

    this.stoAgendaItems[agendaday].push(obj); 

    storage.save({
        key: 'stoAgendaItems',
        data: this.stoAgendaItems,
        expires: null
    });

    this._loadAgendaItems();
}

`

{"2018-04-11":[{"time":"09:01","agendaId":"1523416314746","title":"22233333","dateTimeStart":"2018-04-11 09:01","dateTimeEnd":"2018-04-11 13:01","notificationId":"1523416314","repeat":false,"agendaRemarks":"","notificationAheadTime":0,"editAgendaItem":{"time":"12:01","agendaId":"1523415710565","title":"222","dateTimeStart":"2018-04-11 12:01","dateTimeEnd":"2018-04-11 13:01","notificationId":"1523415710","repeat":false,"agendaRemarks":"","notificationAheadTime":0,"editAgendaItem":null}},{"time":"12:01","agendaId":"1523415699355","title":"111","dateTimeStart":"2018-04-11 12:01","dateTimeEnd":"2018-04-11 13:01","notificationId":"1523415699","repeat":false,"agendaRemarks":"","notificationAheadTime":0,"editAgendaItem":null}],"2018-04-12":[{"time":"22:50","agendaId":"1523541034641","title":"111","dateTimeStart":"2018-04-12 22:50","dateTimeEnd":"2018-04-12 23:50","notificationId":"1523541034","repeat":false,"agendaRemarks":"","notificationAheadTime":0,"editAgendaItem":null},{"time":"22:50","agendaId":"1523541039631","title":"2222","dateTimeStart":"2018-04-12 22:50","dateTimeEnd":"2018-04-12 23:50","notificationId":"1523541039","repeat":false,"agendaRemarks":"","notificationAheadTime":0,"editAgendaItem":null},{"time":"22:50","agendaId":"1523541047254","title":"3333","dateTimeStart":"2018-04-12 22:50","dateTimeEnd":"2018-04-12 23:50","notificationId":"1523541047","repeat":false,"agendaRemarks":"","notificationAheadTime":0,"editAgendaItem":null}]}

Do you confirm is this a bug ? if it will be fixed next release.Thank you so much @tautvilas

Could you provide a clean source code example that I could just copy paste and run in order to reproduce the problem?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MrAlekhin picture MrAlekhin  Â·  4Comments

matieux picture matieux  Â·  4Comments

moiiiiit picture moiiiiit  Â·  4Comments

sommeshEwall picture sommeshEwall  Â·  3Comments

ercpereda picture ercpereda  Â·  4Comments