Skip to content

Commit

Permalink
update refer
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Oct 19, 2023
1 parent 9eb021a commit 7696ec3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/src/conversation/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class Conversation {
public id: number;
public data: Message[];
public end: boolean;
public refer: string;

public constructor(id: number, callback?: ConversationCallback) {
if (callback) this.setCallback(callback);
Expand All @@ -19,12 +20,14 @@ export class Conversation {
this.id = id;
this.end = true;
this.connection = new Connection(this.id);
this.refer = "";

if (id === -1 && this.idx === -1) {
event.bind(({ refer, data }) => {
console.log(
`[conversation] load from sharing event (ref: ${refer}, length: ${data.length})`,
);
this.refer = refer;
this.load(data);
});
}
Expand Down
14 changes: 14 additions & 0 deletions manager/conversation/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,17 @@ func UseSharedConversation(db *sql.DB, user *auth.User, hash string) *Conversati
Message: shared.Messages,
}
}

func (c *Conversation) LoadSharing(db *sql.DB, hash string) {
if strings.TrimSpace(hash) == "" {
return
}

shared, err := GetSharedConversation(db, hash)
if err != nil {
return
}

c.Message = shared.Messages
c.Name = shared.Name
}

0 comments on commit 7696ec3

Please sign in to comment.