Save drafts for comments and issues #313

Closed
dennisreimann opened this Issue Feb 24, 2013 · 1 comment

Projects

None yet

1 participant

@dennisreimann

As discussed in #299.

Lets make it a Singleton (maybe call it TextDrafts) that is accessible throughout the app and holds the draft data in a NSDictionary instance. Here's what the accessor for that could look like:

+ (instancetype)sharedInstance {
    static id sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance = [[self alloc] init];
        sharedInstance.drafts = [[NSDictionary alloc] init];
    });
    return sharedInstance;
}

This Singleton could have a getter method for saved drafts, like
[TextDrafts sharedInstance] draftForKey:@"dennisreimann/ioctocat/pull/299/comment"]
And a setter for saving them:
[TextDrafts sharedInstance] saveDraft:@"This is what I think..." forKey:@"dennisreimann/ioctocat/pull/299/comment"]

The setter gets called whenever one leaves the CommentController without actually saving the comment. When one opens the CommentController we check whether or not a draft for the given key exists - if so, we display the text.

We should think about how to generate the keys for the individual items (Issues, Pull Requests, Gists, Commits), but this would give us the flexibility to handle all these and even future use cases for drafts, without having to specify properties and types for every item type that we want to store drafts for.

@dennisreimann

@ruddfawcett do you plan to implement this? no pressure, just asking, because otherwise I'd take it.

@dennisreimann dennisreimann added a commit that closed this issue Jun 21, 2013
@dennisreimann Add drafts for resources
Closes #313
2794ebd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment