Code Monkey home page Code Monkey logo

messagebeast-objc's People

Contributors

rrbrambley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

messagebeast-objc's Issues

Add methods for clearing all user data

Without this functionality, you cannot have a sign out feature in an app. This would include:

  1. Clearing all in-memory manager data
  2. Removing all rows from all DB tables
  3. Removing persisted channels and any other NSUserDefaults stuff

Message Manager should be smarter about whether to keep messages in memory

Currently, upon fetching new messages from the server, the message manager (pretty much) always assumes it is safe to keep the messages in the channel's message map and incorporate their ids and dates into the MinMaxPair for that channel. However, because an app could create a new message with an old display date (e.g. ohai display date annotation), it is not safe to incorporate all new messages' dates/ids into the MinMaxPair – doing so means that subsequent calls to load persisted messages will use the min max pair and potentially leave gaps of messages out. This is bad.

Rename load...temporarily methods in AATTMessageManager

I think the new naming convention should be:

load methods = load to memory, store in manager's memory map
get = get from persistence, do not store in map
retrieve = get from cloud, persist, store in map

See Android implementation.

Message and Action Message Spec primary key should be changed

Currently we rely on the Message Id for both of these tables. This is incorrect because:

• Offline message ids are created by examining the greatest message id in its target channel
• If an offline message is created in a channel, it is possible that the message id that is used already exists for a message in a different channel

The solution is most likely to change the primary key to be a messageId+channelId combo, but I will have to look into the performance implications for this.

Using MinMaxPair.minId to load messages from DB is wrong

Currently, when loading messages from the sqlite db, the min Id of the currently loaded messages are used to determine the "before date" – the date that must come after the display date of all messages to be loaded.

However, when the displayDate != createdAt on a message (e.g. an ohai date is used), the min id may correspond to a message with a display date that is after a message with a greater id. I think.

Perhaps the solution is to always keep the min display date in memory and query that way?

NSDate is failing as ordered dictionary key

Dates are failing to evaluate as equal. It seems as though using NSNumber timeIntervalSince1970 could work, but that could look messy.

(lldb) p [(NSDate *)[channelMessages.allKeys objectAtIndex:0] timeIntervalSince1970]
(double) $2 = 1394469366.168542
(lldb) p [(NSDate *)[channelMessages.allKeys objectAtIndex:0] timeIntervalSince1970] == messagePlus.displayDate.timeIntervalSince1970
(bool) $3 = true
(lldb) p [(NSDate *)[channelMessages.allKeys objectAtIndex:0] isEqualToDate:messagePlus.displayDate]
(char) $4 = '\0'
(lldb) p [(NSDate *)[channelMessages.allKeys objectAtIndex:0] isEqual:messagePlus.displayDate]
(char) $6 = '\0'

This evaluates to YES:

[[NSNumber numberWithDouble:[(NSDate *)[channelMessages.allKeys objectAtIndex:0] timeIntervalSince1970]] isEqual:[NSNumber numberWithDouble:messagePlus.displayDate.timeIntervalSince1970]]

Is it possible to just use some other dictionary key? Sigh.

Unsent messages with actions applied lose action after message is sent.

Because the message id changes after a message is sent, action messages that are created for unsent messages no longer apply after the unsent message gets sent. After a message is sent, we should somehow, automatically determine which actions have been applied to it and create new action messages for that message.

AATTOrderedMessageBatch messages dictionary does not support two messages with same date

The AATTOrderedMessageBatch contains a property of type NSOrderedDictionary, whose keys are message display dates. So, technically, if two messages are created at the same millisecond, then one of them will not be seen. Is this a problem? I don't think so. Just never create two messages with the same date. Multiple apps could post messages simultaneously though. Will they have the same exact date? Probably not. sigh

Handle invalid Place (bad factual id) in Annotation

I'm not sure what exactly would happen if you give a bogus factual id, but since we provide caching of Places via sqlite, we should handle the case where you try to use a factual id that no longer exists.

Add support for multipart Messages - to exceed max message length

The configuration object currently defines the maximum message length as 2048 characters. It'd be great if we could add way off automatically gluing together multiple messages (via annotations or something) so that they could appear as one message – for those messages that need to exceed the max.

Provide way to delete associated action messages when deleting target message

Although action messages could lay around and have no effect when a their target messages are deleted, it'd be nice to have the action messages deleted automatically. A couple ideas:

  1. ActionMessageManager listens for a broadcast that is sent whenever a delete happens, looks for action messages associated with the deleted message, deletes them.
  2. ChannelSyncManager has a method for deleting a message and does the same work as in 1) above.

Find way to make client apps call proper sendAllUnsent method

AATTMessageManager has a sendAllUnsent... method that should only be used when

  1. the specified channel is not an action channel, or
  2. the action messages in the specified action channel do not correspond to unsent target messages.

So, there is actually a method in AATTActionMessageManager that can be used to send unsent messages in action channels, and it does the right thing – only sends the messages if their target messages have been sent already. However, there is nothing preventing client apps from using the method in AATTMessageManager instead of this one.

In the Android version of this library, an exception is thrown if the MessageManager method is used for action channels, and then there is a package-visible method that the ActionMessageManager can access on the MessageManager when it needs to force sending in other scenarios. However, Objective-C doesn't really support this same thing.

Do something.

Display location instance is not persisted for messages that failed to reverse geocode on fetch

When the AATTDisplayLocations are assigned upon loading messages from the database, a value of false is passed for the persist flag in lookupLocation(). This is because we assume that the display location was already assigned once and persisted when the retrieveMessages() method was called, so we optimize by avoiding a unnecessary insert. This could technically fail for all kinds of display locations, but geolocations are more susceptible to this failure because reverse geocoding can fail easily (e.g. when performing a ton of them upon full sync).

One solution might be to just assign display locations at the DB level - i.e. to rely on the display location instances table to populate the display locations when they are being pulled from sqlite. Then, only if a message does not have a display location we will attempt location lookup and always persist one if we find it.

Add support for finding messages by annotation type

Many apps could benefit from being able to easily access messages that have specific annotations. There is already support for retrieving OEmbed instances from the sqlite database, but maybe the configuration should enable the extraction of any annotation types.

Rethink reverse geocoding usage

Currently, reverse geolocation will be performed rapidly when processing messages that need it (so, especially when a full sync is being performed).

However, I don't think Apple wants this (too many rapid fire requests) and I think it causes failures sometimes. Perhaps a queue should be maintained and they should be fired off gradually? I'm actually not sure what the best solution for this is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.